Skip to content
DeepForgeby svx
All problems
HardComputer Visioncv-322

Anchor Label Assignment

Problem

Assign Faster R-CNN style labels to anchors. An anchor is positive (1) when its best IoU over the ground truths is at least pos_threshold and negative (0) when it is below neg_threshold, otherwise it is ignored (-1).

Every ground-truth box additionally forces its best-matching anchor to be positive, keeping the smallest anchor index on ties. Return the labels.

Test cases

case 1
in: [[[0,0,2,2],[10,10,12,12],[0.5,0.5,2.5,2.5]],[[0,0,2,2]],0.5,0.3]
expected: [1,0,-1]
case 2
in: [[[0,0,2,2],[0,0,1,1]],[[0,0,2,2],[10,10,12,12]],0.5,0.4]
expected: [1,0]
case 3
in: [[[5,5,6,6]],[[0,0,1,1]],0.5,0.3]
expected: [0]
Starter codePython
def assign_anchor_labels(anchors, gt_boxes, pos_threshold, neg_threshold):
    # Your code here
    pass

3 test cases · run your code against them in the editor