Downloads · 30 days
60
18% of all-time downloads
Huyt/arabica-coffee-leaf-disease-efficientnet-b0
arabica-coffee-leaf-disease-efficientnet-b0 is a image classification model from Huyt. Use it when you need a label for an image. It is set up for timm. The card lists the license as cc-by-4.0.
A efficientnetb0 (4.0M params) fine-tuned to classify 5 arabica coffee leaf conditions from close-up RGB crops.
Downloads · 30 days
60
18% of all-time downloads
All-time downloads
325
Public
Parameters
4.1M
32.6 MB on disk
Likes
2
Public
Click a slice to open those files.
.bin16.3 MB · 50%
From the Hugging Face model README
A efficientnet_b0 (4.0M params) fine-tuned to classify 5 arabica coffee leaf
conditions from close-up RGB crops.
The source dataset lists 58,549 images. It contains 3,756 unique images
— 93.6% of the rows are exact byte-for-byte duplicates. One Healthy image
appears 520 times. After also grouping near-duplicate crops of the same leaf
(perceptual hash, hamming <= 5), only 2,891 independent images remain.
Class counts collapse dramatically, and the balance inverts — Healthy is the largest
class as listed and the smallest in reality:
| Class | Listed rows | Byte-unique | Independent groups |
|---|---|---|---|
| Cerscospora | 7,681 | 322 | 317 |
| Healthy | 18,983 | 62 | 48 |
| Leaf_rust | 8,336 | 1,042 | 918 |
| Miner | 16,978 | 1,639 | 923 |
| Phoma | 6,571 | 691 | 685 |
| TOTAL | 58,549 | 3,756 | 2,891 |
This model is trained and evaluated on the deduplicated, group-disjoint data, so no near-duplicate crop appears in more than one split.
The obvious expectation is that removing this much duplication should crater the score. It does not — and reporting that honestly matters more than a tidy story:
| Split protocol | n train | Test accuracy | Test macro-F1 |
|---|---|---|---|
| Naive random split over all 58,549 rows (leaky) | 40,981 | 1.0000 | 1.0000 |
| Group-aware split over 2,891 independent images (honest) | 2,628 | 0.9911 | 0.9941 |
The leaky protocol buys only +0.0089 accuracy / +0.0059 macro-F1. So on this dataset the duplication inflates the apparent size (58,549 vs ~2,891 real images) far more than it inflates the score. These five classes are simply easy to separate: a model trained on 2,628 images with no duplicate leakage still reaches 99.11%.
Do not read this as "leakage is harmless" in general — it is a property of this dataset's easy class boundaries. Read it as: this dataset is ~20x smaller than its row count suggests, and its headline accuracies are not evidence of much.
| Metric | Score |
|---|---|
| Accuracy | 0.9911 |
| Macro-F1 | 0.9941 |
Measured with timm's canonical inference transform (224px, crop_pct=0.875, bicubic),
i.e. exactly the preprocessing the Usage snippet produces.
| Class | Precision | Recall | F1 | Test support | Train images |
|---|---|---|---|---|---|
| Cerscospora | 1.000 | 1.000 | 1.000 | 48 | 226 |
| Healthy | 1.000 | 1.000 | 1.000 | 9 | 43 |
| Leaf_rust | 1.000 | 0.981 | 0.990 | 156 | 729 |
| Miner | 0.980 | 1.000 | 0.990 | 246 | 1147 |
| Phoma | 1.000 | 0.981 | 0.990 | 105 | 483 |
Research and educational use only. Not a substitute for agronomist diagnosis. The
Healthy class is supported by only 43 training images from
48 independent sources — treat its predictions with particular suspicion.
efficientnet_b0 (ImageNet-pretrained, via timm)import timm, torch
from PIL import Image
model = timm.create_model("hf-hub:Huyt/arabica-coffee-leaf-disease-efficientnet-b0", pretrained=True).eval()
cfg = timm.data.resolve_data_config({}, model=model)
tf = timm.data.create_transform(**cfg)
img = Image.open("leaf.jpg").convert("RGB")
with torch.no_grad():
probs = model(tf(img).unsqueeze(0)).softmax(-1)[0]
idx = int(probs.argmax())
print(model.pretrained_cfg["label_names"][idx], float(probs[idx]))
Class order (index -> label):
['Cerscospora', 'Healthy', 'Leaf_rust', 'Miner', 'Phoma']
Healthy is critically under-supported: 48 independent images total.
Its metrics rest on 9 test images and are not trustworthy.coffee_dedup.py (hashing + grouping), coffee_split.py (both splits),
coffee_train.py (training), coffee_eval_final.py (canonical-transform eval) are
included in this repo.
@article{jepkoech2021arabica,
title={Arabica coffee leaf images dataset for coffee leaf disease detection and classification},
author={Jepkoech, Jennifer and Mugo, David Muchangi and Kenduiywo, Benson K and Too, Edna Chebet},
journal={Data in brief}, volume={36}, pages={107142}, year={2021}, publisher={Elsevier}
}