mjohanes commited on
Commit
3f2393a
·
1 Parent(s): 8aaad57
Files changed (1) hide show
  1. app.py +3 -1
app.py CHANGED
@@ -121,9 +121,11 @@ else:
121
  masks_tensor = results[0].masks.data
122
  masks = masks_tensor.cpu().numpy()
123
  if masks.ndim == 3 and masks.shape[0] > 0:
124
- # Combine masks (logical OR via max)
125
  combined_mask = np.max(masks, axis=0)
126
  combined_mask_img = Image.fromarray((combined_mask * 255).astype(np.uint8))
 
 
127
  # Create a red overlay with transparency
128
  overlay = Image.new("RGBA", img.size, (255, 0, 0, 100))
129
  base = img.convert("RGBA")
 
121
  masks_tensor = results[0].masks.data
122
  masks = masks_tensor.cpu().numpy()
123
  if masks.ndim == 3 and masks.shape[0] > 0:
124
+ # Combine masks (logical OR via max)
125
  combined_mask = np.max(masks, axis=0)
126
  combined_mask_img = Image.fromarray((combined_mask * 255).astype(np.uint8))
127
+ # Resize the mask to ensure it matches the base image size
128
+ combined_mask_img = combined_mask_img.resize(img.size, Image.NEAREST)
129
  # Create a red overlay with transparency
130
  overlay = Image.new("RGBA", img.size, (255, 0, 0, 100))
131
  base = img.convert("RGBA")