Takes an image as input and returns metadata (JSON), extracted from the image
- 1.0.0 First release.
python3 -m venv .venv
- activate venv via:
source .venv/bin/activate
pip install -r requirements-dev.txt
- enjoy!
- activate venv via:
source .venv/bin/activate
- Run
python3 -m pytest
into project-root.
This will trigger unit tests and a simple Demo that:
- Uses test image data from tests/input folder
- calls in memory endpoint for prediction making
- print the desired metadata results.
uvicorn app.main:app
docker build -t objectdetector
docker run: docker run -v /tmp/output:/tmp/output -p 5000:5000 -e APP_PORT=5000 -e APP_HOST=0.0.0.0 -e OUTPUT_DIR=/tmp/output -d
OR
docker compose: docker-compose up --build -d
- APP_PORT: it enables custom port for deployment by overriding it. Default 8000 .
- APP_HOST: it enables custom host for deployment by overriding it. Default 0.0.0.0 .
- OUTPUT_DIR: it enables custom output dir by overriding it. Default /tmp/output. Note: it may be required to previously create folder on host filesystem, depending on your OS.
These variables are already configured both in above docker run command and docker-compose.
Default App configuration is located under config/config.json. It would be possibile to change configuration path by overriding env variable CONFIG_PATH
.
In configuration, it is possibile to change parameter related to:
- confidence: decision threshold on prediction. Predictions which score is less than the threshold are filtered out.
- model: you can choice betweet 3 different models at the moment ("frcnn-resnet", "frcnn-mobilenet", "retinanet")
The demo script works as the following:
- Lookups for APP_HOST and APP_PORT variables. If not defined, they assume default values of (0.0.0.0, 5000).
- start docker service at the specified address (logged in console).
- Waits 20 seconds for service startup / model downloading (second time can be faster, SO PLEASE ADJUST SLEEP ACCORDINGLY).
- performs a prediction request for every file comprised in ./tests/input folder.
- Outputs filename, extracted metadata and time to perform the request.
- Check $OUTPUT_DIR folder for annotated images.
Extract OpenApi 3.0 json definition by calling http://$HOST:$PORT/openapi.json
Access SwaggerUI by calling http://$HOST:$PORT/docs