(You can work in pairs, if you want to.)
Your task is to create an inference Web API that checks if an image contains a cat.
This starting project already provides the ML functionality for this (src/CatPredictor.py
), namely a class that uses two pretrained models from the ImageNet family (VGG16 and MobileNet).
You can see an example of its usage in src/usage-example.py
.
An advanced skeleton for the API you should build is provided based on the Flask framework in src/prediction-api.py
.
You can use the HTTP client of your choice to test it, e.g., Postman or curl.
Once your API is ready, encapsulate it into a Docker image, and build and run a container with it.
Bonus task if you are quick: change your client project from last tutorial to use your newly created API instead of the Google Cloud Vision API for identifying all cats from the image set.
- Install Python 3, preferably >= 3.9
- Install dependencies:
pip install -r requirements.txt
- Install Docker Desktop (for the container part)
# using the prediction example (you can change the used filename to a different file under `images`)
python src/usage-example.py
# using the REST API
# set an ENV variable for the Flask entrypoint file
export FLASK_APP=src/prediction-api.py
# start the API --> API offers the endpoint `POST http://localhost:5000/cat-predictions`
flask run
# for enabling hot reload (execute before starting)
export FLASK_ENV=development