adpro commited on
Commit
04109fd
·
verified ·
1 Parent(s): ed02dc5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -4
app.py CHANGED
@@ -12,7 +12,7 @@ import uvicorn
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")
@@ -20,9 +20,14 @@ if not os.path.exists(zoe_path):
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")
 
12
 
13
  app = FastAPI()
14
 
15
+ # 🟢 Clone ZoeDepth nếu chưa
16
  zoe_path = "ZoeDepth"
17
  if not os.path.exists(zoe_path):
18
  os.system("git clone https://github.com/isl-org/ZoeDepth.git")
 
20
  # 🟢 Thêm ZoeDepth vào sys.path để import được
21
  sys.path.append(os.path.abspath(zoe_path))
22
 
23
+ # 🟢 Cài đặt ZoeDepth (nếu cần)
24
+ try:
25
+ from zoedepth.models.builder import build_model
26
+ from zoedepth.utils.config import get_config
27
+ except ModuleNotFoundError:
28
+ os.system("pip install -e ZoeDepth") # 🟢 Cài đặt ZoeDepth trong môi trường runtime
29
+ from zoedepth.models.builder import build_model
30
+ from zoedepth.utils.config import get_config
31
 
32
  # 🟢 Load mô hình ZoeDepth-Tiny
33
  device = torch.device("cuda" if torch.cuda.is_available() else "cpu")