From c392b8de7817ccb0a7111185f5be64af4b8e13a9 Mon Sep 17 00:00:00 2001 From: positive666 <286040359@qq.com> Date: Fri, 10 Sep 2021 17:37:22 +0800 Subject: [PATCH] Allow multi_label option for NMS with PyTorch Hub (#4728) --- models/common.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/models/common.py b/models/common.py index f9a0b23d..9ddd0e1f 100644 --- a/models/common.py +++ b/models/common.py @@ -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() @@ -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])