Non-Maximum Suppression (NMS)
How object detectors filter overlapping boxes to keep only the best predictions.
When an object detector processes an image, it often generates many overlapping bounding boxes around the same object. This happens because multiple anchor boxes or grid cells might fire simultaneously for a single object.
To fix this, NMS first selects the bounding box with the highest confidence score. This box is temporarily considered the "true" detection for the object.
Next, it calculates the Intersection over Union (IoU) between this selected box and all other overlapping boxes. IoU measures how much the boxes overlap geometrically.
Any box that overlaps with the selected box more than a predefined threshold (e.g., IoU > 0.5) is suppressed (discarded). The process repeats for the remaining boxes until no unsuppressed boxes overlap significantly.