MCPcopy
hub / github.com/obss/sahi

github.com/obss/sahi @0.12.1 sqlite

repository ↗ · DeepWiki ↗ · release 0.12.1 ↗
754 symbols 2,923 edges 139 files 705 documented · 94%
README

SAHI logo

SAHI: Slicing Aided Hyper Inference

A lightweight vision library for performing large scale object detection & instance segmentation

teaser

Total Downloads Monthly Downloads PyPI Version Conda Version License

CI Known Vulnerabilities CodeFactor DOI

Context7 MCP llms.txt DeepWiki HuggingFace Spaces

Overview

SAHI helps developers overcome real-world challenges in object detection by enabling sliced inference for detecting small objects in large images. It supports various popular detection models and provides easy-to-use APIs.

🌐 English | 🇨🇳 简体中文

Command Description
predict Perform sliced/standard video/image prediction using any ultralytics / mmdet / huggingface / torchvision model — see CLI guide
predict-fiftyone Perform sliced/standard prediction using any supported model and explore results in fiftyone applearn more
coco slice Automatically slice COCO annotation and image files — see slicing utilities
coco fiftyone Explore multiple prediction results on your COCO dataset with fiftyone ui ordered by number of misdetections
coco evaluate Evaluate classwise COCO AP and AR for given predictions and ground truth — check COCO utilities
coco analyse Calculate and export many error analysis plots — see the complete guide
coco yolo Automatically convert any COCO dataset to ultralytics format

Approved by the Community

📜 List of publications that cite SAHI (currently 600+)

🏆 List of competition winners that used SAHI

Approved by AI Tools

SAHI's documentation is indexed in Context7 MCP, providing AI coding assistants with up-to-date, version-specific code examples and API references. We also provide an llms.txt file following the emerging standard for AI-readable documentation. To integrate SAHI docs with your AI development workflow, check out the Context7 MCP installation guide.

Installation

Basic Installation

pip install sahi

Detailed Installation (Click to open)

  • Install your desired version of pytorch and torchvision:
pip install torch==2.7.0 torchvision==0.22.0 --index-url https://download.pytorch.org/whl/cu126

(torch 2.1.2 is required for mmdet support):

pip install torch==2.1.2 torchvision==0.16.2 --index-url https://download.pytorch.org/whl/cu121
  • Install your desired detection framework (ultralytics):
pip install ultralytics>=8.3.161
  • Install your desired detection framework (huggingface):
pip install transformers>=4.49.0 timm
  • Install your desired detection framework (yolov5):
pip install yolov5==7.0.14 sahi==0.12.1
  • Install your desired detection framework (mmdet):
pip install mim
mim install mmdet==3.3.0
  • Install your desired detection framework (roboflow):
pip install inference>=0.51.5 rfdetr>=1.6.2

Quick Start

Learning Resources

Resource Type
Introduction to SAHI Blog Post
2025 Video Tutorial Video
Official Paper (ICIP 2022 oral) Paper
Pretrained Weights & ICIP 2022 Paper Files Benchmark
Visualizing and Evaluating SAHI Predictions with FiftyOne Blog Post
Exploring SAHI – learnopencv.com Article
Slicing Aided Hyper Inference Explained by Encord Article
Video Tutorial: SAHI for Small Object Detection Video
Satellite Object Detection Blog Post
COCO Dataset Conversion Blog Post
Kaggle Notebook Notebook
Error Analysis Plots & Evaluation Discussion
Interactive Result Visualization and Inspection Discussion
Video Inference Support Discussion
Slicing Operation Notebook Notebook
Complete Documentation Docs

Notebooks & Demos

| Framework | Notebook | Demo | | ------------------ | ---------------------------------------------------------------------------------------------

Core symbols most depended-on inside this repo

tolist
called by 42
sahi/postprocess/utils.py
read_image
called by 36
sahi/utils/cv.py
deepcopy
called by 35
sahi/annotation.py
to_xywh
called by 27
sahi/annotation.py
from_pretrained
called by 22
sahi/auto_model.py
_cocoeval_summarize
called by 20
sahi/scripts/coco_evaluation.py
get_prediction
called by 19
sahi/predict.py
from_coco_dict_or_path
called by 19
sahi/utils/coco.py

Shape

Method 435
Function 232
Class 86
Route 1

Languages

Python100%

Modules by API surface

sahi/utils/coco.py98 symbols
tests/test_combine.py59 symbols
sahi/annotation.py44 symbols
sahi/slicing.py27 symbols
sahi/postprocess/utils.py27 symbols
sahi/utils/cv.py24 symbols
tests/test_coco_utils.py23 symbols
sahi/utils/shapely.py21 symbols
sahi/prediction.py20 symbols
sahi/postprocess/combine.py19 symbols
sahi/models/huggingface.py18 symbols
sahi/postprocess/legacy/combine.py17 symbols

Dependencies from manifests, versioned

fire
opencv-python4.12.0.88 · 1×
pillow8.2.0 · 1×
pyyaml
shapely2.0.0 · 1×
tqdm4.48.2 · 1×

For agents

$ claude mcp add sahi \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact