- πΏ Plant Disease Classification β MobileNetV2
πΏ Plant Disease Classification β MobileNetV2
High-Accuracy Deep Learning Model for Crop Disease Detection
Author: Daksh Goyal
π Overview
This repository provides a lightweight, production-ready MobileNetV2 model trained on the PlantVillage augmented dataset for multi-class plant disease classification (38 classes).
The model is optimized for:
β Real-time inference β Low-compute environments (mobile/edge devices) β Web apps (Streamlit) β Integration with farm-tech solutions
π§ Model Summary
- Architecture: MobileNetV2
- Dataset: New Plant Diseases Dataset (Augmented) β PlantVillage
- Total Classes: 38
- Training Images: ~87,000 images (balanced across 38 classes)
- Validation Accuracy: 95%
- Loss: Cross Entropy
- Optimizer: Adam (LR = 0.001)
- Input Size: 224 Γ 224
- Format: PyTorch
.pth
π Live Demo
Try the fully deployed, interactive plant-disease detection app:
π Streamlit App: https://agriguard271005.streamlit.app/
Upload a leaf image β get: β Disease name β Confidence score β Health status β Severity level β Recommended action
π€ HuggingFace Model
The pretrained .pth model and configuration files are hosted here:
π HuggingFace Model Repo: https://huggingface.co/Daksh159/plant-disease-mobilenetv2
Available assets:
mobilenetv2_plant.pthclass_names.jsonREADME.md(this file)
π Model Architecture (Training Setup)
Backbone: MobileNetV2
model = models.mobilenet_v2(pretrained=True)
for p in model.features.parameters():
p.requires_grad = False # freeze feature extractor
model.classifier[1] = nn.Sequential(
nn.Dropout(0.2),
nn.Linear(model.classifier[1].in_features, 38)
)
Training Loop
- 10 epochs
- Augmented inputs
- Adam optimizer
- Early stopping possible
π Supported Classes
Includes diseases & healthy leaves of:
- Apple
- Blueberry
- Cherry
- Corn
- Grape
- Peach
- Pepper
- Potato
- Raspberry
- Soybean
- Squash
- Strawberry
- Tomato
- Orange
(Full list of 38 classes included in class_names.json)
πΌ Inference Example
import torch
from torchvision import models, transforms
from PIL import Image
model = ... # load your mobilenetv2_plant.pth
model.eval()
tf = transforms.Compose([
transforms.Resize((224,224)),
transforms.ToTensor(),
transforms.Normalize([0.485,0.456,0.406],
[0.229,0.224,0.225])
])
img = Image.open("leaf.jpg").convert("RGB")
x = tf(img).unsqueeze(0)
with torch.no_grad():
preds = model(x)
probs = torch.softmax(preds, dim=1)[0]
index = probs.argmax().item()
print("Predicted Class:", CLASS_NAMES[index])
print("Confidence:", float(probs[index]))
π API / Integration Use Cases
This model can be integrated into:
π± Farming mobile apps πΎ Agri-tech dashboards π‘ Real-time disease monitoring systems πΈ Drone-based crop scanning pipelines π IoT/edge deployment for field devices
π₯ Deployment
Available Deployments
| Platform | Status | Link |
|---|---|---|
| HuggingFace | β Model Hosted | https://huggingface.co/Daksh159/plant-disease-mobilenetv2 |
| Streamlit Cloud | β Web App Live | https://agriguard271005.streamlit.app/ |
π Future Improvements
Planned enhancements:
- Grad-CAM heatmap explainability
- Faster ONNX / TensorRT export
- Support for multiple leaves in a single image
- Region-based crop disease localization
- Larger dataset fine-tuning
π Acknowledgements
- PlantVillage Dataset
- PyTorch
- Kaggle
- Streamlit Cloud
- HuggingFace π€