Update app.py
Browse files
app.py
CHANGED
@@ -31,7 +31,7 @@ async def analyze_path(file: UploadFile = File(...)):
|
|
31 |
# 🔵 Resize ảnh để xử lý nhanh hơn
|
32 |
image = image.resize((256, 256))
|
33 |
image_np = np.array(image)
|
34 |
-
|
35 |
|
36 |
# 🟢 Chuẩn bị ảnh cho mô hình
|
37 |
inputs = processor(images=image_np, return_tensors="pt").to(device)
|
@@ -42,8 +42,8 @@ async def analyze_path(file: UploadFile = File(...)):
|
|
42 |
|
43 |
# 🟢 Xử lý ảnh sau khi dự đoán
|
44 |
predicted_depth = outputs.predicted_depth.squeeze().cpu().numpy()
|
45 |
-
depth_map = (predicted_depth
|
46 |
-
|
47 |
# 🔵 Chuyển depth_map thành ảnh có thể hiển thị
|
48 |
depth_colored = cv2.applyColorMap(depth_map, cv2.COLORMAP_INFERNO)
|
49 |
depth_pil = Image.fromarray(depth_colored)
|
|
|
31 |
# 🔵 Resize ảnh để xử lý nhanh hơn
|
32 |
image = image.resize((256, 256))
|
33 |
image_np = np.array(image)
|
34 |
+
# flipped_image = cv2.flip(image_np, -1) # Lật ảnh
|
35 |
|
36 |
# 🟢 Chuẩn bị ảnh cho mô hình
|
37 |
inputs = processor(images=image_np, return_tensors="pt").to(device)
|
|
|
42 |
|
43 |
# 🟢 Xử lý ảnh sau khi dự đoán
|
44 |
predicted_depth = outputs.predicted_depth.squeeze().cpu().numpy()
|
45 |
+
depth_map = (predicted_depth - predicted_depth.min()) / (predicted_depth.max() - predicted_depth.min())
|
46 |
+
#depth_map = (predicted_depth * 255 / predicted_depth.max()).astype("uint8")
|
47 |
# 🔵 Chuyển depth_map thành ảnh có thể hiển thị
|
48 |
depth_colored = cv2.applyColorMap(depth_map, cv2.COLORMAP_INFERNO)
|
49 |
depth_pil = Image.fromarray(depth_colored)
|