Search⌘ K
AI Features

Understanding NMS (Non-Maximum Suppression)

Explore how Non-Maximum Suppression (NMS) works to remove multiple overlapping bounding boxes in object detection, ensuring only the most confident box remains. Understand NMS for single and multiple classes, confidence scoring, and IoU thresholds to optimize YOLO predictions.

Why do we need NMS?

Object detection models often predict multiple bounding boxes for a single object in an image. However, the final output should ideally have only one bounding box per object. To achieve this, a technique called non-maximum suppression (NMS) is used.

In the image below, there are three bounding boxes predicted for one person with different confidence scores. On visual inspection, for our final output, we would prefer the green box because it fits better as compared to the other two boxes and has the highest confidence score.

Multiple bounding boxes predicted for a single object
Multiple bounding boxes predicted for a single object

How does NMS work?

NMS works at the inference stageWhile making predictions as a post processing step to suppress unnecessary boxes and to output a confident box.
The format of a bounding box followed in YOLO is [xmin,ymin,xmax,ymax,conf,classx_{min}, y_{min}, x_{max}, y_{max}, conf, class ...