Downloads · 30 days
0
BiernyVR/crop-disease-classifier
crop-disease-classifier is a image classification model from BiernyVR. Use it when you need a label for an image. It is set up for pytorch. The card lists the license as mit.
A production-ready EfficientNetV2-S model fine-tuned on the PlantVillage benchmark (54,306 images across 38 disease & healthy categories spanning 14 crop species).
Downloads · 30 days
0
Access
Public
Updated Sep 14, 2026
Repo size
165 MB
Likes
0
Public
Click a slice to open those files.
.pth81.8 MB · 49%
From the Hugging Face model README
A production-ready EfficientNetV2-S model fine-tuned on the PlantVillage benchmark (54,306 images across 38 disease & healthy categories spanning 14 crop species).
Achieves 99.89% validation accuracy with sub-4ms GPU inference latency and includes Grad-CAM explainability and ONNX edge deployment weights.
| Model | Val Accuracy | Macro F1 | Latency (RTX 5080) | Parameters | Format |
|---|---|---|---|---|---|
| EfficientNetV2-S (Ours) | 99.89% | ~0.999 | ~3.9 ms | 21.5M | PyTorch + ONNX |
| ResNet50 (Baseline) | 97.10% | 0.969 | ~3.8 ms | 25.6M | PyTorch |
Trained on NVIDIA GeForce RTX 5080 (CUDA 13.2, SM_120) with cosine learning rate schedule, AdamW optimizer, label smoothing 0.1, batch size 64.
The model detects specific pathologies as well as healthy leaves across 14 agricultural crop species:
In agriculture, black-box predictions are not enough — agronomists and farmers need to know where the model detected symptoms. The model's activations align precisely with pathological lesions, rust pustules, and necrosis spots rather than background artifacts.
pip install onnxruntime pillow numpy huggingface_hub
import json
import numpy as np
from PIL import Image
import onnxruntime as ort
from huggingface_hub import hf_hub_download
# Download model & classes
onnx_model = hf_hub_download(repo_id="BiernyVR/crop-disease-classifier", filename="efficientnet_v2_s_best.onnx")
onnx_data = hf_hub_download(repo_id="BiernyVR/crop-disease-classifier", filename="efficientnet_v2_s_best.onnx.data")
classes_file = hf_hub_download(repo_id="BiernyVR/crop-disease-classifier", filename="classes.json")
with open(classes_file, "r") as f:
classes = json.load(f)["classes"]
# Preprocess image
img = Image.open("leaf.jpg").convert("RGB").resize((224, 224), Image.Resampling.BILINEAR)
arr = (np.array(img, dtype=np.float32) / 255.0 - [0.485, 0.456, 0.406]) / [0.229, 0.224, 0.225]
tensor = np.expand_dims(np.transpose(arr, (2, 0, 1)), axis=0).astype(np.float32)
# Run inference
session = ort.InferenceSession(onnx_model, providers=["CPUExecutionProvider"])
logits = session.run(None, {"input": tensor})[0][0]
probs = np.exp(logits - np.max(logits))
probs /= probs.sum()
top_class = classes[np.argmax(probs)]
print(f"Prediction: {top_class} ({np.max(probs)*100:.2f}%)")
python infer.py --image sample_leaf.jpg --topk 3
efficientnet_v2_s_best.pth: Full PyTorch model checkpoint.efficientnet_v2_s_best.onnx + .onnx.data: ONNX exported weights for TensorRT / mobile / ONNX Runtime.classes.json: Complete mapping of 38 disease and healthy classes.sample_leaf.jpg: Test apple scab sample leaf image.sample_gradcam.png: Grad-CAM visualization output.infer.py: Self-contained evaluation script.confusion_matrix.png, training_curves.png, per_class_accuracy.png: Evaluation and training metrics plots.