Update app.py
Browse files
app.py
CHANGED
@@ -18,13 +18,18 @@ if not os.path.exists("fastdepth"):
|
|
18 |
# 🟢 Thêm `fastdepth` vào `sys.path`
|
19 |
sys.path.append(os.path.abspath("fastdepth"))
|
20 |
|
|
|
|
|
|
|
|
|
|
|
21 |
# 🟢 Import FastDepth
|
22 |
-
from fastdepth.models import MobileNetSkipAdd
|
23 |
|
24 |
# 🟢 Load mô hình FastDepth
|
25 |
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
26 |
-
model = MobileNetSkipAdd(output_size=(224, 224)) # 🔹
|
27 |
-
model.load_state_dict(torch.load(
|
28 |
model.eval().to(device)
|
29 |
|
30 |
@app.post("/analyze_path/")
|
|
|
18 |
# 🟢 Thêm `fastdepth` vào `sys.path`
|
19 |
sys.path.append(os.path.abspath("fastdepth"))
|
20 |
|
21 |
+
# 🟢 Đảm bảo file trọng số tồn tại
|
22 |
+
weights_path = "fastdepth/models/fastdepth_nyu.pt"
|
23 |
+
if not os.path.exists(weights_path):
|
24 |
+
os.system(f"wget -O {weights_path} https://github.com/dwofk/fast-depth/raw/master/models/fastdepth_nyu.pt")
|
25 |
+
|
26 |
# 🟢 Import FastDepth
|
27 |
+
from fastdepth.models import MobileNetSkipAdd
|
28 |
|
29 |
# 🟢 Load mô hình FastDepth
|
30 |
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
31 |
+
model = MobileNetSkipAdd(output_size=(224, 224)) # 🔹 Fix lỗi thiếu `output_size`
|
32 |
+
model.load_state_dict(torch.load(weights_path, map_location=device))
|
33 |
model.eval().to(device)
|
34 |
|
35 |
@app.post("/analyze_path/")
|