Skip to content

Commit 5a7010f

Browse files
authored
Remove empty boxes before NMS (#1019)
1 parent 5ba9587 commit 5a7010f

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

torchvision/models/detection/roi_heads.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -501,6 +501,10 @@ def postprocess_detections(self, class_logits, box_regression, proposals, image_
501501
inds = torch.nonzero(scores > self.score_thresh).squeeze(1)
502502
boxes, scores, labels = boxes[inds], scores[inds], labels[inds]
503503

504+
# remove empty boxes
505+
keep = box_ops.remove_small_boxes(boxes, min_size=1e-2)
506+
boxes, scores, labels = boxes[keep], scores[keep], labels[keep]
507+
504508
# non-maximum suppression, independently done per class
505509
keep = box_ops.batched_nms(boxes, scores, labels, self.nms_thresh)
506510
# keep only topk scoring predictions

0 commit comments

Comments
 (0)