Jump to content

Connect Leeroopedia MCP: Equip your AI agents to search best practices, build plans, verify code, diagnose failures, and look up hyperparameter defaults.

Heuristic:Obss Sahi Warning Deprecated Legacy NMS

From Leeroopedia




Knowledge Sources
Domains Object_Detection, Postprocessing, Deprecation
Last Updated 2026-02-08 14:00 GMT

Overview

Deprecation warning: the legacy NMS/UnionMerge classes in sahi.postprocess.legacy.combine are superseded by the optimized implementations in sahi.postprocess.combine.

Description

The sahi.postprocess.legacy package contains the original pure-Python NMS and UnionMerge postprocessing classes (NMSPostprocess and UnionMergePostprocess). These have been superseded by the current implementations in sahi.postprocess.combine, which provide:

  • GreedyNMMPostprocess — Optimized greedy non-maximum merging with spatial indexing via Shapely STRtree
  • NMSPostprocess — Torch-based NMS using torchvision.ops.nms or torchvision.ops.batched_nms for GPU acceleration
  • NMMPostprocess — Torch-accelerated non-maximum merging
  • LSNMSPostprocess — Large-Scale NMS using the lsnms library

The legacy implementations use naive O(n^2) nested loops with Python-level iteration, making them significantly slower on large prediction sets.

Usage

This warning applies when you encounter imports from sahi.postprocess.legacy.combine. Migrate to the current sahi.postprocess.combine module unless backward compatibility with older SAHI versions (pre-0.9) is strictly required.

The Insight (Rule of Thumb)

  • Action: Replace imports from sahi.postprocess.legacy.combine with sahi.postprocess.combine.
  • Migration: NMSPostprocess (legacy) maps to NMSPostprocess (current). UnionMergePostprocess (legacy) maps to NMMPostprocess (current).
  • Trade-off: The current implementations require PyTorch as a dependency; the legacy implementations only need NumPy.

Reasoning

The legacy module resides in sahi/postprocess/legacy/, which by directory convention indicates deprecated code. The current postprocessing module (sahi/postprocess/combine.py, 597 lines) provides the same functionality with:

  • Spatial indexing via Shapely STRtree for faster candidate matching
  • Torch-accelerated score sorting and NMS via torchvision.ops
  • Support for additional algorithms (GreedyNMM, LSNMS)

The legacy module (179 lines) uses Python-level loops and copy.deepcopy on every call, which becomes a bottleneck for high-density prediction outputs.

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment