Training an anchor-based detector requires deciding, for every anchor, what it is supposed to detect. The standard rule uses IoU with the ground-truth boxes. An anchor whose best IoU is at least pos_thresh is a positive and is assigned the ground-truth box it overlaps most. An anchor whose best IoU is below neg_thresh is a negative (background). Anchors in between are ignored because they are ambiguous and would only add noise to the loss. One extra rule rescues small objects: every ground-truth box also claims its single best-matching anchor as a positive, even if the IoU is below the threshold, so no object is left without a training signal.
Implement match_anchors.
anchors has shape (A, 4) and gt_boxes has shape (G, 4), both (x1, y1, x2, y2). Compute the (A, G) IoU matrix yourself.matches of length A: the index of the matched ground-truth box for positives, -1 for negatives and -2 for ignored anchors.>= pos_thresh marks it positive, < neg_thresh negative, otherwise ignore. (2) For each ground-truth box, take the anchor with the highest IoU for it (lowest index on ties); if that IoU is greater than 0 force the anchor to be positive with that ground truth (this overrides rule 1, and later ground truths override earlier ones).G == 0, every anchor is negative.Positives' targets are then encoded with the box encoding from the previous question.
Rule 2 is applied after rule 1 so it can promote an ignored or negative anchor.
No results yet
Run your code to check it against the examples, or submit to run every test.