A efficientnetb0 (4.0M params) fine-tuned to classify 17 rice leaf conditions from RGB leaf photographs.
Source du modèle
Description de la source
A efficientnet_b0 (4.0M params) fine-tuned to classify 17 rice leaf conditions
from RGB leaf photographs.
Sources
1 sourceVérifié 1 août
Artefacts du modèle
2 artefactsExtraits de sources
2 extraits| Metric | Score |
|---|
| Accuracy | 0.9709 |
| Macro-F1 | 0.9473 |
Macro-F1 is the primary metric: the data is long-tailed, so accuracy is dominated by the head classes and overstates real performance.
Measured with timm's canonical inference transform (224px, crop_pct=0.875, bicubic)
— i.e. the exact preprocessing produced by the Usage snippet below, so these numbers are
reproducible from a fresh hf-hub: load rather than tied to the training script.
| Class | Precision | Recall | F1 | Support |
|---|---|---|---|---|
| Bacterial Blight | 0.981 | 0.984 | 0.983 | 579 |
| Bacterial Streak | 0.812 | 0.867 | 0.839 | 15 |
| Bakanae | 1.000 | 1.000 | 1.000 | 15 |
| Brown Spot | 0.972 | 0.976 | 0.974 | 632 |
| False Smut | 1.000 | 0.933 | 0.966 | 15 |
| Grassy Stunt Virus | 0.933 | 0.933 |
Research and educational use for rice disease triage from leaf images. Not a substitute for agronomist diagnosis. Predictions on out-of-distribution imagery (other crops, other capture conditions) are unreliable.
Derived from the Rice Leaf Disease Images dataset (~29.4k images, 18 folders). The raw data needed substantial cleaning before it was usable:
Leaf Smut class entirely. 1,460 of its 1,500 files were named
BLAST*, derived from ~160 base images augmented 9x, and show blast lesions rather
than smut. Several were byte-identical to files in Leaf Blast, so the two labels
directly contradicted each other. Only 40 images looked like genuine leaf smut —
too few to learn or evaluate. This leaves 17 classes.BLAST1_074/BLAST5_074; brownspot_orig_001/brownspot_rotated_001). Splitting
these at random would place augmented copies of the same leaf in both train and test.
Images were grouped by base identity and split by group, so no leaf appears in more
than one split. Final: 18601 train / 3984 val / 3984 test (70/15/15),
verified zero group overlap.These numbers therefore describe generalisation to unseen leaves, not to unseen crops of leaves already memorised. Note that accuracy stayed high (0.971) even after the leakage was removed, so the split cleanup alone does not explain the ~98% figures often quoted for this dataset — the head classes are simply easy, and the lab/field confound below is the more likely driver. Macro-F1 (0.947) is the more informative number.
efficientnet_b0 (ImageNet-pretrained, via timm)The data is long-tailed, so class-weighted loss is the obvious reflex. It did not help.
Weights proportional to (1/freq)^alpha were ablated, selecting on validation
macro-F1 (test was not consulted for this choice):
alpha | val macro-F1 | test macro-F1 | test acc |
|---|---|---|---|
| 0.0 (used) | 0.9609 | 0.9473 | 0.9709 |
| 0.5 | 0.9587 | 0.9536 | 0.9694 |
| 1.0 | 0.8683 | 0.8694 | 0.9443 |
Full inverse-frequency weighting (alpha=1) gives the rarest class ~60x the weight of
the most common one. The model then over-predicts rare classes — recall near 1.0 at
~0.1 precision after one epoch — and macro-F1 drops sharply. Unweighted loss won on
validation, so it is what ships.
Caveat: alpha=0.0 and alpha=0.5 are close, and the gap sits within the noise floor
of the rare classes — with 14-15 test images each, a single image moves a class F1 by
~0.07. The alpha=1 result is the only clearly separated one. Read the 0.0-vs-0.5
ordering as a coin-flip, not a finding.
import timm, torch
from PIL import Image
model = timm.create_model("hf-hub:Huyt/rice-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):
['Bacterial Blight', 'Bacterial Streak', 'Bakanae', 'Brown Spot', 'False Smut', 'Grassy Stunt Virus', 'Healthy', 'Hispa', 'Leaf Blast', 'Leaf Scald', 'Narrow Brown Spot', 'Neck Blast', 'Ragged Stunt Virus', 'Sheath Blight', 'Sheath Rot', 'Stem Rot', 'Tungro']
Leaf Smut was the clearest labelling failure, but the
other classes were not audited image-by-image and may contain similar errors.--- license: apache-2.0 tags: - image-classification - agriculture - plant-disease - rice - timm library_name: timm pipeline_tag: image-classification metrics: - accuracy - f1 --- # Rice Leaf Disease Classification — efficientnet_b0 A `efficientnet_b0` (4.0M params) fine-tuned to classify 17 rice leaf conditions from RGB leaf photographs. ## Results (held-out test set, n=3984) | Metric | Score | |---|---| | Accuracy | **0.9709** | | Macro-F1 | **0.9473** | Macro-F1 is the primary metric: the data is long-tailed, so accuracy is dominated by the head classes and overstates real performance. Measured with `timm`'s canonical inference transform (224px, `crop_pct=0.875`, bicubic) — i.e. the exact preprocessing produced by the Usage snippet below, so these numbers are reproducible from a fresh `hf-hub:` load rather than tied to the training script. ### Per-class F1 | Class | Precision | Recall | F1 | Support | |---|---|---|---|---| | Bacterial Blight | 0.981 | 0.984 | **0.983** | 579 | | Bacterial Streak | 0.812 | 0.867 | **0.839** | 15 | | Bakanae | 1.000 | 1.000 | **1.000** | 15 | | Brown Spot | 0.972 | 0.976 | **0.974** | 632 | | False Smut | 1.000 | 0.933 | **0.966** | 15 | | Grassy Stunt Virus | 0.933 | 0.933 | **0.933** | 15 | | Healthy | 0.942 | 0.952 | **0.947** | 442 | | Hispa | 0.924 | 0.913 | **0.918** | 333 | | Leaf Blast | 0.954 | 0.961 | **0.957** | 513 | | Leaf Scald | 0.990 | 0.992 | **0.991** | 385 | | Narrow Brown Spot | 0.989 | 0.989 | **0.989** | 269 | | Neck Blast | 1.000 | 1.000 | **1.000** | 150 | | Ragged Stunt Virus | 0.933 | 0.933 | **0.933** | 15 | | Sheath Blight | 1.000 | 0.957 | **0.978** | 93 | | Sheath Rot | 1.000 | 0.533 | **0.696** | 15 | | Stem Rot | 1.000 | 1.000 | **1.000** | 15 | | Tungro | 1.000 | 1.000 | **1.000** | 483 | ## Intended use Research and educational use for rice disease triage from leaf images. **Not** a substitute for agronomist diagnosis. Predictions on out-of-distribution imagery (other crops, other capture conditions) are unreliable. ## Training data Derived from the *Rice Leaf Disease Images* dataset (~29.4k images, 18 folders). The raw data needed substantial cleaning before it was usable: - **Dropped the `Leaf Smut` class entirely.** 1,460 of its 1,500 files were named `BLAST*`, derived from ~160 base images augmented 9x, and show blast lesions rather than smut. Several were byte-identic...
Source context: 156 downloads · 0 likes · Pipeline image-classification · Library timm · Repo Huyt/rice-leaf-disease-efficientnet-b0
| 0.933 |
| 15 |
| Healthy | 0.942 | 0.952 | 0.947 | 442 |
| Hispa | 0.924 | 0.913 | 0.918 | 333 |
| Leaf Blast | 0.954 | 0.961 | 0.957 | 513 |
| Leaf Scald | 0.990 | 0.992 | 0.991 | 385 |
| Narrow Brown Spot | 0.989 | 0.989 | 0.989 | 269 |
| Neck Blast | 1.000 | 1.000 | 1.000 | 150 |
| Ragged Stunt Virus | 0.933 | 0.933 | 0.933 | 15 |
| Sheath Blight | 1.000 | 0.957 | 0.978 | 93 |
| Sheath Rot | 1.000 | 0.533 | 0.696 | 15 |
| Stem Rot | 1.000 | 1.000 | 1.000 | 15 |
| Tungro | 1.000 | 1.000 | 1.000 | 483 |