From b7363819339d5be5accf962766a05755b04b3fec Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Martin Date: Thu, 9 Sep 2021 13:56:47 +0200 Subject: [PATCH 1/2] Allow specifying multi_label option for NMS when using torch hub --- models/common.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/models/common.py b/models/common.py index e79b8a9d2644..2014d422b07c 100644 --- a/models/common.py +++ b/models/common.py @@ -278,6 +278,7 @@ 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): @@ -337,7 +338,7 @@ 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]) From e6d33cb8e05eb2b48f2a93a637978a6a94ae608c Mon Sep 17 00:00:00 2001 From: Glenn Jocher Date: Thu, 9 Sep 2021 15:21:29 +0200 Subject: [PATCH 2/2] Reformat --- models/common.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/models/common.py b/models/common.py index 2014d422b07c..5305b03d5389 100644 --- a/models/common.py +++ b/models/common.py @@ -278,7 +278,7 @@ 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 + multi_label = False # NMS multiple labels per box max_det = 1000 # maximum number of detections per image def __init__(self, model): @@ -338,7 +338,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, multi_label=self.multi_label, 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])