pub const MAX_NMS_CANDIDATES: usize = 30_000;Expand description
Maximum number of above-threshold candidates fed to NMS.
At very low score thresholds (e.g., t=0.01 on YOLOv8 with 8400 anchors × 80 classes), the number of survivors approaches the full 672 000-entry score grid. NMS is O(n²) and the downstream mask matmul runs once per survivor, so an unbounded set produces minutes-per-frame decode times.
MAX_NMS_CANDIDATES matches the Ultralytics max_nms default
and is applied as a top-K-by-score truncation immediately
before NMS. Values above the cap are silently dropped — at the
score thresholds where the cap activates the bottom of the
candidate list is dominated by noise that NMS would discard
anyway.