codic commited on
Commit
67f16d7
·
verified ·
1 Parent(s): 15881fc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -0
app.py CHANGED
@@ -25,6 +25,10 @@ def process_image(image_path, depth_map_path=None):
25
  image_np = np.array(image)
26
  subject = remove(image_np) # Removes background
27
 
 
 
 
 
28
  # Step 2: Inpaint the background
29
  mask = cv2.inRange(subject, (0, 0, 0), (0, 0, 0)) # Binary mask
30
  background_inpainted = cv2.inpaint(image_np, mask, inpaintRadius=3, flags=cv2.INPAINT_TELEA)
 
25
  image_np = np.array(image)
26
  subject = remove(image_np) # Removes background
27
 
28
+ # Ensure subject is in RGB format if not already
29
+ if len(subject.shape) == 2 or subject.shape[2] != 3:
30
+ subject = cv2.cvtColor(subject, cv2.COLOR_GRAY2RGB) # Convert to 3-channel image
31
+
32
  # Step 2: Inpaint the background
33
  mask = cv2.inRange(subject, (0, 0, 0), (0, 0, 0)) # Binary mask
34
  background_inpainted = cv2.inpaint(image_np, mask, inpaintRadius=3, flags=cv2.INPAINT_TELEA)