Update app.py
Browse files
app.py
CHANGED
|
@@ -62,11 +62,11 @@ def process_image(image_path, depth_map_path=None):
|
|
| 62 |
background_depth_value = 20 # Slight depth for background
|
| 63 |
background_depth = np.full_like(depth_image, background_depth_value) # Flat depth for background
|
| 64 |
|
| 65 |
-
#
|
| 66 |
-
|
| 67 |
|
| 68 |
# Combine the flat background with the foreground depth
|
| 69 |
-
combined_depth_image = np.where(
|
| 70 |
|
| 71 |
# Step 3: Generate 3D model using the combined depth map
|
| 72 |
try:
|
|
|
|
| 62 |
background_depth_value = 20 # Slight depth for background
|
| 63 |
background_depth = np.full_like(depth_image, background_depth_value) # Flat depth for background
|
| 64 |
|
| 65 |
+
# Resize the foreground mask to match the size of depth_image
|
| 66 |
+
foreground_mask_resized = np.array(foreground_image.convert("L").resize(image.size, Image.Resampling.NEAREST)) > 0
|
| 67 |
|
| 68 |
# Combine the flat background with the foreground depth
|
| 69 |
+
combined_depth_image = np.where(foreground_mask_resized, depth_image, background_depth)
|
| 70 |
|
| 71 |
# Step 3: Generate 3D model using the combined depth map
|
| 72 |
try:
|