Spaces:
Sleeping
Sleeping
IZERE HIRWA Roger
commited on
Commit
·
7dc5d22
1
Parent(s):
f5cfe82
- app.py +3 -2
- result.png +3 -1
app.py
CHANGED
@@ -97,10 +97,11 @@ def segment_endpoint():
|
|
97 |
overlay = request.args.get("overlay", "false").lower() == "true"
|
98 |
if overlay:
|
99 |
colored = np.array(image_pil).copy()
|
100 |
-
|
|
|
101 |
out_img = Image.fromarray(colored)
|
102 |
else:
|
103 |
-
out_img = Image.fromarray((mask * 255)
|
104 |
|
105 |
buf = io.BytesIO()
|
106 |
out_img.save(buf, format="PNG")
|
|
|
97 |
overlay = request.args.get("overlay", "false").lower() == "true"
|
98 |
if overlay:
|
99 |
colored = np.array(image_pil).copy()
|
100 |
+
mask_np = mask.cpu().numpy() if hasattr(mask, "cpu") else np.array(mask)
|
101 |
+
colored[mask_np] = [255, 0, 0] # red overlay
|
102 |
out_img = Image.fromarray(colored)
|
103 |
else:
|
104 |
+
out_img = Image.fromarray((mask.astype(np.uint8) * 255) if hasattr(mask, "astype") else (np.array(mask, dtype=np.uint8) * 255))
|
105 |
|
106 |
buf = io.BytesIO()
|
107 |
out_img.save(buf, format="PNG")
|
result.png
CHANGED
![]() |
![]() |