Home

Awesome

<div align="center"> <h1> SAHI: Slicing Aided Hyper Inference </h1> <h4> A lightweight vision library for performing large scale object detection & instance segmentation </h4> <h4> <img width="700" alt="teaser" src="https://raw.githubusercontent.com/obss/sahi/main/resources/sliced_inference.gif"> </h4> <div> <a href="https://pepy.tech/project/sahi"><img src="https://pepy.tech/badge/sahi" alt="downloads"></a> <a href="https://pepy.tech/project/sahi"><img src="https://pepy.tech/badge/sahi/month" alt="downloads"></a> <br> <a href="https://badge.fury.io/py/sahi"><img src="https://badge.fury.io/py/sahi.svg" alt="pypi version"></a> <a href="https://anaconda.org/conda-forge/sahi"><img src="https://anaconda.org/conda-forge/sahi/badges/version.svg" alt="conda version"></a> <a href="https://github.com/obss/sahi/actions/workflows/package_testing.yml"><img src="https://github.com/obss/sahi/actions/workflows/package_testing.yml/badge.svg" alt="package testing"></a> <br> <a href="https://ieeexplore.ieee.org/document/9897990"><img src="https://img.shields.io/badge/DOI-10.1109%2FICIP46576.2022.9897990-orange.svg" alt="ci"></a> <br> <a href="https://colab.research.google.com/github/obss/sahi/blob/main/demo/inference_for_yolov5.ipynb"><img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"></a> <a href="https://huggingface.co/spaces/fcakyon/sahi-yolox"><img src="https://raw.githubusercontent.com/obss/sahi/main/resources/hf_spaces_badge.svg" alt="HuggingFace Spaces"></a>

</div> </div>

<div align="center">Overview</div>

Object detection and instance segmentation are by far the most important applications in Computer Vision. However, the detection of small objects and inference on large images still need to be improved in practical usage. Here comes the SAHI to help developers overcome these real-world problems with many vision utilities.

CommandDescription
predictperform sliced/standard video/image prediction using any ultralytics/mmdet/detectron2/huggingface/torchvision model
predict-fiftyoneperform sliced/standard prediction using any ultralytics/mmdet/detectron2/huggingface/torchvision model and explore results in fiftyone app
coco sliceautomatically slice COCO annotation and image files
coco fiftyoneexplore multiple prediction results on your COCO dataset with fiftyone ui ordered by number of misdetections
coco evaluateevaluate classwise COCO AP and AR for given predictions and ground truth
coco analysecalculate and export many error analysis plots
coco yolov5automatically convert any COCO dataset to ultralytics format

<div align="center">Quick Start Examples</div>

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

🏆 List of competition winners that used SAHI

Tutorials

<a href="https://huggingface.co/spaces/fcakyon/sahi-yolox"><img width="600" src="https://user-images.githubusercontent.com/34196005/144092739-c1d9bade-a128-4346-947f-424ce00e5c4f.gif" alt="sahi-yolox"></a>

</details>

Installation

<img width="700" alt="sahi-installation" src="https://user-images.githubusercontent.com/34196005/149311602-b44e6fe1-f496-40f2-a7ae-5ea1f66e1550.gif"> <details closed> <summary> <big><b>Installation details:</b></big> </summary>
pip install sahi
conda install -c conda-forge shapely
conda install pytorch=1.10.2 torchvision=0.11.3 cudatoolkit=11.3 -c pytorch
conda install pytorch=1.13.1 torchvision=0.14.1 pytorch-cuda=11.7 -c pytorch -c nvidia
pip install yolov5==7.0.13
pip install ultralytics==8.0.207
pip install mim
mim install mmdet==3.0.0
pip install detectron2 -f https://dl.fbaipublicfiles.com/detectron2/wheels/cu113/torch1.10/index.html
pip install transformers timm
pip install super-gradients==3.3.1
</details>

Framework Agnostic Sliced/Standard Prediction

<img width="700" alt="sahi-predict" src="https://user-images.githubusercontent.com/34196005/149310540-e32f504c-6c9e-4691-8afd-59f3a1a457f0.gif">

Find detailed info on sahi predict command at cli.md.

Find detailed info on video inference at video inference tutorial.

Find detailed info on image/dataset slicing utilities at slicing.md.

Error Analysis Plots & Evaluation

<img width="700" alt="sahi-analyse" src="https://user-images.githubusercontent.com/34196005/149537858-22b2e274-04e8-4e10-8139-6bdcea32feab.gif">

Find detailed info at Error Analysis Plots & Evaluation.

Interactive Visualization & Inspection

<img width="700" alt="sahi-fiftyone" src="https://user-images.githubusercontent.com/34196005/149321540-e6ddd5f3-36dc-4267-8574-a985dd0c6578.gif">

Find detailed info at Interactive Result Visualization and Inspection.

Other utilities

