A 97% model is useless on a phone in a field. So I taught a small one to think like it.
A dual-branch, lesion-aware Inception teacher guided by U-Net mask proposals, distilled into a MobileNetV3 student and quantized to INT8 — with Grad-CAM used to confirm it looks at the disease, not the background.
Three requirements that normally trade off against each other.
Corn leaf disease has to be caught early to matter. That means diagnosis happens in a field, on a cheap device, offline — which rules out the models that are accurate enough to trust.
- Accuracy lives in models too heavy to deploy. Inception V3 and the vision transformers score well and are far too slow for edge inference.
- Background noise is a real failure mode. A model trained on whole photographs can learn soil and lighting instead of pathology, and nobody notices until it meets a new field.
- Compression usually costs the fine-grained cues. Distilling into a mobile-sized student risks losing exactly the lesion detail that made the teacher accurate.
- A confident wrong diagnosis is worse than no diagnosis. A model that can't decline to answer will always answer, including on images it has no business classifying.
Force attention onto the lesion first. Compress second. Add an escape hatch last.
U-Net mask proposals
A lightweight U-Net proposes lesion masks, supervised jointly with the classifier.
Lesion-aware dual branch
One branch sees the raw image, one sees the mask-attenuated image — forcing focus onto pathology, not background.
Multi-teacher ensemble
The LAIC Inception teacher plus DeiT-Small contribute complementary signal.
Distillation into MobileNetV3
Logit distillation, attention transfer, and GAP feature matching compress the teachers into one student.
QAT to INT8 + abstention
Quantization-aware training for edge latency, then temperature scaling and selective prediction validated with risk–coverage analysis.
The student kept the teacher's F1 and shed most of its cost.
| Model | Accuracy | F1 | Note |
|---|---|---|---|
| Inception V3 (LAIC teacher) | 97.12% | 0.970 | Baseline FP32, ~40.1 s/epoch |
| DeiT-Small | 96.18% | 0.96 | Best transformer evaluated |
| ResNet101 | 95.23% | 0.95 | Conventional CNN reference |
| ViT | 93.32% | 0.93 | Underperforms at this dataset size |
| Student MobileNetV3 (FP32) | 97.12% | 0.966 | 18.2 ms CPU |
| Student INT8 (dynamic QAT) | 95.90% | 0.966 | 15.5 ms CPU — shipped |
| Multi-teacher KD (LAIC + DeiT) | 96.16% | 0.951 | Two teachers, more signal, slightly lower F1 |
The FP32 student matches the teacher's accuracy exactly at a fraction of the cost. Quantizing to INT8 trades 1.2 points of accuracy for another 15% latency cut — worth it for offline field use, and the honest tradeoff to state rather than hide.
Grad-CAM confirms the model looks at diseased tissue
Peak activations align consistently with lesion regions rather than background — the check that separates a model that learned pathology from one that learned the photographer's habits.
Stress-tested against the conditions it will actually meet
Evaluated under busy backgrounds, additive Gaussian noise, severe blur, and random rectangular occlusion to measure behaviour under real distribution shift, not just clean test images.
The model is allowed to decline
Temperature scaling plus selective prediction lets it abstain on low-confidence cases, validated with risk–coverage curves and AURC — so ambiguous images route to a human instead of getting a guess.
This one's charts live in the notebook.
Unlike the other two ML projects, this repository ships as a single Jupyter notebook, so the Grad-CAM overlays, reliability diagrams, and risk–coverage curves are generated at run time rather than committed as image files. Export them from the notebook into assets/img/corn/ and they can be dropped into this page in the same gallery format used on the other case studies.