Skip to content

Commit

Permalink
Sort by confidence and remove excess boxes without explicit if (ultra…
Browse files Browse the repository at this point in the history
…lytics#10517)

* sort by confidence and remove excess boxes without explicit if

Signed-off-by: Yonghye Kwon <[email protected]>

* cleanup indexing boxes for remove excess boxes

it is related to ultralytics#10502.

Signed-off-by: Yonghye Kwon <[email protected]>
Co-authored-by: Glenn Jocher <[email protected]>
  • Loading branch information
developer0hye and glenn-jocher authored Dec 19, 2022
1 parent 10e93d2 commit 5545ff3
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions utils/general.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 5545ff3

Please sign in to comment.