Flask inference API for a custom CNN that classifies apple leaf diseases across 4 classes from the PlantVillage dataset. Accepts an image, runs it through a Keras .h5 model, and returns the predicted class with per-class confidence scores.
Frontend repo: cnn-frontend
Live demo: app-dlite-net.vercel.app
| Property | Value |
|---|---|
| Architecture | Custom CNN (built from scratch) |
| Dataset | PlantVillage |
| Classes | 4 (diseases + healthy) |
| Accuracy | 99.16% on test set |
| Model size | 8 MB (.h5) |
| Framework | TensorFlow / Keras |
Accepts a leaf image and returns the top predicted class with confidence scores.
Request
Content-Type: multipart/form-data
Body: image (file)
Response
{
"predicted_class": "Apple___Apple_scab",
"confidence": 0.9812,
"all_scores": {
"Apple___Apple_scab": 0.9812,
"Apple___Black_rot": 0.0103,
...
}
}Returns 200 OK if the service is running and the model is loaded.
Prerequisites: Python 3.8+, pip
git clone https://github.com/Somansh1/cnn-backend.git
cd cnn-backend
pip install -r requirements.txtPlace your trained model file in the project root (or update the path in app.py):
cnn-backend/
├── app.py
├── model.h5 # ← your trained Keras model
├── requirements.txt
├── Procfile
└── scripts/
python app.py # starts on http://localhost:5000Configured for Heroku via Procfile:
heroku create your-app-name
git push heroku mainThe scripts/ directory contains shell helpers for environment setup.
- Frontend: React app with image upload and confidence score display — cnn-frontend
- Training notebook: Available on request
MIT