CoolFace
Modelpublic

harinpurumandla/rice-disease-net

sourceHugging Facemitupdated 4mo agoView on Hugging Face
0likes10downloads
Model Card

rice-disease-net

DINOv2-large fine-tuned to classify 15 paddy disease and stress conditions from field photographs. Trained on a deduplicated multi-source dataset of 9,376 images spanning Tamil Nadu, Bangladesh, and laboratory conditions.

Test accuracy: 92.96% · Weighted F1: 0.9288 · 15 classes · 304M parameters

Model Details

PropertyValue
Backbonefacebook/dinov2-large (304M params)
HeadLinear(1024→512, GELU) → Dropout(0.3) → Linear(512→15)
TrainingLinear probe (5 epochs) → Full fine-tune (24 epochs, early stopping)
OptimizerAdamW, head LR 1e-4, backbone LR 1e-5
ScheduleCosine decay with 5-epoch linear warmup
Hardware2× RTX 3090, BF16 mixed precision, accelerate
Input size224×224 RGB
NormalizationDINOv2 standard (mean=[0.485,0.456,0.406], std=[0.229,0.224,0.225])

Input / Output

Input

A single RGB paddy leaf or plant photograph. The model works best on:

  • —Clear images of individual leaves or panicles
  • —Field or laboratory lighting (not heavily shadowed)
  • —Paddy/rice plants (Oryza sativa) only — not validated on other crops
python
from PIL import Image
from transformers import AutoImageProcessor

processor = AutoImageProcessor.from_pretrained("harinpurumandla/rice-disease-net")
image = Image.open("paddy_leaf.jpg").convert("RGB")

# Returns dict with "pixel_values" tensor of shape (1, 3, 224, 224)
inputs = processor(images=image, return_tensors="pt")

Output

Raw logits tensor of shape (batch_size, 15). Higher logit = higher confidence for that class. Apply softmax for probabilities.

python
import torch, json

config = json.load(open("config.json"))
idx_to_class = config["idx_to_class"]

with torch.no_grad():
    logits = model(inputs["pixel_values"])   # (1, 15)
    probs = torch.softmax(logits, dim=1)     # (1, 15)
    pred_idx = probs.argmax(dim=1).item()
    confidence = probs[0, pred_idx].item()

print(f"Predicted: {idx_to_class[str(pred_idx)]}  ({confidence:.1%} confidence)")
# Example: "Predicted: blast  (87.3% confidence)"

Full inference example

python
import json, torch
from PIL import Image
from transformers import AutoImageProcessor

# --- load once at startup ---
import sys
sys.path.insert(0, "path/to/rice-disease-net")
sys.path.insert(0, "path/to/rice-disease-net/train")
from train.model import PaddyClassifier

config = json.load(open("config.json"))
processor = AutoImageProcessor.from_pretrained("harinpurumandla/rice-disease-net")

model = PaddyClassifier(num_classes=15, hidden_dim=512, dropout=0.3)
from safetensors.torch import load_file
model.load_state_dict(load_file("model.safetensors"))
model.eval()

# --- per-image inference ---
def predict(image_path: str) -> dict:
    image = Image.open(image_path).convert("RGB")
    pixel_values = processor(images=image, return_tensors="pt")["pixel_values"]
    with torch.no_grad():
        probs = torch.softmax(model(pixel_values), dim=1)[0]
    idx = probs.argmax().item()
    return {
        "class": config["idx_to_class"][str(idx)],
        "confidence": round(probs[idx].item(), 4),
        "all_probs": {config["idx_to_class"][str(i)]: round(p.item(), 4)
                      for i, p in enumerate(probs)},
    }

result = predict("paddy_leaf.jpg")
print(result)
# {'class': 'blast', 'confidence': 0.8731, 'all_probs': {...}}

Classes

IndexClassDisease / ConditionCausal Agent
0bacterialleafblightBacterial leaf blightXanthomonas oryzae pv. oryzae
1bacterialleafstreakBacterial leaf streakXanthomonas oryzae pv. oryzicola
2bacterialpanicleblightBacterial panicle blightBurkholderia glumae
3blastBlast (leaf + neck)Magnaporthe oryzae
4brown_spotBrown spotBipolaris oryzae
5downy_mildewDowny mildewSclerophthora macrospora
6hispaRice hispaDicladispa armigera
7leaf_rollerRice leaf rollerCnaphalocrocis medinalis
8leaf_scaldLeaf scaldMonographella albescens
9sheath_blightSheath blightRhizoctonia solani
10stem_rotStem rotSclerotium oryzae
11tungroTungroRice tungro spherical + bacilliform virus
12yellowstemborerYellow stem borerScirpophaga incertulas
13normalHealthy plant—
14potassium_deficiencyPotassium deficiency (abiotic)Nutrient stress

