CodeJackR commited on
Commit
f8836df
·
1 Parent(s): d29fd9e

Manage image resizing

Browse files
Files changed (1) hide show
  1. handler.py +8 -1
handler.py CHANGED
@@ -64,9 +64,16 @@ class EndpointHandler():
64
 
65
  # 4. Process and select the best mask
66
  try:
 
 
 
 
 
 
 
67
  # Use the processor's post-processing utility to resize masks and remove padding
68
  masks = self.processor.post_process_masks(
69
- outputs.pred_masks.cpu(),
70
  inputs["original_sizes"].cpu(),
71
  inputs["reshaped_input_sizes"].cpu()
72
  )[0]
 
64
 
65
  # 4. Process and select the best mask
66
  try:
67
+ pred_masks_raw = outputs.pred_masks.cpu()
68
+
69
+ # The model may output 5-dim tensors, but the post-processor expects 4-dim.
70
+ # We squeeze the extra dimension to fix this.
71
+ if pred_masks_raw.ndim == 5:
72
+ pred_masks_raw = pred_masks_raw.squeeze(1)
73
+
74
  # Use the processor's post-processing utility to resize masks and remove padding
75
  masks = self.processor.post_process_masks(
76
+ pred_masks_raw,
77
  inputs["original_sizes"].cpu(),
78
  inputs["reshaped_input_sizes"].cpu()
79
  )[0]