Skip to content

Commit

Permalink
Use torchvision.ops.nms (ultralytics#1460)
Browse files Browse the repository at this point in the history
  • Loading branch information
glenn-jocher authored Nov 20, 2020
1 parent 199c9c7 commit 394131c
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion utils/general.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import matplotlib
import numpy as np
import torch
import torchvision
import yaml

from utils.google_utils import gsutil_getsize
Expand Down Expand Up @@ -323,7 +324,7 @@ def non_max_suppression(prediction, conf_thres=0.1, iou_thres=0.6, merge=False,
# Batched NMS
c = x[:, 5:6] * (0 if agnostic else max_wh) # classes
boxes, scores = x[:, :4] + c, x[:, 4] # boxes (offset by class), scores
i = torch.ops.torchvision.nms(boxes, scores, iou_thres)
i = torchvision.ops.nms(boxes, scores, iou_thres) # NMS
if i.shape[0] > max_det: # limit detections
i = i[:max_det]
if merge and (1 < n < 3E3): # Merge NMS (boxes merged using weighted mean)
Expand Down

0 comments on commit 394131c

Please sign in to comment.