Update app.py
Browse files
app.py
CHANGED
|
@@ -52,6 +52,11 @@ def process_image(image_path, depth_map_path=None):
|
|
| 52 |
# Smooth the edges to blend the subject with the background
|
| 53 |
mask = remove(image_raw) # Generate mask
|
| 54 |
mask_blurred = np.array(mask.filter(ImageFilter.GaussianBlur(5))) # Edge blur
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 55 |
blended_depth_image = cv2.addWeighted(depth_image, 0.8, mask_blurred, 0.2, 0)
|
| 56 |
|
| 57 |
try:
|
|
|
|
| 52 |
# Smooth the edges to blend the subject with the background
|
| 53 |
mask = remove(image_raw) # Generate mask
|
| 54 |
mask_blurred = np.array(mask.filter(ImageFilter.GaussianBlur(5))) # Edge blur
|
| 55 |
+
# Ensure mask_blurred matches depth_image dimensions
|
| 56 |
+
mask_blurred_resized = cv2.resize(mask_blurred, (depth_image.shape[1], depth_image.shape[0]), interpolation=cv2.INTER_LINEAR)
|
| 57 |
+
|
| 58 |
+
# Blend the resized mask with the depth image
|
| 59 |
+
blended_depth_image = cv2.addWeighted(depth_image, 0.8, mask_blurred_resized, 0.2, 0)
|
| 60 |
blended_depth_image = cv2.addWeighted(depth_image, 0.8, mask_blurred, 0.2, 0)
|
| 61 |
|
| 62 |
try:
|