An intuitive guide to understanding Non-maximum suppression (NMS)

I found this to be a good resource for better understanding NMS

In a nutshell, here’s the NMS algorithm for one class

  1. Instantiate an empty list, call it outputs = []
  2. Sort all bounding boxes by descending score and call the list bboxes.
  3. Select the bounding box with the largest score from bboxes and put it into outputs.
  4. Computer the intersection over union between the highest score bounding box with other bounding boxes in bboxes. Remove bounding boxes from bboxes if IoU is 0.5 or higher. (The IoU threshold is a hyperparameter).
  5. If bboxes is not empty, we repeat the process from step 3.
  6. At last, we return outputs that contains the non-overlapping bounding boxes (as per the IoU threshold).

When there are multiple objects to be detected then you perform NMS independently for each class, ranking bounding boxes by score within one class.

1 Like