JingShiang Yang
commited on
Commit
·
2e11ff8
1
Parent(s):
d5f470e
Fix mask output: use decoder output[1] and resize to 1024x1024
Browse files- handler.py +7 -5
handler.py
CHANGED
|
@@ -54,12 +54,14 @@ class EndpointHandler:
|
|
| 54 |
'point_labels': labels.reshape(1, -1)
|
| 55 |
})
|
| 56 |
|
| 57 |
-
|
|
|
|
|
|
|
| 58 |
|
| 59 |
-
#
|
| 60 |
-
mask = masks
|
| 61 |
-
|
| 62 |
-
|
| 63 |
mask = (mask > 0.0).astype(np.uint8) * 255
|
| 64 |
|
| 65 |
# Return result
|
|
|
|
| 54 |
'point_labels': labels.reshape(1, -1)
|
| 55 |
})
|
| 56 |
|
| 57 |
+
# decoder_outputs[0] is IoU scores (1, 4)
|
| 58 |
+
# decoder_outputs[1] is masks (1, 4, 256, 256)
|
| 59 |
+
masks = decoder_outputs[1]
|
| 60 |
|
| 61 |
+
# Take first mask and resize to 1024x1024
|
| 62 |
+
mask = masks[0, 0] # Shape: (256, 256)
|
| 63 |
+
mask = Image.fromarray(mask).resize((1024, 1024), Image.BILINEAR)
|
| 64 |
+
mask = np.array(mask)
|
| 65 |
mask = (mask > 0.0).astype(np.uint8) * 255
|
| 66 |
|
| 67 |
# Return result
|