A CNN on the MAKERE University and FGVC Cassava Leaf Datasets with flexibly designed GradCAM heatmap visualizations
# Cassava Leaf Disease Classifier
A fine-tuned EfficientNetB0 classifier for automated cassava leaf disease detection across 5 categories: Cassava Brown Streak Disease (CBSD), Cassava Green Mite (CGM), Cassava Mosaic Disease (CMD), Cassava Bacterial Blight (CBB), and Healthy leaves.
---
## Model Architecture
The base EfficientNetB0 backbone is extended with several components motivated by disease-specific visual characteristics:
**CBAM Attention (Channel + Spatial)**
Inserted before global pooling to focus on diagnostically relevant regions. Channel attention learns which feature maps correspond to disease-specific textures (vein patterns, lesion edges, mosaic patterns). Spatial attention reweights spatial locations, directly addressing the uniform full-image activation observed in baseline GradCAM analysis.
**Generalized Mean Pooling (GeM)**
Replaces standard average pooling with a learnable pooling exponent. Unlike average pooling which weights all spatial locations equally, GeM emphasizes the strongest activations — preserving lesion-specific signal that average pooling would dilute against healthy background tissue.
**Auxiliary Supervision Head**
Attached at the 2/3 depth point of the backbone (MBConv block 5, 112 channels) to encourage mid-level feature discriminability, with a gradual loss weight ramp to avoid destabilizing early training.
**Multi-Sample Dropout**
Five parallel dropout heads (p=0.20 to p=0.40) with averaged logits, applied after BatchNorm normalization to stabilize statistics across dropout masks.
**Projection Head + Supervised Contrastive Loss**
A lightweight MLP projector (1280 → 256 → 128, L2-normalized) produces embeddings for SupCon loss. Inverse-frequency anchor weighting prevents the majority class (CMD, 65% of data) from dominating contrastive gradient updates, improving minority class cluster separation in embedding space.
---
## Augmentation Pipeline
Augmentation is **class-conditional** — transforms are selected based on …