PlantVillage Leaf-Disease Classifier (ViT)
Fine-tuned google/vit-base-patch16-224-in21k on PlantVillage (38 crop-disease
classes across 14 crop species). Built as the local screening option for
DakiKobo, a French-language
agricultural advisor for smallholder farmers in Burkina Faso, with the Gemini Vision
API retained as fallback for crops this model does not cover.
Evaluation
Held-out test split, not seen during training.
Split provenance: training used a parquet mirror
(BrandonFors/Plant-Diseases-PlantVillage-Dataset), whose 43,456 / 10,849 partition
differs from the original leaf-grouped 43,596 / 10,709 split. The mirror does not
expose leaf_id, so leaf grouping could not be verified or reconstructed.
PlantVillage contains multiple photographs of the same physical leaf, so images of
one leaf may appear on both sides of this split. The figures below are therefore
likely optimistic relative to a leaf-grouped evaluation.
| Metric | All 38 classes | Maize only (n=769) |
|---|---|---|
| Accuracy | 0.9979 | 0.9844 |
| F1 (macro) | 0.9960 | 0.9785 |
Per-class precision, recall, and F1: per_class_report.csv in this repo.
The overall figure should be read in context. Published PlantVillage accuracies have run 99.3 to 99.8 percent since Mohanty et al. (2016); a high number here reflects the dataset, not the method. The maize column is reported separately because maize is the only crop shared between this dataset and DakiKobo's users.
Limits
-
Routing threshold 0.95 was measured on held-out maize predictions, not guessed. It rejects 10 of 12 observed errors at the cost of routing 6.2% of maize cases to the fallback API. Two errors still pass, both gray leaf spot / northern leaf blight confusions above the threshold.
-
Possible train/test leakage. See split provenance above. Not quantified.
-
Crop coverage does not match the deployment context. PlantVillage covers apple, blueberry, cherry, corn, grape, orange, peach, bell pepper, potato, raspberry, soybean, squash, strawberry, tomato. DakiKobo's users grow millet, sorghum, maize, cowpea, and groundnut. Only maize overlaps. On the other four crops this model will return a confident label from a class set that cannot contain the right answer. It is routed accordingly in the application: covered crops only, Gemini otherwise.
-
Capture conditions differ from field use. PlantVillage leaves were detached, placed on a grey or black background, and photographed with a single camera under controlled outdoor light. Models trained on it partly learn background and capture conditions. See "Uncovering bias in the PlantVillage dataset" (arXiv:2206.04374). Accuracy on phone photographs of attached leaves in a field has not been measured here and should be assumed lower.
-
No unknown class. Out-of-distribution input is assigned one of the 38 known classes with a confidence score, not flagged as unrecognized.
-
Single training run, no seed variance study, no hyperparameter search.
-
The dominant failure mode is on the crop that matters. Maize error rate is 1.56% against 0.21% overall, roughly 7x. Maize is 7% of the test set but about half of all errors. Effectively every maize error is one bidirectional confusion: Cercospora gray leaf spot vs northern leaf blight (F1 0.947 and 0.969, the two lowest of 38 classes). Both are real maize diseases with different management responses, so this confusion is consequential rather than cosmetic.
Use
from transformers import pipeline
clf = pipeline("image-classification", model="kimcomehome/plantvillage-vit-leaf-disease")
clf("leaf.jpg")
Citation
Mohanty, S.P., Hughes, D.P., Salathe, M. (2016). Using deep learning for image-based plant disease detection. Frontiers in Plant Science 7:1419.