codic commited on
Commit
c5a8131
·
verified ·
1 Parent(s): 832ddab

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -3
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
- # Foreground mask from background removal (assumed to be binary mask)
66
- foreground_mask = np.array(foreground_image.convert("L")) > 0
67
 
68
  # Combine the flat background with the foreground depth
69
- combined_depth_image = np.where(foreground_mask, depth_image, background_depth)
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: