Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
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 |
|