To run the FastAPI application locally, use the following command:
make run
This will start the server at http://127.0.0.1:8000.
To send an image for prediction, you can use the following curl command:
make send-image
This command will POST the image located at test_images/dog.png
to the /predict/
endpoint of the API. Make sure to replace the path with the image you want to test.
If you prefer to run the application in a Docker container, you can use the following commands:
To build the Docker image, run:
make docker-build
To run the Docker container, use:
make docker-run
This will start the container and expose the application on port 8000.
POST /predict/: Upload an image and receive the predicted class.
curl -X POST 'http://127.0.0.1:8000/predict/' -H 'accept: application/json' -H 'Content-Type: multipart/form-data' -F 'file=@test_images/dog.png'
The response will include the predicted class in JSON format:
{
"predicted_class": "your_class_name"
}