Skip to content

Commit 1315c89

Browse files
nijkahfacebook-github-bot
authored andcommitted
Fix rrpn proposal validation
Summary: https://github.com/facebookresearch/detectron2/blob/08f617cc2c9276a48e7e7dc96ae946a5df23af3f/detectron2/modeling/proposal_generator/proposal_utils.py#L104 ```python if not valid_mask.all(): if training: raise FloatingPointError( "Predicted boxes or scores contain Inf/NaN. Training has diverged." ) boxes = boxes[valid_mask] scores_per_img = scores_per_img[valid_mask] lvl = lvl[valid_mask] ``` Unlike function **find_top_rpn_proposals**, **find_top_rrpn_proposals** does not include valid masking for level indices. When the program goes into if condition, it gives an undesirable error says that "shape does not match". I add a handling code same with **find_top_rpn_proposals**. Pull Request resolved: #3770 Reviewed By: sstsai-adl Differential Revision: D33119548 Pulled By: zhanghang1989 fbshipit-source-id: fee677ad6b610deb713d2769901ab8d3d47539c3
1 parent 9176db6 commit 1315c89

File tree

1 file changed

+8
-2
lines changed
  • detectron2/modeling/proposal_generator

1 file changed

+8
-2
lines changed

detectron2/modeling/proposal_generator/rrpn.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,17 +92,23 @@ def find_top_rrpn_proposals(
9292
for n, image_size in enumerate(image_sizes):
9393
boxes = RotatedBoxes(topk_proposals[n])
9494
scores_per_img = topk_scores[n]
95+
lvl = level_ids
96+
9597
valid_mask = torch.isfinite(boxes.tensor).all(dim=1) & torch.isfinite(scores_per_img)
9698
if not valid_mask.all():
99+
if training:
100+
raise FloatingPointError(
101+
"Predicted boxes or scores contain Inf/NaN. Training has diverged."
102+
)
97103
boxes = boxes[valid_mask]
98104
scores_per_img = scores_per_img[valid_mask]
105+
lvl = lvl[valid_mask]
99106
boxes.clip(image_size)
100107

101108
# filter empty boxes
102109
keep = boxes.nonempty(threshold=min_box_size)
103-
lvl = level_ids
104110
if _is_tracing() or keep.sum().item() != len(boxes):
105-
boxes, scores_per_img, lvl = (boxes[keep], scores_per_img[keep], level_ids[keep])
111+
boxes, scores_per_img, lvl = (boxes[keep], scores_per_img[keep], lvl[keep])
106112

107113
keep = batched_nms_rotated(boxes.tensor, scores_per_img, lvl, nms_thresh)
108114
# In Detectron1, there was different behavior during training vs. testing.

0 commit comments

Comments
 (0)