A detector fires many overlapping boxes around the same object, each with a confidence score. Reporting all of them would count one cat five times. Non-maximum suppression (NMS) keeps the best and discards its near-duplicates: sort the boxes by score; take the highest-scoring box and keep it; remove every remaining box whose IoU with it exceeds a threshold; repeat with what is left. A box far from the kept one survives and may be kept later, so two different cats are both detected. The threshold is a trade-off: too low suppresses neighbouring objects, too high leaves duplicates.
Implement nms.
boxes has shape (N, 4) as (x1, y1, x2, y2), scores has shape (N,) and iou_thresh is a float.iou_thresh with it.Keep a boolean suppressed array and iterate over np.argsort(-scores, kind='stable').
When a box is kept, mark every other box with IoU above the threshold as suppressed.
No results yet
Run your code to check it against the examples, or submit to run every test.