A lightweight Python API for object detection with pluggable backends. This API allows you to detect objects in images using different detection backends, starting with TensorFlow Lite.
- FastAPI-based REST API for object detection
- Pluggable backend architecture for different detection engines
- TensorFlow Lite integration for lightweight, efficient object detection
- Support for image uploads and detection with confidence thresholds
- Extensible design for adding new detection backends
- Python 3.9+
- pipenv (for dependency management)
-
Clone the repository:
git clone https://github.com/yourusername/light-object-detect.git cd light-object-detect
-
Install dependencies:
pipenv install
-
Download a sample TFLite model:
pipenv run python scripts/download_model.py
-
Start the API server using the provided script:
pipenv run python scripts/run_server.py --reload
Or manually with uvicorn:
pipenv run uvicorn main:app --reload --port 9001
-
The API will be available at http://localhost:9001
-
Access the API documentation at http://localhost:9001/docs
GET /
- Root endpoint with API informationGET /api/v1/backends
- List available detection backendsPOST /api/v1/detect
- Detect objects in an uploaded image
curl -X POST "http://localhost:9001/api/v1/detect" \
-H "accept: application/json" \
-H "Content-Type: multipart/form-data" \
-F "file=@/path/to/your/image.jpg" \
-F "backend=tflite" \
-F "confidence_threshold=0.5"
To add a new detection backend:
- Create a new module in the
backends
directory - Implement the
DetectionBackend
interface - Register the backend in
backends/factory.py
light-object-detect/
├── api/ # API endpoints
│ ├── v1/ # API version 1
│ │ └── endpoints/ # API endpoints
│ │ └── detection.py # Detection endpoints
│ └── router.py # API router
├── backends/ # Detection backends
│ ├── base.py # Base backend interface
│ ├── factory.py # Backend factory
│ └── tflite/ # TFLite backend
│ └── backend.py # TFLite implementation
├── models/ # Data models
│ └── detection.py # Detection models
├── scripts/ # Utility scripts
│ ├── download_model.py # Script to download models
│ ├── run_server.py # Script to run the API server
│ └── test_api.py # Script to test the API
├── utils/ # Utility functions
│ └── image.py # Image processing utilities
├── config.py # Application configuration
├── main.py # FastAPI application
├── Pipfile # Dependencies
└── README.md # This file
Licensed under GPLv3