Objective
Catch coffee leaf diseases early, accepting false alarms over missed infections.
Classifies leaf images into five classes (healthy, Cercospora, Leaf Rust, Miner, Phoma), comparing VGG16, EfficientNetB0 and a custom CNN with runs tracked in MLflow.
Challenges
- 01Visually similar diseases in an imbalanced dataset
- 02A missed disease costs more than a false alarm
- 03Aggressive augmentation can erase the color cues that identify a disease
How it was solved
- 01Class weights from the train distribution, with a boost for the rarest disease
- 02Custom disease-recall metric that excludes the healthy class, monitored during training
- 03Horizontal flips and subtle brightness/contrast only; hue and saturation untouched
Results
- No diseased test leaf was classified as healthy
Overview
Classifies a coffee leaf photo as healthy or as one of four diseases.
Technical Implementation
Models
VGG16 and EfficientNetB0 with ImageNet weights, plus a lightweight custom CNN. Training runs in two phases, frozen base then fine-tuning, with dropout, early stopping and a learning rate chosen by dataset size. The loader detects the architecture from the saved model’s layers.
Data
Images are letterboxed to 224x224 and split per class into train, validation and test sets.
Serving
FastAPI validates the image format, runs inference on a cached model and returns the top class plus every class probability. The API ships as a Docker image; trained models are uploaded to Google Cloud Storage.
Features
- Image upload endpoint and health check that reports whether the model is loaded
- Separate Streamlit app for upload and prediction
- Evaluation with confusion matrix and false-negative analysis
- Train, evaluate and predict commands through Make targets
Technologies
- TensorFlow/Keras
- VGG16
- EfficientNetB0
- FastAPI
- Streamlit
- MLflow
- Docker
- Google Cloud Storage
- Python
