NMS unused variable fix (#7161)
Browse files* NMS unused variable fix
* Update general.py
- utils/general.py +6 -7
utils/general.py
CHANGED
@@ -703,7 +703,7 @@ def clip_coords(boxes, shape):
|
|
703 |
|
704 |
def non_max_suppression(prediction, conf_thres=0.25, iou_thres=0.45, classes=None, agnostic=False, multi_label=False,
|
705 |
labels=(), max_det=300):
|
706 |
-
"""
|
707 |
|
708 |
Returns:
|
709 |
list of detections, on (n,6) tensor per image [xyxy, conf, cls]
|
@@ -718,18 +718,19 @@ def non_max_suppression(prediction, conf_thres=0.25, iou_thres=0.45, classes=Non
|
|
718 |
assert 0 <= iou_thres <= 1, f'Invalid IoU {iou_thres}, valid values are between 0.0 and 1.0'
|
719 |
|
720 |
# Settings
|
721 |
-
min_wh
|
|
|
722 |
max_nms = 30000 # maximum number of boxes into torchvision.ops.nms()
|
723 |
time_limit = 0.030 * bs # seconds to quit after
|
724 |
redundant = True # require redundant detections
|
725 |
multi_label &= nc > 1 # multiple labels per box (adds 0.5ms/img)
|
726 |
merge = False # use merge-NMS
|
727 |
|
728 |
-
t
|
729 |
output = [torch.zeros((0, 6), device=prediction.device)] * bs
|
730 |
for xi, x in enumerate(prediction): # image index, image inference
|
731 |
# Apply constraints
|
732 |
-
x[((x[..., 2:4] < min_wh) | (x[..., 2:4] > max_wh)).any(1), 4] = 0 # width-height
|
733 |
x = x[xc[xi]] # confidence
|
734 |
|
735 |
# Cat apriori labels if autolabelling
|
@@ -790,9 +791,7 @@ def non_max_suppression(prediction, conf_thres=0.25, iou_thres=0.45, classes=Non
|
|
790 |
|
791 |
output[xi] = x[i]
|
792 |
if (time.time() - t) > time_limit:
|
793 |
-
|
794 |
-
LOGGER.warning(f'WARNING: NMS time limit {time_limit:3f}s exceeded')
|
795 |
-
warn_time = False
|
796 |
break # time limit exceeded
|
797 |
|
798 |
return output
|
|
|
703 |
|
704 |
def non_max_suppression(prediction, conf_thres=0.25, iou_thres=0.45, classes=None, agnostic=False, multi_label=False,
|
705 |
labels=(), max_det=300):
|
706 |
+
"""Non-Maximum Suppression (NMS) on inference results to reject overlapping bounding boxes
|
707 |
|
708 |
Returns:
|
709 |
list of detections, on (n,6) tensor per image [xyxy, conf, cls]
|
|
|
718 |
assert 0 <= iou_thres <= 1, f'Invalid IoU {iou_thres}, valid values are between 0.0 and 1.0'
|
719 |
|
720 |
# Settings
|
721 |
+
# min_wh = 2 # (pixels) minimum box width and height
|
722 |
+
max_wh = 7680 # (pixels) maximum box width and height
|
723 |
max_nms = 30000 # maximum number of boxes into torchvision.ops.nms()
|
724 |
time_limit = 0.030 * bs # seconds to quit after
|
725 |
redundant = True # require redundant detections
|
726 |
multi_label &= nc > 1 # multiple labels per box (adds 0.5ms/img)
|
727 |
merge = False # use merge-NMS
|
728 |
|
729 |
+
t = time.time()
|
730 |
output = [torch.zeros((0, 6), device=prediction.device)] * bs
|
731 |
for xi, x in enumerate(prediction): # image index, image inference
|
732 |
# Apply constraints
|
733 |
+
# x[((x[..., 2:4] < min_wh) | (x[..., 2:4] > max_wh)).any(1), 4] = 0 # width-height
|
734 |
x = x[xc[xi]] # confidence
|
735 |
|
736 |
# Cat apriori labels if autolabelling
|
|
|
791 |
|
792 |
output[xi] = x[i]
|
793 |
if (time.time() - t) > time_limit:
|
794 |
+
LOGGER.warning(f'WARNING: NMS time limit {time_limit:.3f}s exceeded')
|
|
|
|
|
795 |
break # time limit exceeded
|
796 |
|
797 |
return output
|