Repolode
obss

obss/sahi

A Python library for sliced inference that runs object detection models over tiles of large images to find small objects.

Stars
5,586
Forks
794
Open issues
10
Last commit
6 days ago

What is it?

SAHI (Slicing Aided Hyper Inference) addresses a common problem in object detection: small objects become hard to detect when a large image is resized to a model's input size. It splits images into overlapping slices, runs detection on each slice, and merges the results back into full-image coordinates.

The library is framework agnostic and wraps detectors from Ultralytics YOLO, MMDetection, Hugging Face, TorchVision, Detectron2, YOLOv5, and Roboflow RF-DETR behind a common API and a `sahi predict` command line tool. Besides sliced prediction, it includes utilities for slicing COCO datasets, converting COCO to YOLO format, evaluating COCO AP and AR, and generating error analysis plots.

Results can be explored interactively through an integration with the FiftyOne app, which can also rank predictions by number of misdetections.

Key features

  • 01Sliced inference that runs detection on image tiles and merges results back to full-image coordinates.
  • 02Unified API and CLI across Ultralytics, MMDetection, Hugging Face, TorchVision, Detectron2, YOLOv5 and RF-DETR models.
  • 03Video and image prediction from the command line.
  • 04COCO utilities for slicing, subsampling, filtering, merging, splitting and converting to YOLO format.
  • 05Classwise COCO AP and AR evaluation and error analysis plot export.
  • 06Interactive result inspection through the FiftyOne app.

Use cases

  • Detecting small objects such as vehicles or people in high-resolution aerial or satellite imagery.
  • Running inference on large surveillance or industrial inspection images without downsampling.
  • Converting and slicing COCO datasets before training a YOLO model.
  • Analyzing where a detector fails by generating error analysis plots.

Quick start

  1. 1

    Install SAHI from PyPI

    pip install sahi
  2. 2

    Install PyTorch and torchvision for your hardware (see Detailed Installation in the README)

    pip install torch==2.13.0 torchvision==0.28.0 --index-url https://download.pytorch.org/whl/cu130
  3. 3

    Install a detection framework such as ultralytics

    pip install ultralytics>=8.3.161

Things to know

  • Full use requires installing a separate detection framework and PyTorch, which adds setup effort.
  • Sliced inference runs the detector over many tiles, so it is slower than standard prediction.

In collections

Topics

FAQ

What is sahi?
A Python library for sliced inference that runs object detection models over tiles of large images to find small objects. SAHI (Slicing Aided Hyper Inference) addresses a common problem in object detection: small objects become hard to detect when a large image is resized to a model's input size. It splits images into overlapping slices, runs detection on each slice, and merges the results back into full-image coordinates.
Is sahi free to use? What license does it have?
sahi is open source under the MIT license. Check the license terms before using it in commercial products.
Is sahi still maintained?
Actively maintained. The last commit to sahi was on Nov 1, 2026.
What can I use sahi for?
Detecting small objects such as vehicles or people in high-resolution aerial or satellite imagery. Running inference on large surveillance or industrial inspection images without downsampling. Converting and slicing COCO datasets before training a YOLO model. Analyzing where a detector fails by generating error analysis plots.
How do I install sahi?
Install SAHI from PyPI: pip install sahi Install PyTorch and torchvision for your hardware (see Detailed Installation in the README): pip install torch==2.13.0 torchvision==0.28.0 --index-url https://download.pytorch.org/whl/cu130 Install a detection framework such as ultralytics: pip install ultralytics>=8.3.161
Where can I get sahi?
The source code and installation instructions are on GitHub: https://github.com/obss/sahi

Summary generated by AI from the project's README. GitHub stats refresh daily.

Related projects