Update app.py
Browse files
app.py
CHANGED
@@ -1,5 +1,6 @@
|
|
1 |
import io
|
2 |
import os
|
|
|
3 |
import time
|
4 |
import numpy as np
|
5 |
import cv2
|
@@ -11,17 +12,21 @@ import uvicorn
|
|
11 |
|
12 |
app = FastAPI()
|
13 |
|
14 |
-
# 🟢
|
15 |
-
|
|
|
16 |
os.system("git clone https://github.com/isl-org/ZoeDepth.git")
|
17 |
|
18 |
-
# 🟢
|
19 |
-
|
20 |
-
|
|
|
|
|
|
|
21 |
|
22 |
# 🟢 Load mô hình ZoeDepth-Tiny
|
23 |
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
24 |
-
config = get_config("
|
25 |
model = build_model(config).to(device)
|
26 |
model.eval()
|
27 |
|
|
|
1 |
import io
|
2 |
import os
|
3 |
+
import sys
|
4 |
import time
|
5 |
import numpy as np
|
6 |
import cv2
|
|
|
12 |
|
13 |
app = FastAPI()
|
14 |
|
15 |
+
# 🟢 Kiểm tra nếu ZoeDepth chưa được tải, thì tải về
|
16 |
+
zoe_path = "ZoeDepth"
|
17 |
+
if not os.path.exists(zoe_path):
|
18 |
os.system("git clone https://github.com/isl-org/ZoeDepth.git")
|
19 |
|
20 |
+
# 🟢 Thêm ZoeDepth vào sys.path để import được
|
21 |
+
sys.path.append(os.path.abspath(zoe_path))
|
22 |
+
|
23 |
+
# 🟢 Import ZoeDepth sau khi đã tải về
|
24 |
+
from zoedepth.models.builder import build_model
|
25 |
+
from zoedepth.utils.config import get_config
|
26 |
|
27 |
# 🟢 Load mô hình ZoeDepth-Tiny
|
28 |
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
29 |
+
config = get_config(f"{zoe_path}/configs/zoedepth_tiny.py") # 🟢 Chọn model tiny để chạy nhanh hơn
|
30 |
model = build_model(config).to(device)
|
31 |
model.eval()
|
32 |
|