Skip to content

Commit a32ebd9

Browse files
committed
RoIHeads: don't remove empty boxes in postprocess
pytorch#1019 introduced a change that removes empty boxes in postprocessing on the basis that, previously, empty boxes would actually reach this postprocessing step, and that the model could therefore output empty boxes (even though NMS would've most likely filtered them out). It's essentially a safety check that'd be seldom needed. However, that filtering causes dynamicity on the TPU (because the number of empty boxes, if any, would be unknown). And in any case, we recently introduced a change in PR pytorch#4 that purposefully pads the boxes tensor with empty boxes, to avoid dynamicity. Therefore there's no point trying to remove boxes that we use as padding, we'll just filter those out of the output on the CPU.
1 parent 8db28bb commit a32ebd9

File tree

1 file changed

+0
-4
lines changed

1 file changed

+0
-4
lines changed

torchvision/models/detection/roi_heads.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -603,10 +603,6 @@ def postprocess_detections(self, class_logits, box_regression, proposals, image_
603603
scores = torch.where(score_mask, scores, torch.tensor(0.0, device=device))
604604
labels = torch.where(score_mask, labels, torch.tensor(-1, device=device))
605605

606-
# remove empty boxes
607-
keep = box_ops.remove_small_boxes(boxes, min_size=1e-2)
608-
boxes, scores, labels = boxes[keep], scores[keep], labels[keep]
609-
610606
# non-maximum suppression, independently done per class
611607
keep = box_ops.batched_nms(boxes, scores, labels, self.nms_thresh, self.detections_per_img)
612608

0 commit comments

Comments
 (0)