Downloads · 30 days
58
28% of all-time downloads
eymenslimani/plant-disease-detector
plant-disease-detector is a image classification model from eymenslimani. Use it when you need a label for an image. It is set up for pytorch. The card lists the license as mit.
State-of-the-art plant disease detection model achieving 79.86% test accuracy.
Downloads · 30 days
58
28% of all-time downloads
All-time downloads
206
Public
Parameters
53.2M
1.1 GB on disk
Likes
1
Public
Click a slice to open those files.
.pth637 MB · 75%
From the Hugging Face model README
State-of-the-art plant disease detection model achieving 79.86% test accuracy.
| Metric | Score |
|---|---|
| Test Accuracy | 79.86% |
| F1-Score (Macro) | 0.7519 |
| Classes | 28 |
| Training Time | 83.0 min |
import torch
import timm
from PIL import Image
import albumentations as A
from albumentations.pytorch import ToTensorV2
import numpy as np
# Load model
model = timm.create_model(
'tf_efficientnetv2_m.in21k_ft_in1k',
pretrained=False,
num_classes=28
)
checkpoint = torch.load('weights/best_model.pth', map_location='cpu')
model.load_state_dict(checkpoint['model_state_dict'])
model.eval()
# Preprocessing
transform = A.Compose([
A.Resize(256, 256),
A.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225]),
ToTensorV2()
])
# Inference
image = Image.open('leaf.jpg').convert('RGB')
image = transform(image=np.array(image))['image'].unsqueeze(0)
with torch.no_grad():
logits = model(image)
probs = torch.softmax(logits, dim=1)
pred_class = probs.argmax(1).item()
confidence = probs[0, pred_class].item()
class_names = ['Apple_Scab_Leaf', 'Apple_leaf', 'Apple_rust_leaf', 'Bell_pepper_leaf', 'Bell_pepper_leaf_spot'] # ... truncated for README
print(f"Prediction: {class_names[pred_class]} ({confidence:.2%})")
plantdoc_model/
├── weights/
│ ├── model.safetensors # Model weights (preferred)
│ └── best_model.pth # Full checkpoint with metadata
├── plots/
│ ├── training_history.png # Training curves
│ ├── confusion_matrix.png # Confusion matrix
│ └── per_class_metrics.png # Per-class performance
├── logs/
│ └── training.json # Training logs
├── config.json # Model configuration
├── preprocessor_config.json # Preprocessing settings
└── README.md # This file
The model can identify 28 plant disease classes:
@misc{plantdoc_elite,
title={PlantDoc Elite Disease Classifier},
author={Your Name},
year={2025},
publisher={HuggingFace},
url={https://huggingface.co/your-username/plantdoc-elite}
}
This model is released under the MIT License. See LICENSE file for details.