This section an example implementation of a YOLO Server API, designed to facilitate object detection using the YOLO model. This guide provides information on how to use, configure, and understand the features of this API.
-
Run the server:
python app.py
or
gunicorn -w 1 -b 0.0.0.0:8000 "examples.object_detection_server_api.app:app"
-
Send a request to the API:
- Use tools like
curl
, Postman, or your web browser to send a request to the server. - Example using
curl
:curl -X POST -F "file=@path/to/your/image.jpg" http://localhost:8000/detect
- Use tools like
- Authentication: Secure the API with authentication mechanisms.
- Caching: Improve performance with caching of detection results.
- Model Download: Automated downloading and loading of the YOLO model.
- Configuration: Flexible configuration options to customise the API.
- Object Detection: Perform object detection on uploaded images using YOLO.
- Error Handling: Robust error handling to manage different scenarios gracefully.
The API can be configured through the config.py
file. Below are some of the key configuration options available:
-
Server Settings:
HOST
: The hostname to run the server on. Default is0.0.0.0
.PORT
: The port to run the server on. Default is8000
.
-
Model Settings:
MODEL_PATH
: Path to the YOLO model file.CONFIDENCE_THRESHOLD
: Confidence threshold for object detection.
-
Cache Settings:
CACHE_ENABLED
: Enable or disable caching. Default isTrue
.CACHE_EXPIRY
: Cache expiry time in seconds. Default is3600
.
-
Authentication Settings:
AUTH_ENABLED
: Enable or disable authentication. Default isTrue
.SECRET_KEY
: Secret key for JWT authentication.
- app.py: Main application file that starts the server and defines the API endpoints.
- auth.py: Handles authentication mechanisms.
- cache.py: Implements caching functionalities.
- config.py: Contains configuration settings for the API.
- detection.py: Performs object detection using the YOLO model.
- model_downloader.py: Handles downloading and loading of the YOLO model.
- models.py: Defines data models and schemas.
- security.py: Implements security features.
Ensure to review and adjust the configuration settings in config.py
to suit your specific requirements.