Find detailed info on COCO utilities (yolov5 conversion, slicing, subsampling, filtering, merging, splitting) at coco.md.

Find detailed info on MOT utilities (ground truth dataset creation, exporting tracker metrics in mot challenge format) at mot.md.

<div align="center">Citation</div>

If you use this package in your work, please cite it as:

@article{akyon2022sahi,
  title={Slicing Aided Hyper Inference and Fine-tuning for Small Object Detection},
  author={Akyon, Fatih Cagatay and Altinuc, Sinan Onur and Temizel, Alptekin},
  journal={2022 IEEE International Conference on Image Processing (ICIP)},
  doi={10.1109/ICIP46576.2022.9897990},
  pages={966-970},
  year={2022}
}
@software{obss2021sahi,
  author       = {Akyon, Fatih Cagatay and Cengiz, Cemil and Altinuc, Sinan Onur and Cavusoglu, Devrim and Sahin, Kadir and Eryuksel, Ogulcan},
  title        = {{SAHI: A lightweight vision library for performing large scale object detection and instance segmentation}},
  month        = nov,
  year         = 2021,
  publisher    = {Zenodo},
  doi          = {10.5281/zenodo.5718950},
  url          = {https://doi.org/10.5281/zenodo.5718950}
}

<div align="center">Contributing</div>

sahi library currently supports all YOLOv5 models, MMDetection models, Detectron2 models, and HuggingFace object detection models. Moreover, it is easy to add new frameworks.

All you need to do is, create a new .py file under sahi/models/ folder and create a new class in that .py file that implements DetectionModel class. You can take the MMDetection wrapper or YOLOv5 wrapper as a reference.

Before opening a PR:

pip install -e ."[dev]"
python -m scripts.run_code_style format

<div align="center">Contributors</div>

<div align="center">

<a align="left" href="https://github.com/fcakyon" target="_blank">Fatih Cagatay Akyon</a>

<a align="left" href="https://github.com/sinanonur" target="_blank">Sinan Onur Altinuc</a>

<a align="left" href="https://github.com/devrimcavusoglu" target="_blank">Devrim Cavusoglu</a>

<a align="left" href="https://github.com/cemilcengiz" target="_blank">Cemil Cengiz</a>

<a align="left" href="https://github.com/oulcan" target="_blank">Ogulcan Eryuksel</a>

<a align="left" href="https://github.com/kadirnar" target="_blank">Kadir Nar</a>

<a align="left" href="https://github.com/madenburak" target="_blank">Burak Maden</a>

<a align="left" href="https://github.com/PushpakBhoge" target="_blank">Pushpak Bhoge</a>

<a align="left" href="https://github.com/mcvarer" target="_blank">M. Can V.</a>

<a align="left" href="https://github.com/ChristofferEdlund" target="_blank">Christoffer Edlund</a>

<a align="left" href="https://github.com/ishworii" target="_blank">Ishwor</a>

<a align="left" href="https://github.com/mecevit" target="_blank">Mehmet Ecevit</a>

<a align="left" href="https://github.com/ssahinnkadir" target="_blank">Kadir Sahin</a>

<a align="left" href="https://github.com/weypro" target="_blank">Wey</a>

<a align="left" href="https://github.com/youngjae-avikus" target="_blank">Youngjae</a>

<a align="left" href="https://github.com/tureckova" target="_blank">Alzbeta Tureckova</a>

<a align="left" href="https://github.com/s-aiueo32" target="_blank">So Uchida</a>

<a align="left" href="https://github.com/developer0hye" target="_blank">Yonghye Kwon</a>

<a align="left" href="https://github.com/aphilas" target="_blank">Neville</a>

<a align="left" href="https://github.com/mayrajeo" target="_blank">Janne Mäyrä</a>

<a align="left" href="https://github.com/christofferedlund" target="_blank">Christoffer Edlund</a>

<a align="left" href="https://github.com/ilkermanap" target="_blank">Ilker Manap</a>

<a align="left" href="https://github.com/nguyenthean" target="_blank">Nguyễn Thế An</a>

<a align="left" href="https://github.com/weiji14" target="_blank">Wei Ji</a>

<a align="left" href="https://github.com/aynursusuz" target="_blank">Aynur Susuz</a>

<a align="left" href="https://github.com/pranavdurai10" target="_blank">Pranav Durai</a>

<a align="left" href="https://github.com/lakshaymehra" target="_blank">Lakshay Mehra</a>

<a align="left" href="https://github.com/karl-joan" target="_blank">Karl-Joan Alesma</a>

<a align="left" href="https://github.com/jacobmarks" target="_blank">Jacob Marks</a>

<a align="left" href="https://github.com/williamlung" target="_blank">William Lung</a>

<a align="left" href="https://github.com/amoghdhaliwal" target="_blank">Amogh Dhaliwal</a>

</div>