This is a FastAPI application that provides an API endpoint for classifying dog breeds from uploaded images using a pre-trained FastAI model.
- Accepts image uploads in PNG, JPG, or JPEG format
- Validates and processes the uploaded image
- Returns the top 3 predicted dog breeds and their probabilities
- Python 3.7 or higher
- FastAI
- Pillow
- Clone the repository:
git clone https://github.com/your-repo/dog-breed-classifier.git
- Install the required packages:
pip install -r requirements.txt
- Start the FastAPI server:
uvicorn api.main:app --reload # If django project is running, use `uvicorn api.main:app --reload --port 8001` or any port of your choice
- The API will be available at
http://localhost:8000 # Or the port you set
- To check if the API is running, send a GET request to the root endpoint:
GET http://localhost:8000/
- To classify a dog breed from an image, send a POST request to the
/predict
endpoint with the image file:
POST http://localhost:8000/predict
Content-Type: multipart/form-data
file: <image_file>
The API will return a JSON response with the top 3 predicted dog breeds and their probabilities:
{
"prediction": {
"breed1": 95,
"breed2": 3,
"breed3": 2
}
}