This project provides an object detection Flask service using YOLOv5 models.
The service can run inference using either ONNX models or RKNN (Orange Pi 5 Plus tested).
Note: To use RKNN engine, install it manually from distr/
directory.
data/
distr/
models/
uploads/
app.py
detectors.py
requirements.txt
test_api.py
test_rknn.py
- app.py: Main application file for the Flask server.
- detectors.py: Contains the detector classes for RKNN and ONNX models.
- requirements.txt: List of Python dependencies.
- test_api.py: Unit tests for the API.
- test_rknn.py: Script to test the RKNN model.
- data: Contains data files such as anchors and labels.
- models: Contains the model files.
- uploads: Directory for uploaded images.
- Python 3.10 or higher
pip
package manager
- Clone the repository:
git clone https://github.com/labintsev/flask_objects_detection.git
cd flask_objects_detection
- Create a virtual environment and activate it:
python -m venv venv
source venv/bin/activate # On Windows use `venv\Scripts\activate`
- Install the dependencies:
pip install -r requirements.txt
- Create a .env file in the root directory with the following content:
APP_TOKEN=your_secret_token
- Install RKNN engine (for Orange Pi 5 devices):
pip install distr/rknn_toolkit_lite2-2.3.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
To start the Flask server, run:
python app.py
By default, the server will run on http://0.0.0.0:5000
.
GET /
: Home endpoint. Returns a welcome message.POST /predict
: Endpoint for object detection. Requires an image file and a valid token.
curl -X POST http://127.0.0.1:5000/predict \
-H "Authorization: Bearer your_secret_token" \
-F "image_file=@path_to_your_image.jpg"
To run the unit tests, use:
python -m unittest test_api.py
This project is licensed under the Apache License 2.0. See the LICENSE file for details.
For any inquiries, please contact [email protected].