Update app.py
Browse files
app.py
CHANGED
|
@@ -62,8 +62,13 @@ def process_image(image_path, depth_map_path=None):
|
|
| 62 |
raise Exception("Error reconstructing 3D model")
|
| 63 |
|
| 64 |
def inpaint_background(image, original_image):
|
| 65 |
-
#
|
| 66 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 67 |
inpainted_image = cv2.inpaint(original_image, mask, inpaintRadius=3, flags=cv2.INPAINT_TELEA)
|
| 68 |
return inpainted_image
|
| 69 |
|
|
|
|
| 62 |
raise Exception("Error reconstructing 3D model")
|
| 63 |
|
| 64 |
def inpaint_background(image, original_image):
|
| 65 |
+
# Resize `image` to match `original_image` dimensions
|
| 66 |
+
resized_image = image.resize(original_image.shape[1::-1]) # Resize to (width, height)
|
| 67 |
+
|
| 68 |
+
# Convert to grayscale and create the mask in `uint8` format
|
| 69 |
+
mask = np.array(resized_image.convert("L").point(lambda x: 255 if x == 0 else 0, mode="1")).astype(np.uint8)
|
| 70 |
+
|
| 71 |
+
# Apply inpainting
|
| 72 |
inpainted_image = cv2.inpaint(original_image, mask, inpaintRadius=3, flags=cv2.INPAINT_TELEA)
|
| 73 |
return inpainted_image
|
| 74 |
|