Update app.py
Browse files
app.py
CHANGED
@@ -3,7 +3,7 @@ import time
|
|
3 |
import numpy as np
|
4 |
import cv2
|
5 |
import torch
|
6 |
-
from transformers import
|
7 |
from fastapi import FastAPI, File, UploadFile, Response
|
8 |
from fastapi.responses import FileResponse, HTMLResponse
|
9 |
from PIL import Image
|
@@ -15,8 +15,8 @@ app = FastAPI()
|
|
15 |
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
16 |
|
17 |
# 🟢 Tải model DPT-Hybrid để tăng tốc
|
18 |
-
feature_extractor =
|
19 |
-
model =
|
20 |
model.eval()
|
21 |
|
22 |
@app.post("/analyze_path/")
|
|
|
3 |
import numpy as np
|
4 |
import cv2
|
5 |
import torch
|
6 |
+
from transformers import AutoImageProcessor, AutoModelForDepthEstimation
|
7 |
from fastapi import FastAPI, File, UploadFile, Response
|
8 |
from fastapi.responses import FileResponse, HTMLResponse
|
9 |
from PIL import Image
|
|
|
15 |
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
16 |
|
17 |
# 🟢 Tải model DPT-Hybrid để tăng tốc
|
18 |
+
feature_extractor = AutoImageProcessor.from_pretrained("Intel/dpt-swinv2-tiny-256")
|
19 |
+
model = AutoModelForDepthEstimation.from_pretrained("Intel/dpt-swinv2-tiny-256").to(device)
|
20 |
model.eval()
|
21 |
|
22 |
@app.post("/analyze_path/")
|