ChatGPT Image May 31, 2026, 06_27_00 PM

A fine-tuned ResNet50 model that classifies rice leaf diseases from photos, exported to ONNX for fast CPU inference. Built to power a Telegram bot that delivers treatment advice in Bangla for Bangladeshi farmers.


Model Details

Property Value
Architecture ResNet50 (fine-tuned)
Format ONNX
Input RGB image, 224×224
Output 4-class softmax
Best Val Accuracy 98.47%
Inference CPU (ONNX Runtime)

Classes

Index Class Bangla
0 Bacterial_Leaf_Blight ব্যাকটেরিয়াল লিফ ব্লাইট
1 Brown_Spot ব্রাউন স্পট
2 Leaf_Blast লিফ ব্লাস্ট
3 Tungro টুংরো

Performance

Per-Class Accuracy on Test Set

Class Accuracy
Bacterial Leaf Blight 98.5%
Brown Spot 97.0%
Leaf Blast 95.5%
Tungro 100.0%

Confusion Matrix (Normalized)

Confusion Matrix and Per-Class Accuracy

Training Curve

ResNet50 trained for 45 epochs with best validation accuracy of 98.47%.

Training Curve


Dataset

Merged from two publicly available sources:

Source Link
Rice Leaf Bacterial and Fungal Disease Dataset (Hasan et al., 2023) Mendeley Data
Rice Leaf Disease Image Kaggle / Nirmal Sankalana
Class Total Images
Bacterial_Leaf_Blight 1,308
Brown Spot 1,308
Leaf_Blast 1,308
Tungro 1,308
Total 5,232

Balanced: All classes were downsampled to 1,308 images (the size of the smallest class, Tungro) to prevent class imbalance during training.

Dataset Distribution

Sample Images

Sample Images


Usage

import onnxruntime as ort
import numpy as np
from PIL import Image

# Load model
session = ort.InferenceSession("model.onnx")

class_names = [
    "Bacterial_Leaf_Blight",
    "Brown_Spot",
    "Leaf_Blast",
    "Tungro"
]

def preprocess(image_path):
    img = Image.open(image_path).convert("RGB").resize((224, 224))
    img = np.array(img, dtype=np.float32) / 255.0
    img = (img - [0.485, 0.456, 0.406]) / [0.229, 0.224, 0.225]
    return img.transpose(2, 0, 1)[np.newaxis].astype(np.float32)

def predict(image_path):
    input_tensor = preprocess(image_path)
    outputs = session.run(None, {"input": input_tensor})
    probs = outputs[0][0]
    idx = np.argmax(probs)
    return class_names[idx], float(probs[idx])

label, confidence = predict("rice_leaf.jpg")
print(f"{label} ({confidence:.1%} confidence)")

Telegram Bot

This model powers a Telegram bot that lets farmers send a photo of a diseased rice leaf and receive instant diagnosis and treatment advice in Bangla.

🔗 Try the bot →
🌐 Project demo page →
💻 Source code →


Citation

If you use this model, please cite:

@misc{rice-leaf-disease-classifier,
  author = {nihal4},
  title  = {Rice Leaf Disease Classifier},
  year   = {2026},
  url    = {https://huggingface.co/nihal4/rice-leaf-disease-classifier}
}

Made with ♥ for Bangladeshi rice farmers

Dataset Citations

If you use the training data, please cite the original sources:

Mendeley Data (Bangladesh dataset):

Hasan, Mehedi; Khatun, Sonia; Raihan, Md. Abu; Uddin, Abdul Hasib (2023),
"Rice Leaf Bacterial and Fungal Disease Dataset",
Mendeley Data, V2, doi: 10.17632/hx6f852hw4.2

Kaggle (Nirmal dataset):

Nirmal Sankalana, "Rice Leaf Disease Image", Kaggle. https://www.kaggle.com/datasets/nirmalsankalana/rice-leaf-disease-image

Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for nihal4/rice-disease-model

Quantized
(9)
this model