@@ -748,11 +748,6 @@ def non_max_suppression(
748748 shape (num_boxes, 6 + num_masks) containing the kept boxes, with columns
749749 (x1, y1, x2, y2, confidence, class, mask1, mask2, ...).
750750 """
751- out_shape = prediction .shape
752- if 3 != len (out_shape ):
753- raise RuntimeError ("YoloV8 wrapper expects the output of rank 3" )
754- if 1 != out_shape [0 ]:
755- raise RuntimeError ("YoloV8 wrapper expects 1 as the first dim of the output" )
756751 nc = nc or (prediction .shape [1 ] - 4 ) # number of classes
757752 mi = 4 + nc # mask start index
758753 xc = np .amax (prediction [:, 4 :mi ], 1 ) > conf_thres # candidates
@@ -837,15 +832,19 @@ def parameters(cls):
837832
838833 def postprocess (self , outputs , meta ):
839834 if 1 != len (outputs ):
840- raise RuntimeError ("YoloV8 wrapper expects 1 output" )
835+ self .raise_error ("expect 1 output" )
836+ prediction = next (iter (outputs .values ()))
837+ out_shape = prediction .shape
838+ if 3 != len (out_shape ):
839+ raise RuntimeError ("expect the output of rank 3" )
840+ if 1 != out_shape [0 ]:
841+ raise RuntimeError ("expect 1 as the first dim of the output" )
841842 boxes = non_max_suppression (
842- next ( iter ( outputs . values ())) , self .confidence_threshold , self .iou_threshold
843+ prediction , self .confidence_threshold , self .iou_threshold
843844 )
844845
845- inputImgWidth , inputImgHeight = (
846- meta ["original_shape" ][1 ],
847- meta ["original_shape" ][0 ],
848- )
846+ inputImgWidth = meta ["original_shape" ][1 ]
847+ inputImgHeight = meta ["original_shape" ][0 ]
849848 invertedScaleX , invertedScaleY = (
850849 inputImgWidth / self .orig_width ,
851850 inputImgHeight / self .orig_height ,
@@ -865,7 +864,7 @@ def postprocess(self, outputs, meta):
865864 boxes [:, :4 ] -= (padLeft , padTop , padLeft , padTop )
866865 boxes [:, :4 ] *= (invertedScaleX , invertedScaleY , invertedScaleX , invertedScaleY )
867866
868- intboxes = np .rint (boxes [:, :4 ]).astype (np .int32 )
867+ intboxes = np .rint (boxes [:, :4 ]).astype (np .int32 ) # TODO: np.round(float_act_map, out=float_act_map).astype()
869868 np .clip (
870869 intboxes ,
871870 0 ,
0 commit comments