obss/sahi

Framework agnostic sliced/tiled inference + interactive ui + error analysis plots

SAHI – Slicing‑Aided Hyper Inference

What it is – SAHI is a lightweight Python library that makes object‑detection models work better on very large images or videos. It does this by automatically cutting the input into overlapping tiles, running a standard detector on each tile, and then stitching the results back together. The technique is called sliced inference and helps find small objects that would otherwise be missed.

Key capabilities

  • Works with many popular detection back‑ends: Ultralytics YOLO (v5, v8, YOLOX, YOLO‑E, etc.), MMDetection, Detectron2, Hugging Face object‑detection pipelines, TorchVision, Roboflow RF‑DETR, GroundingDINO, and more.
  • Provides a unified CLI (sahi predict, sahi predict‑fiftyone, sahi coco …) for image, video, and COCO‑style dataset processing.
  • Includes utilities to slice COCO datasets, convert between formats, evaluate AP/AR, and generate error‑analysis plots.
  • Integrates with the FiftyOne visualisation tool for interactive inspection of predictions.
  • Distributed on PyPI and Conda‑Forge; installation is a single pip install sahi plus optional dependencies for the chosen detector.

Typical workflow

  1. Install the library and the detector you want (e.g., pip install ultralytics).
  2. Run sahi predict pointing to an image/video and a model checkpoint. SAHI will automatically tile the input, run inference on each tile, and output merged detections.
  3. (Optional) Open the results in FiftyOne with sahi predict‑fiftyone for visual debugging.
  4. For dataset‑level work, use the coco sub‑commands to slice annotations, evaluate against ground truth, or convert to a format required by a specific framework.

Why it matters – Large‑scale aerial, satellite, or medical images often contain tiny objects that standard detectors miss because the objects occupy only a few pixels. By slicing the image, SAHI lets existing models keep their original architecture while dramatically improving recall on small objects, without needing to retrain.

Resources

  • Official paper (ICIP 2022) – https://ieeexplore.ieee.org/document/9897990
  • Quick‑start notebooks for every major detector (all runnable on Google Colab)
  • Community‑maintained list of papers and competition wins that cite SAHI
  • HuggingFace Space demo showing YOLOX inference on large images

Installation snippet

pip install sahi               # core library
# pick a detector framework, e.g.:
pip install ultralytics>=8.3   # YOLO family
# or for MMDetection support:
pip install mim && mim install mmdet==3.3.0

Getting started – After installing, try the demo notebook:

jupyter notebook demo/inference_for_ultralytics.ipynb

or run a one‑liner on the command line:

sahi predict --model yolov8n.pt --image path/to/large_image.tif

All information above is taken directly from the repository’s README.

Related

  • Project
  • Project
  • Project
  • Project
  • Project