JingShiang Yang commited on
Commit
2e11ff8
·
1 Parent(s): d5f470e

Fix mask output: use decoder output[1] and resize to 1024x1024

Browse files
Files changed (1) hide show
  1. handler.py +7 -5
handler.py CHANGED
@@ -54,12 +54,14 @@ class EndpointHandler:
54
  'point_labels': labels.reshape(1, -1)
55
  })
56
 
57
- masks = decoder_outputs[0]
 
 
58
 
59
- # Postprocess - squeeze to get 2D mask
60
- mask = masks.squeeze() # Remove all dimensions of size 1
61
- if len(mask.shape) > 2:
62
- mask = mask[0] # Take first mask if multiple
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