adpro commited on
Commit
4b32247
·
verified ·
1 Parent(s): 4d26de9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -3
app.py CHANGED
@@ -14,8 +14,8 @@ app = FastAPI()
14
  device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
15
 
16
  # 🟢 Tải model DPT-Hybrid thay cho ZoeDepth để tăng tốc
17
- feature_extractor = DPTFeatureExtractor.from_pretrained("Intel/dpt-hybrid-midas")
18
- model = DPTForDepthEstimation.from_pretrained("Intel/dpt-hybrid-midas").to(device)
19
  model.eval()
20
 
21
  @app.post("/analyze_path/")
@@ -27,7 +27,7 @@ async def analyze_path(file: UploadFile = File(...)):
27
  image = Image.open(io.BytesIO(image_bytes)).convert("RGB")
28
 
29
  # 🔵 Resize ảnh để xử lý nhanh hơn
30
- image = image.resize((256, 256)) # Giảm kích thước giúp tăng tốc độ xử lý
31
  image_np = np.array(image)
32
  flipped_image = cv2.flip(image_np, -1)
33
  # 🟢 Chuẩn bị ảnh cho mô hình
 
14
  device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
15
 
16
  # 🟢 Tải model DPT-Hybrid thay cho ZoeDepth để tăng tốc
17
+ feature_extractor = DPTFeatureExtractor.from_pretrained("Intel/dpt-small")
18
+ model = DPTForDepthEstimation.from_pretrained("Intel/dpt-small").to(device)
19
  model.eval()
20
 
21
  @app.post("/analyze_path/")
 
27
  image = Image.open(io.BytesIO(image_bytes)).convert("RGB")
28
 
29
  # 🔵 Resize ảnh để xử lý nhanh hơn
30
+ image = image.resize((192, 192)) # Giảm kích thước giúp tăng tốc độ xử lý
31
  image_np = np.array(image)
32
  flipped_image = cv2.flip(image_np, -1)
33
  # 🟢 Chuẩn bị ảnh cho mô hình