Non-maximum suppression (NMS)

Non-maximum suppression (NMS) is the post-processing step that removes duplicate detections: among boxes of the same class that overlap more than an IoU threshold, it keeps the one with the highest confidence and discards the rest. Transformer detectors such as RT-DETR and DEIM predict one box per object and skip it.

Tasks and training

The greedy algorithm

  1. Drop boxes below the confidence threshold and sort the rest by score.
  2. Take the highest-scoring box and add it to the output.
  3. Remove every remaining box of the same class whose IoU with it exceeds the NMS threshold.
  4. Repeat from step 2 until no boxes are left.

A worked example

Three boxes of the class "person", with the NMS threshold at 0.5:

BoxScoreIoU with AResult
A0.92–Kept: highest score
B0.850.71Removed: a duplicate of A
C0.600.10Kept: a different person

Settings that change the result

A lower IoU threshold removes more boxes; a higher one leaves more duplicates, which count as false positives and lower precision. NMS can run per class or across classes, and most implementations cap the number of boxes kept per image. The confidence threshold applied before NMS often matters as much as the NMS threshold itself.

Where NMS hurts

In crowds, two real people standing close can overlap above the threshold, and greedy NMS deletes one of them. Soft-NMS lowers the scores of overlapping boxes instead of removing them, which keeps more of those true neighbours.

Detectors that skip it

Some recent models are trained so that each object yields one box. The README of the Supervisely YOLOv8 app describes YOLOv10 as using consistent dual assignments for NMS-free training, and the RT-DETRv2 app describes the model as eliminating the need for NMS in post-processing. Other YOLO versions and anchor-based detectors still rely on it; see anchor boxes.

Frequently asked questions.

Why is non-maximum suppression needed?

Detectors often predict several overlapping boxes for one object. NMS keeps the box with the highest score and removes the others whose IoU with it is above a threshold, so each object is reported once.

Do all object detectors need NMS?

No. DETR-style detectors such as RT-DETR, and YOLOv10 and YOLO26 in their end-to-end mode, predict one box per object and skip NMS.