A detector doesn't find one box per object — it finds a dozen nearly identical ones. NMS is the greedy cleanup that keeps only the best of each pile:
iou_threshold — those are duplicates of the same object.Task: write nms(boxes, scores, iou_threshold) where boxes is a list of [x1, y1, x2, y2] and scores is the matching confidence for each. Return the list of kept indices, in the order they were kept (so highest score first).
Note what the threshold does. Set it high and you keep near-duplicates; set it low and you start deleting genuinely separate objects that happen to stand close together.