Abstract
In modern object detection pipelines, Non-Maximum Suppression (NMS) has emerged as a significant post-processing bottleneck. While neural network inference has been optimized through hardware acceleration and efficient architectures, NMS remains largely sequential with a worst-case complexity of $O(n^2)$. This paper reinterprets NMS through the lens of graph theory, modeling the suppression process as a Directed Acyclic Graph (DAG). Leveraging this perspective, we introduce two novel algorithms: eQSI-NMS, which utilizes a Cartesian tree structure to achieve $O(n \log n)$ complexity, and BOE-NMS, which employs geometric pruning to accelerate processing with zero accuracy loss. To facilitate standardized evaluation, we also present NMS-Bench. Our results demonstrate speedups of up to 10.7× on standard benchmarks like MS COCO 2017.
Introduction
Object detection is typically a two-phase process: model inference followed by post-processing. As GPUs and lightweight architectures (such as the YOLO series) have drastically reduced inference time, the "last mile" of the pipeline—NMS—has become a disproportionate computational burden. Standard NMS greedily selects the highest-confidence bounding box and suppresses all overlapping boxes exceeding a specific Intersection over Union (IoU) threshold. This sequential nature limits the benefits of parallel hardware and leads to redundant calculations.
Previous attempts to optimize NMS have often focused on brute-force parallelization (e.g., Fast NMS or Cluster NMS) rather than addressing the underlying algorithmic complexity. Furthermore, the lack of a unified benchmarking framework has made it difficult to compare different NMS strategies across varying models and datasets. This work addresses these gaps by providing a theoretical graph-based foundation for NMS and proposing efficient, mathematically grounded alternatives.
A Graph Theory Perspective on NMS
The core insight of this research is that the suppression relationship between bounding boxes can be modeled as a Directed Acyclic Graph (DAG). In this model:
- Each bounding box is represented as a node.
- A directed edge (arc) exists from box $A$ to box $B$ if $A$ has a higher confidence score than $B$ and the IoU between them exceeds the suppression threshold.
By viewing NMS as a DAG, the problem of finding the final set of kept boxes becomes equivalent to solving a dynamic programming equation in topological order. Analysis of real-world detection data reveals that these graphs are remarkably sparse, consisting of numerous small "Weakly Connected Components" (WCCs). This sparsity suggests that the traditional $O(n^2)$ approach performs a vast number of unnecessary comparisons between boxes that have no spatial or logical interaction.
Proposed Algorithms
1. eQSI-NMS (Enhanced Quicksort Induced NMS)
Inspired by the divide-and-conquer logic of the quicksort algorithm, QSI-NMS partitions boxes into subsets based on their spatial centroids using Manhattan distance. The enhanced version, eQSI-NMS, utilizes a Cartesian tree structure. This approach reduces the search space for potential suppressions, achieving an optimal complexity of $O(n \log n)$. While this method introduces a negligible trade-off in accuracy, it provides the highest throughput gains for high-speed applications.
2. BOE-NMS (Boxes Outside Excluded NMS)
BOE-NMS focuses on geometric locality to prune redundant IoU calculations. The authors prove a geometric theorem: if the centroid of box $B$ lies outside the boundaries of box $A$, their IoU is guaranteed to be $\leq 0.5$. Given that most NMS thresholds are set above 0.5, BOE-NMS uses a search tree to restrict IoU calculations only to boxes whose centroids fall within a specific neighborhood. Crucially, this method is mathematically proven to result in zero mAP loss compared to the original NMS algorithm.
NMS-Bench: A New Evaluation Framework
To address the evaluation gap in the field, the authors introduced NMS-Bench. This benchmark decouples model inference from the post-processing stage by saving raw box outputs from various models. This allows researchers to test and iterate on NMS algorithms in minutes rather than hours, providing a standardized environment to measure speed and accuracy across different architectures (e.g., YOLOv5, YOLOv8, Faster R-CNN) and datasets (MS COCO, Open Images V7).
Experimental Results
The proposed methods were evaluated against existing standards like Fast NMS and Cluster NMS. Key findings include:
- Throughput Gains: On the YOLOv8-N model using MS COCO, eQSI-NMS achieved a 10.7× speedup over the original NMS with only a 0.3% drop in mAP.
- Lossless Acceleration: BOE-NMS provided a 5.1× speedup with 0.0% mAP loss, offering a "plug-and-play" performance boost for existing production pipelines.
- Versatility: The speedups remained consistent across both one-stage and two-stage detectors. In Faster R-CNN, where box counts are typically lower, the methods still yielded 2× to 4× improvements, demonstrating effectiveness even on resource-constrained edge devices.
Conclusion and Future Work
By reinterpreting NMS through graph theory and geometric pruning, this work demonstrates that the computational overhead of object detection post-processing can be significantly reduced without sacrificing accuracy. Future research directions include combining QSI-NMS with accuracy-recovery techniques like Soft-NMS and further optimizing these graph-based approaches for direct implementation on GPU architectures. Additionally, the distribution of Weakly Connected Components offers a promising avenue for discovering even tighter geometric bounds for suppression pruning.
Summary updated