@@ -15,18 +15,25 @@ def __init__(self,
15
15
model_input_size : tuple = (640 , 640 ),
16
16
mean : tuple = None ,
17
17
std : tuple = None ,
18
+ nms_thr : float = 0.45 ,
19
+ score_thr : float = 0.7 ,
18
20
to_openpose : bool = False ,
19
21
backend : str = 'onnxruntime' ,
20
22
device : str = 'cpu' ):
21
23
super ().__init__ (onnx_model , model_input_size , mean , std , backend ,
22
24
device )
23
25
self .to_openpose = to_openpose
26
+ self .nms_thr = nms_thr
27
+ self .score_thr = score_thr
28
+
29
+ def __call__ (self , image : np .ndarray , nms_thr : float = None , score_thr : float = None ):
30
+ nms_thr = nms_thr if nms_thr is not None else self .nms_thr
31
+ score_thr = score_thr if score_thr is not None else self .score_thr
24
32
25
- def __call__ (self , image : np .ndarray ):
26
33
image , ratio = self .preprocess (image )
27
34
outputs = self .inference (image )
28
35
29
- keypoints , scores = self .postprocess (outputs , ratio )
36
+ keypoints , scores = self .postprocess (outputs , ratio , nms_thr , score_thr )
30
37
31
38
if self .to_openpose :
32
39
keypoints , scores = convert_coco_to_openpose (keypoints , scores )
@@ -74,6 +81,8 @@ def postprocess(
74
81
self ,
75
82
outputs : List [np .ndarray ],
76
83
ratio : float = 1. ,
84
+ nms_thr : float = None ,
85
+ score_thr : float = None ,
77
86
) -> Tuple [np .ndarray , np .ndarray ]:
78
87
"""Do postprocessing for RTMO model inference.
79
88
@@ -97,8 +106,8 @@ def postprocess(
97
106
# apply nms
98
107
dets , keep = multiclass_nms (final_boxes ,
99
108
final_scores [:, np .newaxis ],
100
- nms_thr = 0.45 ,
101
- score_thr = 0.7 )
109
+ nms_thr = nms_thr ,
110
+ score_thr = score_thr )
102
111
if keep is not None :
103
112
keypoints = keypoints [keep ]
104
113
scores = scores [keep ]
0 commit comments