Skip to content

Commit

Permalink
Allow multi_label option for NMS with PyTorch Hub (#4728)
Browse files Browse the repository at this point in the history
  • Loading branch information
positive666 committed Sep 10, 2021
1 parent 6c09812 commit c392b8d
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions models/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -408,8 +408,9 @@ class AutoShape(nn.Module):
conf = 0.25 # NMS confidence threshold
iou = 0.45 # NMS IoU threshold
classes = None # (optional list) filter by class
multi_label = False # NMS multiple labels per box
max_det = 1000 # maximum number of detections per image

def __init__(self, model):
super(AutoShape, self).__init__()
self.model = model.eval()
Expand Down Expand Up @@ -466,7 +467,8 @@ def forward(self, imgs, size=640, augment=False, profile=False):
t.append(time_sync())

# Post-process
y = non_max_suppression(y, self.conf, iou_thres=self.iou, classes=self.classes, max_det=self.max_det) # NMS
y = non_max_suppression(y, self.conf, iou_thres=self.iou, classes=self.classes,
multi_label=self.multi_label, max_det=self.max_det) # NMS
for i in range(n):
scale_coords(shape1, y[i][:, :4], shape0[i])

Expand Down

0 comments on commit c392b8d

Please sign in to comment.