@@ -60,6 +60,11 @@ class yolox_darknet53(BaseWrapper):
6060 def __init__ (self , device : str , ** kwargs ):
6161 super ().__init__ (device )
6262
63+ from yolox .exp import get_exp
64+ from yolox .utils import postprocess
65+
66+ self .postprocess = postprocess
67+
6368 _path_prefix = (
6469 f"{ root_path } "
6570 if kwargs ["model_path_prefix" ] == "default"
@@ -74,8 +79,6 @@ def __init__(self, device: str, **kwargs):
7479 self .conf_thres = kwargs ["conf_thres" ]
7580 self .nms_thres = kwargs ["nms_thres" ]
7681
77- from yolox .exp import get_exp
78-
7982 self .squeeze_at_split_enabled = False
8083
8184 exp = get_exp (exp_file = None , exp_name = "yolov3" )
@@ -230,6 +233,8 @@ def _feature_at_l13_to_output(
230233 <https://github.com/Megvii-BaseDetection/YOLOX?tab=Apache-2.0-1-ov-file#readme>
231234
232235 """
236+ from yolox .utils import postprocess
237+
233238 y = x [self .SPLIT_L13 ]
234239
235240 # Recovery session to expand dimension to original
@@ -258,7 +263,9 @@ def _feature_at_l13_to_output(
258263
259264 outputs = self .head ((fp_lvl2 , fp_lvl1 , fp_lvl0 ))
260265
261- pred = postprocess (outputs , self .num_classes , self .conf_thres , self .nms_thres )
266+ pred = self .postprocess (
267+ outputs , self .num_classes , self .conf_thres , self .nms_thres
268+ )
262269
263270 return pred
264271
@@ -278,6 +285,7 @@ def _feature_at_l37_to_output(
278285 <https://github.com/Megvii-BaseDetection/YOLOX?tab=Apache-2.0-1-ov-file#readme>
279286
280287 """
288+ from yolox .utils import postprocess
281289
282290 fp_lvl2 = x [self .SPLIT_L37 ]
283291 fp_lvl1 = self .backbone .dark4 (fp_lvl2 )
@@ -297,7 +305,9 @@ def _feature_at_l37_to_output(
297305
298306 outputs = self .head ((fp_lvl2 , fp_lvl1 , fp_lvl0 ))
299307
300- pred = postprocess (outputs , self .num_classes , self .conf_thres , self .nms_thres )
308+ pred = self .postprocess (
309+ outputs , self .num_classes , self .conf_thres , self .nms_thres
310+ )
301311
302312 return pred
303313
@@ -308,11 +318,11 @@ def forward(self, x):
308318 self .model = self .model .to (self .device ).eval ()
309319 img = x ["image" ].unsqueeze (0 ).to (self .device )
310320
311- from yolox .utils import postprocess
312-
313321 fpn_out = self .yolo_fpn (img )
314322 outputs = self .head (fpn_out )
315323
316- pred = postprocess (outputs , self .num_classes , self .conf_thres , self .nms_thres )
324+ pred = self .postprocess (
325+ outputs , self .num_classes , self .conf_thres , self .nms_thres
326+ )
317327
318328 return pred
0 commit comments