Aim: AI-driven object detection via FastAPI (on COCO image dataset)
Machine learning models:
- ultralytics/yolo11n
- ultralytics/yolo11s
- Local development
- Execution via docker container
- Deployment on Docker hub
- MLOps pipeline via GitHub actions
Command line in development mode:
fastapi dev app/main.py
Manual command line in production:
fastapi run app/main.py
Notes:
- Serving at: http://127.0.0.1:8000
- API docs: http://127.0.0.1:8000/docs
Command lines:
- Endpoint "/":
curl -X 'GET' -H 'accept: application/json' 'http://127.0.0.1:8000/'
- Endpoint "/info":
curl -X 'GET' -H 'accept: application/json' 'http://127.0.0.1:8000/info'
- Endpoint "/api/v1/detect":
curl -X POST -F "image=@./tests/data/savanna.jpg" http://127.0.0.1:8000/api/v1/detect
- Endpoint "/api/v1/detect" with optional model type (e.g. yolo11n or yolo11s):
curl -X POST -F "image=@./tests/data/savanna.jpg" http://127.0.0.1:8000/api/v1/detect?model=yolo11n
Command line:
python app/inference_api.py -u "http://127.0.0.1:8000/api/v1/detect" -f tests/data/savanna.jpg
Command lines:
pytest tests/ -v
pytest tests/ -s -o log_cli=true -o log_level=DEBUG
Command lines:
sudo docker build -t object-detection-yolo-fastapi .
sudo docker run --name object-detection-yolo-fastapi-cont -p 8000:8000 object-detection-yolo-fastapi
Command lines:
- Endpoint "/":
curl -X 'GET' 'http://0.0.0.0:8000/' -H 'accept: application/json'
- Endpoint "/info":
curl -X 'GET' -H 'accept: application/json' 'http://0.0.0.0:8000/info'
- Endpoint "/api/v1/detect":
curl -X 'POST' -F "image=@./tests/data/savanna.jpg" http://0.0.0.0:8000/api/v1/detect
- Endpoint "/api/v1/detect" with optional model type (e.g. yolo11n or yolo11s):
curl -X 'POST' -F "image=@./tests/data/savanna.jpg" http://0.0.0.0:8000/api/v1/detect\?model=yolo11s
This FastAPI application is available as a Docker container on Docker hub
URL: https://hub.docker.com/r/cvachet/object-detection-yolo-fastapi
Github actions were created to enable Continuous Integration (CI) and Continuous Deployment (CD) for this FastAPI app.
YAML files:
- Python testing suite: ci_python.yml
- Pushing to docker: publish_docker_image.yml