Update app.py
Browse files
app.py
CHANGED
|
@@ -95,7 +95,7 @@ def process_image(image_path, depth_map_path=None):
|
|
| 95 |
return [img, gltf_path, gltf_path]
|
| 96 |
|
| 97 |
def create_3d_obj(foreground, depth_image, background, image_path, depth=14):
|
| 98 |
-
# Enforce minimum depth and
|
| 99 |
depth = max(depth, 2) # Ensure depth is at least 2
|
| 100 |
print(f"Using depth value: {depth}") # Debug statement to trace depth value
|
| 101 |
|
|
@@ -137,10 +137,12 @@ def create_3d_obj(foreground, depth_image, background, image_path, depth=14):
|
|
| 137 |
pcd, depth=depth, width=1, scale=2, linear_fit=True
|
| 138 |
)
|
| 139 |
except RuntimeError as e:
|
| 140 |
-
|
|
|
|
| 141 |
if depth > 2:
|
| 142 |
-
|
| 143 |
-
|
|
|
|
| 144 |
else:
|
| 145 |
raise RuntimeError(f"Poisson reconstruction failed with minimum depth setting of 2. Original error: {e}")
|
| 146 |
|
|
|
|
| 95 |
return [img, gltf_path, gltf_path]
|
| 96 |
|
| 97 |
def create_3d_obj(foreground, depth_image, background, image_path, depth=14):
|
| 98 |
+
# Enforce minimum depth and debug statement
|
| 99 |
depth = max(depth, 2) # Ensure depth is at least 2
|
| 100 |
print(f"Using depth value: {depth}") # Debug statement to trace depth value
|
| 101 |
|
|
|
|
| 137 |
pcd, depth=depth, width=1, scale=2, linear_fit=True
|
| 138 |
)
|
| 139 |
except RuntimeError as e:
|
| 140 |
+
print(f"Error during Poisson reconstruction with depth={depth}: {e}")
|
| 141 |
+
# Check if depth is above minimum value
|
| 142 |
if depth > 2:
|
| 143 |
+
next_depth = max(depth - 2, 2) # Decrement depth but ensure it doesn't go below 2
|
| 144 |
+
print(f"Retrying Poisson reconstruction with lower depth={next_depth}")
|
| 145 |
+
return create_3d_obj(foreground, depth_image, background, image_path, depth=next_depth)
|
| 146 |
else:
|
| 147 |
raise RuntimeError(f"Poisson reconstruction failed with minimum depth setting of 2. Original error: {e}")
|
| 148 |
|