Contributing to SAHI
April 10, 2026 ยท View on GitHub
Thank you for your interest in contributing to SAHI! This guide will help you get started.
Setting Up Development Environment
1. Fork and Clone
git clone https://github.com/YOUR_USERNAME/sahi.git
cd sahi
2. Create Environment
We recommend Python 3.10 for development:
pip install uv
uv venv --python 3.10
source .venv/bin/activate # On Windows: .venv\Scripts\activate
3. Install Dependencies
# Install core + dev dependencies
uv sync --extra dev
# For testing specific models, install their dependencies.
Code Formatting
We use ruff for code formatting and linting. To format your code:
# Check formatting
uv run ruff check .
uv run ruff format --check .
# Fix formatting
uv run ruff check --fix .
uv run ruff format .
Or use the convenience script:
# Check formatting
python scripts/format_code.py check
# Fix formatting
python scripts/format_code.py fix
Running Tests
# Run all tests
uv run pytest
# Run specific test file
uv run pytest tests/test_predict.py
# Run with coverage
uv run pytest --cov=sahi
Submitting Pull Requests
- Create a new branch:
git checkout -b feature-name - Make your changes
- Format your code:
python scripts/format_code.py fix - Run tests:
uv run pytest - Commit with clear message:
git commit -m "Add feature X" - Push and create PR:
git push origin feature-name
CI Build Failures
If the CI build fails due to formatting:
-
Check the CI output for the specific Python version that failed
-
Create environment with that Python version:
uv venv --python 3.X # Replace X with the version from CI source .venv/bin/activate -
Install dev dependencies:
uv sync --extra dev -
Fix formatting:
python scripts/format_code.py fix -
Commit and push the changes
Adding New Model Support
To add support for a new detection framework:
- Create a new file under
sahi/models/your_framework.py - Implement a class that inherits from
DetectionModel - Add your framework to
MODEL_TYPE_TO_MODEL_CLASS_NAMEinsahi/auto_model.py - Add tests under
tests/test_yourframework.py - Add a demo notebook under
docs/notebooks/inference_for_your_framework.ipynb - Update
README.mdand related docs underdocs/to include your new model
See existing implementations like sahi/models/ultralytics.py for reference.
Questions?
Feel free to start a discussion if you have questions!