Evaluation — In-Domain Test Set (n=938)

Summary Metrics

MetricValue
Top-1 Accuracy92.96%
Weighted F10.9288
Weighted Precision0.9326
Weighted Recall0.9296
Macro F10.9192
Macro Precision0.9361
Macro Recall0.9138
Best class F11.000 (yellowstemborer)
Worst class F10.692 (bacterialleafstreak, n=17)
Weighted metrics weight each class by its test-set support count. Macro metrics treat all 15 classes equally regardless of support.

Per-Class Results

ClassPrecisionRecallF1Support
bacterialleafstreak1.0000.5290.69217
downy_mildew0.7270.8280.77429
blast0.9430.8390.888137
tungro0.8780.9520.91383
brown_spot0.8720.9620.91578
hispa0.9100.9350.922108
bacterialpanicleblight0.9170.9570.93623
bacterialleafblight0.9700.9250.947106
normal0.9240.9650.944113
leaf_scald1.0000.9090.95211
potassium_deficiency0.9520.9760.96441
leaf_roller0.9730.9730.97337
sheath_blight1.0000.9580.97924
stem_rot0.9761.0000.98841
yellowstemborer1.0001.0001.00090

[image]

Limitations and Known Issues

Weak classes:

  • —bacterial_leaf_streak (F1=0.692, support=17): Only 17 test samples; the model is precise when confident but misses ~47% of actual cases. More field data needed.
  • —downy_mildew (F1=0.774): Visually similar to early blast and nutrient deficiency; low precision suggests over-prediction.
  • —blast (F1=0.888, recall=0.839): Leaf blast and neck blast were merged. Some blast images are classified as brown_spot.

Geographic scope: Training data covers Tamil Nadu (Paddy Doctor) and Bangladesh (BRRI). Performance on Telangana, Andhra Pradesh, West Bengal, and Southeast Asian varieties has not been validated. Expect degraded accuracy on field conditions significantly different from the training distribution.

Not a diagnostic tool: Model output should be reviewed by an agronomist before treatment decisions. Abiotic stress (potassium_deficiency) shares visual symptoms with several diseases.

Training Data

SourceClasses UsedImages (kept after dedup)
Paddy Doctor (Kaggle 2022)All 13 original classes~6,600
BRRI Kaggle (valid set)blast, bacterialleafblight, brownspot, hispa, leafscald, sheath_blight, tungro~1,400
Mendeley Rice Disease V1 (2026)bacterialleafblight, leafroller, stemrot, potassium_deficiency~1,400

Total after SHA-256 exact dedup + pHash near-dedup (Hamming ≤ 10): 9,376 images. Split: 80% train / 10% val / 10% test (stratified, frozen test set).

Citations

Backbone:

bibtex
@misc{oquab2023dinov2,
    title={DINOv2: Learning Robust Visual Features without Supervision},
    author={Maxime Oquab and others},
    year={2023},
    eprint={2304.07193},
    archivePrefix={arXiv}
}

Paddy Doctor dataset:

bibtex
@misc{paddy-disease-classification,
    author={Paddy Doctor and Pandarasamy Arjunan (Samy) and Petchiammal},
    title={Paddy Doctor: Paddy Disease Classification},
    year={2022},
    howpublished={\url{https://kaggle.com/competitions/paddy-disease-classification}},
    note={Kaggle}
}

Mendeley dataset: Raki, Nishat Sultana; Bakki, Md. Abdul; Sheikh, Foysal; Pria, Mosa. Nadia Sultana; Parvin, Shahnaj; Matin, Mafiul Hasan (2026), "Rice Disease Image Dataset", Mendeley Data, V1, doi: 10.17632/jw7hp6r5gj.1

BRRI dataset: Attributed to Bangladesh Rice Research Institute (https://brri.gov.bd/). No formal citation provided by dataset authors.