Skip to content

Commit 25f7961

Browse files
author
Hans Gaiser
committed
Fix inconsistency with matched_idxs.
1 parent 3dd9e4b commit 25f7961

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

torchvision/models/detection/retinanet.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -182,8 +182,7 @@ def compute_loss(self, targets, head_outputs, anchors, matched_idxs):
182182
for targets_per_image, bbox_regression_per_image, anchors_per_image, matched_idxs_per_image in \
183183
zip(targets, bbox_regression, anchors, matched_idxs):
184184
# no matched_idxs means there were no annotations in this image
185-
if matched_idxs_per_image is None:
186-
loss.append(0)
185+
if matched_idxs_per_image.numel() == 0:
187186
continue
188187

189188
# get the targets corresponding GT for each proposal
@@ -386,7 +385,7 @@ def compute_loss(self, targets, head_outputs, anchors):
386385
matched_idxs = []
387386
for anchors_per_image, targets_per_image in zip(anchors, targets):
388387
if targets_per_image['boxes'].numel() == 0:
389-
matched_idxs.append(torch.empty((0,)))
388+
matched_idxs.append(torch.empty((0,), dtype=torch.int32))
390389
continue
391390

392391
match_quality_matrix = box_ops.box_iou(targets_per_image['boxes'], anchors_per_image)

0 commit comments

Comments
 (0)