From 2c35c1b318ecd4856275039220c052a976d2cfe2 Mon Sep 17 00:00:00 2001 From: Yonghye Kwon Date: Sun, 18 Dec 2022 21:03:01 +0900 Subject: [PATCH] Limit detections without explicit if condition (#10502) * limit detections without explicit if condition Signed-off-by: Yonghye Kwon * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * cleanup indexing code for limit detections Signed-off-by: Yonghye Kwon Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Glenn Jocher --- utils/general.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/utils/general.py b/utils/general.py index 744abb4..70b6f64 100644 --- a/utils/general.py +++ b/utils/general.py @@ -978,8 +978,7 @@ def non_max_suppression( c = x[:, 5:6] * (0 if agnostic else max_wh) # classes boxes, scores = x[:, :4] + c, x[:, 4] # boxes (offset by class), scores i = torchvision.ops.nms(boxes, scores, iou_thres) # NMS - if i.shape[0] > max_det: # limit detections - i = i[:max_det] + i = i[:max_det] # limit detections if merge and (1 < n < 3E3): # Merge NMS (boxes merged using weighted mean) # update boxes as boxes(i,4) = weights(i,n) * boxes(n,4) iou = box_iou(boxes[i], boxes) > iou_thres # iou matrix