All problems
Anchor IoU Matching
Problem
Match every anchor box to the ground-truth box with the highest IoU.
Boxes use [x1, y1, x2, y2] continuous coordinates. Return the ground-truth index when the best IoU is at least threshold, otherwise -1; ties keep the smallest ground-truth index.
Hint
Compute the IoU against every ground-truth box and keep the best match.
Test cases
case 1
in: [[[0,0,2,2],[10,10,12,12]],[[0,0,2,2],[9,9,13,13]],0.5]
expected: [0,-1]
case 2
in: [[[0,0,2,2],[10,10,12,12]],[[0,0,2,2],[9,9,13,13]],0.2]
expected: [0,1]
case 3
in: [[[0,0,2,2]],[],0.5]
expected: [-1]
case 4
in: [[],[[0,0,2,2]],0.5]
expected: []
Starter codePython
def match_anchors(anchors, gt_boxes, threshold):
# Your code here
pass4 test cases · run your code against them in the editor