Skip to content

Commit 1ad9fea

Browse files
karanchahalwaleedka
authored andcommitted
Multiple Anchors have same IOU
Fixed the Todo for matching multiple anchors with the same IOU, and setting their value to 1. The previous version only picked the first anchor that had a maximum IOU. Now, if multiple anchors had the same IOU < 0.7, all of them will be set to a foreground class.
1 parent 2b84add commit 1ad9fea

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

mrcnn/model.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1495,8 +1495,8 @@ def build_rpn_targets(image_shape, anchors, gt_class_ids, gt_boxes, config):
14951495
anchor_iou_max = overlaps[np.arange(overlaps.shape[0]), anchor_iou_argmax]
14961496
rpn_match[(anchor_iou_max < 0.3) & (no_crowd_bool)] = -1
14971497
# 2. Set an anchor for each GT box (regardless of IoU value).
1498-
# TODO: If multiple anchors have the same IoU match all of them
1499-
gt_iou_argmax = np.argmax(overlaps, axis=0)
1498+
# If multiple anchors have the same IoU match all of them
1499+
gt_iou_argmax = np.argwhere(overlaps == np.max(overlaps, axis=0))[:,0]
15001500
rpn_match[gt_iou_argmax] = 1
15011501
# 3. Set anchors with high overlap as positive.
15021502
rpn_match[anchor_iou_max >= 0.7] = 1

0 commit comments

Comments
 (0)