Sort by confidence and remove excess boxes without explicit if (#10517)
* sort by confidence and remove excess boxes without explicit if Signed-off-by: Yonghye Kwon <developer.0hye@gmail.com> * cleanup indexing boxes for remove excess boxes it is related to https://github.com/ultralytics/yolov5/pull/10502. Signed-off-by: Yonghye Kwon <developer.0hye@gmail.com> Co-authored-by: Glenn Jocher <glenn.jocher@ultralytics.com>
This commit is contained in:
1 parent
10e93d295f
commit
5545ff3545
1 file changed
+1
-4
+1
-4
@@ -969,10 +969,7 @@ def non_max_suppression(
|
||||
n = x.shape[0] # number of boxes
|
||||
if not n: # no boxes
|
||||
continue
|
||||
elif n > max_nms: # excess boxes
|
||||
x = x[x[:, 4].argsort(descending=True)[:max_nms]] # sort by confidence
|
||||
else:
|
||||
x = x[x[:, 4].argsort(descending=True)] # sort by confidence
|
||||
x = x[x[:, 4].argsort(descending=True)[:max_nms]] # sort by confidence and remove excess boxes
|
||||
|
||||
# Batched NMS
|
||||
c = x[:, 5:6] * (0 if agnostic else max_wh) # classes
|
||||
|
||||
Reference in new issue
Block a user