codic commited on
Commit
c506795
·
verified ·
1 Parent(s): 103ad20

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -2
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
- # Create the mask and convert to uint8 format for OpenCV compatibility
66
- mask = np.array(image.convert("L").point(lambda x: 255 if x == 0 else 0, mode="1")).astype(np.uint8)
 
 
 
 
 
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