sahi
A vision library for performing sliced inference on large images/small objects
What it is and what it does
SAHI is a lightweight wrapper library that enables sliced inference—a technique for improving object detection on large images containing small objects. Instead of running detection on the full image at once, SAHI divides the image into overlapping tiles, runs inference on each tile independently, and merges the predictions back together. This approach helps detection models see small objects at higher effective resolution, which often improves accuracy on objects that would otherwise be missed or poorly localized.
The library integrates with popular detection frameworks (ultralytics, mmdet, huggingface, torchvision, roboflow) and provides both programmatic APIs and command-line tools. It includes utilities for dataset slicing, COCO evaluation, error analysis, and visualization. Runtime dependencies are standard data-processing libraries (numpy, opencv-python, pillow, matplotlib, shapely, requests, pyyaml, click, fire, tqdm), making it straightforward to add to existing computer vision pipelines.
Use it for:
- Detect small objects in aerial or satellite imagery by slicing large images into manageable tiles.
- Improve detection accuracy on crowded scenes where objects are densely packed and small relative to image size.
- Preprocess datasets by automatically slicing COCO-annotated images and converting between annotation formats.
- Evaluate detection model performance on large images using built-in COCO evaluation and error analysis tools.
- Prototype detection pipelines with multiple frameworks without rewriting inference code.
- Analyze detection failures across a dataset and export error plots for model debugging.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
SAHI performs sliced inference on large images to detect and segment small objects, breaking images into overlapping tiles for processing by detection models and merging results.
Yes. SAHI is actively maintained, has no security vulnerabilities, and solves a real problem in object detection on large images. Install it if you work with large images containing small objects or need a framework-agnostic wrapper for detection inference. The low install friction and permissive license make it a low-risk addition to a computer vision project.
Install
sahi on PyPI
pip
pip install sahiuv
uv add sahipoetry
poetry add sahiInstalling sahi
Before you install
Low install friction with a pure-Python wheel and no compiled dependencies. Active maintenance with a recent release (11 days ago) and steady repository activity.
License in practice
MIT license permits commercial and private use with minimal restrictions—suitable for most projects.
Quickstart
pip install sahi
from sahi.prediction import get_prediction
from sahi.models.detection import Yolov8DetectionModel
model = Yolov8DetectionModel(model_type="yolov8m", device="cpu")
results = get_prediction(image_path="image.jpg", detection_model=model)
Requires a detection framework (ultralytics, mmdet, huggingface, torchvision, or roboflow) to be installed separately; PyTorch and torchvision are also required dependencies not bundled with SAHI.
Verify before relying
- Whether sliced inference provides measurable accuracy gains on your specific object sizes and image resolutions.
- Performance overhead of tiling and merging compared to full-image inference on your hardware.
- Compatibility matrix between SAHI version 0.12.5 and specific detection framework versions.
- Tile dimensions and overlap strategy supported by the slicing API.
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.8) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 10 — click, fire, matplotlib, numpy, opencv-python, pillow, pyyaml, requests, shapely, tqdm |
| Maintenance | actively maintained — 11 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 281,218/month — #8,102 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: sahi-0.12.5-py3-none-any.whl
Tags
More Libraries packages
urllib3 is an HTTP client library that provides…
permissive · top 100 on PyPI
requestsRequests is a Python HTTP library that…
permissive · top 100 on PyPI
pluggyPluggy provides a plugin system that lets you…
permissive · top 100 on PyPI
python-dateutilProvides parsing, arithmetic, and recurrence…
permissive · top 100 on PyPI
sixSix provides utility functions to write Python…
permissive · top 100 on PyPI
pytestpytest is a testing framework that lets you…
permissive · top 100 on PyPI
faster-coco-evalFaster-COCO-Eval provides a high-performance…
unclear · top 15,000 on PyPI
slicerProvides a uniform slicing interface for…
permissive · top 5,000 on PyPI
ultralyticsUltralytics YOLO provides a unified framework…
agpl · top 5,000 on PyPI
inference-sdkPython SDK for connecting to and running…
permissive · top 15,000 on PyPI
inference-cliA command-line tool for running computer vision…
permissive · top 15,000 on PyPI
mmdetMMDetection is an object detection and instance…
permissive · top 15,000 on PyPI
rfdetrRF-DETR is a transformer-based object…
permissive · top 15,000 on PyPI
fiftyoneFiftyOne is a Python framework for building,…
permissive · top 15,000 on PyPI
rcsliceSlices lists using a row-column notation with…
permissive · top 15,000 on PyPI
transparent-backgroundRemoves backgrounds from images and videos…
permissive · top 15,000 on PyPI