reachy-vision-api / README.md
Chris
feat: add YOLOv8 object detection API
00340de unverified
---
title: Reachy Vision API
emoji: πŸ€–
colorFrom: blue
colorTo: purple
sdk: docker
pinned: false
---
# Reachy Vision API
**FastAPI-based YOLOv8 vision API for Reachy robots.**
Reachy Vision API is a lightweight object detection service built with **FastAPI** and **YOLOv8**, designed to run on **Hugging Face Spaces (Docker)** or locally, and to be easily integrated with **Reachy robots** or any backend.
---
## ✨ Features
- πŸ” Object detection powered by **YOLOv8**
- ⚑ FastAPI HTTP API (simple & stateless)
- 🐳 Hugging Face **Docker Space** compatible
- 🧠 CPU-friendly (`yolov8n` by default)
- πŸ€– Ready to integrate with **Reachy Mini**
- πŸ“¦ Dependency management with **uv**
---
## πŸ“‘ API Endpoints
### Health check
```
GET /health
```
Response:
```json
{ "status": "ok" }
```
---
### Object detection
```
POST /detect
```
**Request**
- `multipart/form-data`
- Field: `file` (image)
**Example**
```bash
curl -X POST \
-F "file=@image.jpg" \
http://localhost:7860/detect
```
**Response**
```json
{
"num_detections": 2,
"detections": [
{
"class_id": 0,
"class_name": "person",
"confidence": 0.92,
"bbox_xyxy": [120.3, 45.1, 380.7, 620.9]
}
]
}
```
---
## πŸš€ Deployment (Hugging Face Space)
Recommended setup:
- **Space type**: `Docker`
- **Hardware**: CPU (default) or GPU
- **Exposed port**: `7860`
### Repository structure
```
reachy-vision-api/
β”œβ”€β”€ app.py # FastAPI application
β”œβ”€β”€ Dockerfile # Docker image definition
β”œβ”€β”€ pyproject.toml # Project configuration and dependencies
β”œβ”€β”€ uv.lock # Lockfile for reproducible builds
β”œβ”€β”€ .gitignore # Git ignore rules
β”œβ”€β”€ tests/ # Test suite
β”‚ β”œβ”€β”€ __init__.py
β”‚ β”œβ”€β”€ conftest.py # Pytest fixtures
β”‚ └── test_api.py # API tests
└── README.md
```
Once pushed, the Space will automatically build and expose:
```
https://<username>-<space-name>.hf.space
```
---
## 🐳 Docker (local run)
```bash
docker build -t reachy-vision-api .
docker run -p 7860:7860 reachy-vision-api
```
---
## πŸ“¦ Dependencies
Dependencies are managed using **uv**.
Main dependencies:
- `fastapi`
- `uvicorn`
- `ultralytics`
- `pillow`
- `python-multipart`
The lockfile (`uv.lock`) ensures reproducible builds.
---
## πŸ› οΈ Development
Install dev dependencies:
```bash
uv sync --extra dev
```
### Tools
- **ruff** - Linter and formatter
- **mypy** - Static type checker
- **pytest** - Testing framework
- **pytest-cov** - Code coverage
### Run tests
```bash
uv run pytest
```
Coverage report is generated in `htmlcov/` and displayed in terminal.
### Lint and format
```bash
uv run ruff check .
uv run ruff format .
```
### Type checking
```bash
uv run mypy app.py
```
### Release workflow
This project uses [commitizen](https://commitizen-tools.github.io/commitizen/) for versioning and changelog generation.
To trigger a new release, push a commit to `main` with the message `chore: release a new version`:
```bash
git commit --allow-empty -m "chore: release a new version"
git push origin main
```
This will:
1. Bump the version based on conventional commits
2. Generate/update the CHANGELOG
3. Create a GitHub Release
4. Sync to Hugging Face Space
---
## πŸ€– Usage with Reachy
This API is designed to be called from:
- Reachy Mini
- A central VPS backend
- Another Hugging Face Space
Typical flow:
1. Capture image from Reachy camera
2. Send image to `/detect`
3. Use detections for interaction, navigation, or reasoning
---
## πŸ“„ License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.