Alwin122 commited on
Commit
45b0807
·
verified ·
1 Parent(s): 52de347

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -12
app.py CHANGED
@@ -281,20 +281,12 @@ def extract_segments(image: Image.Image, pred_seg, segment_data: Dict, settings:
281
  background = np.full(cropped_image.shape, 248, dtype=np.uint8)
282
  mask_uint8 = (cropped_mask_smooth * 255).astype(np.uint8)
283
  contours, _ = cv2.findContours(mask_uint8, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
284
-
285
- outline_mask = np.zeros_like(mask_uint8)
286
- cv2.drawContours(outline_mask, contours, -1, 255, thickness=2)
287
- kernel = np.ones((3,3), np.uint8)
288
- outline_mask = cv2.dilate(outline_mask, kernel, iterations=1)
289
 
290
  mask_3d = np.stack([cropped_mask_smooth] * 3, axis=2)
291
- outline_3d = np.stack([outline_mask/255.0] * 3, axis=2)
292
- grey_color = np.full(cropped_image.shape, 128, dtype=np.uint8)
293
-
294
- # Composite image
295
- final_image = (cropped_image * mask_3d +
296
- grey_color * outline_3d * (1 - mask_3d) +
297
- background * (1 - mask_3d) * (1 - outline_3d)).astype(np.uint8)
298
 
299
 
300
 
 
281
  background = np.full(cropped_image.shape, 248, dtype=np.uint8)
282
  mask_uint8 = (cropped_mask_smooth * 255).astype(np.uint8)
283
  contours, _ = cv2.findContours(mask_uint8, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
 
 
 
 
 
284
 
285
  mask_3d = np.stack([cropped_mask_smooth] * 3, axis=2)
286
+ # Composite image - just object + white background (no grey outline)
287
+ final_image = (cropped_image * mask_3d +
288
+ background * (1 - mask_3d)).astype(np.uint8)
289
+
 
 
 
290
 
291
 
292