Update app.py
Browse files
app.py
CHANGED
|
@@ -96,10 +96,8 @@ from PIL import Image
|
|
| 96 |
from skimage.util import img_as_ubyte, img_as_float
|
| 97 |
|
| 98 |
def create_3d_obj(foreground, depth_image, background, image_path, depth=12):
|
| 99 |
-
# Resize depth_image to match the size of the foreground
|
| 100 |
-
depth_image_resized =
|
| 101 |
-
Image.fromarray(depth_image).resize(foreground.shape[:2][::-1], Image.LANCZOS)
|
| 102 |
-
)
|
| 103 |
|
| 104 |
# Normalize depth_image_resized to the range [0, 1]
|
| 105 |
min_depth = np.min(depth_image_resized)
|
|
@@ -170,7 +168,6 @@ def create_3d_obj(foreground, depth_image, background, image_path, depth=12):
|
|
| 170 |
|
| 171 |
return gltf_path
|
| 172 |
|
| 173 |
-
|
| 174 |
# Gradio Interface
|
| 175 |
title = "Depth Estimation & 3D Reconstruction Demo"
|
| 176 |
description = "Upload an image and optionally a depth map (in .npy or image format) to generate a 3D model. If no depth map is provided, the DPT model will generate it."
|
|
|
|
| 96 |
from skimage.util import img_as_ubyte, img_as_float
|
| 97 |
|
| 98 |
def create_3d_obj(foreground, depth_image, background, image_path, depth=12):
|
| 99 |
+
# Resize depth_image to match the size of the foreground using OpenCV
|
| 100 |
+
depth_image_resized = cv2.resize(depth_image, (foreground.shape[1], foreground.shape[0]), interpolation=cv2.INTER_LANCZOS4)
|
|
|
|
|
|
|
| 101 |
|
| 102 |
# Normalize depth_image_resized to the range [0, 1]
|
| 103 |
min_depth = np.min(depth_image_resized)
|
|
|
|
| 168 |
|
| 169 |
return gltf_path
|
| 170 |
|
|
|
|
| 171 |
# Gradio Interface
|
| 172 |
title = "Depth Estimation & 3D Reconstruction Demo"
|
| 173 |
description = "Upload an image and optionally a depth map (in .npy or image format) to generate a 3D model. If no depth map is provided, the DPT model will generate it."
|