AI-powered multi-crop plant disease detection system built with PyTorch and Streamlit. The app classifies plant leaf images across 34 crop health and disease categories, then provides practical symptoms, treatment, and care guidance for farmers, students, researchers, and agriculture technology projects.
Recommended repository name: smart-crop-disease-detector
- Detects crop diseases from leaf images using a trained ResNet18 transfer learning model.
- Supports 13 plant types and 34 healthy/disease classes from a PlantVillage-style dataset.
- Provides disease name, confidence score, symptoms, suggested medicine, and care instructions.
- Includes both a Streamlit web app and a Tkinter desktop app.
- Includes training scripts for retraining on the
newplantvillageimage dataset. - Lightweight project structure suitable for GitHub portfolios, agriculture AI demos, and academic submissions.
Apple, Blueberry, Cherry, Grape, Orange, Peach, Pepper Bell, Potato, Raspberry, Soybean, Squash, Strawberry, and Tomato.
Example disease classes include Apple Scab, Black Rot, Cedar Apple Rust, Citrus Greening, Bacterial Spot, Early Blight, Late Blight, Powdery Mildew, Septoria Leaf Spot, Tomato Mosaic Virus, and healthy leaf categories.
- Python
- PyTorch
- Torchvision
- Streamlit
- Tkinter
- Pillow
- Scikit-learn
- Matplotlib and Seaborn
smart-crop-disease-detector/
|-- crop_disease_web.py # Streamlit web application
|-- crop_disease_app.py # Tkinter desktop application
|-- train_app_model.py # Fast ResNet18 training script
|-- train_crop_disease.py # Full training/evaluation pipeline
|-- crop_disease_model.pth # Trained ResNet18 weights
|-- classes.json # Class labels used by the model
|-- screenshots/
| `-- streamlit-home.png # README screenshot
|-- requirements.txt
|-- .gitignore
`-- README.md
The raw dataset folder newplantvillage/ is intentionally ignored by Git because it contains 25,000+ images. Keep it locally when training, or host the dataset separately on Kaggle, Google Drive, Hugging Face Datasets, or GitHub Releases.
git clone https://github.com/amirmughal44/smart-crop-disease-detector.git
cd smart-crop-disease-detector
python -m venv .venvWindows:
.venv\Scripts\activate
python -m pip install --upgrade pip
python -m pip install -r requirements.txtmacOS/Linux:
source .venv/bin/activate
python -m pip install --upgrade pip
python -m pip install -r requirements.txtpython -m streamlit run crop_disease_web.pyOpen the local URL shown in the terminal, upload a clear plant leaf image, and view the predicted disease result with recovery guidance.
python crop_disease_app.pyPlace the dataset in this structure:
newplantvillage/
|-- Apple___Apple_scab/
|-- Apple___Black_rot/
|-- Tomato___Early_blight/
`-- ...
Fast training script used by the app:
python train_app_model.pyFull training and evaluation pipeline:
python train_crop_disease.pyThese are the clean commands used to publish this type of project:
git init
git add README.md requirements.txt LICENSE .gitignore screenshots classes.json *.py crop_disease_model.pth
git commit -m "Initial commit: add smart crop disease detector"
gh repo create smart-crop-disease-detector --public --description "AI-powered multi-crop plant disease detection app using PyTorch ResNet18 and Streamlit. Classifies 34 plant leaf disease and healthy classes with treatment guidance." --source . --remote origin --push
gh repo edit amirmughal44/smart-crop-disease-detector --add-topic plant-disease-detection --add-topic crop-disease-detection --add-topic pytorch --add-topic streamlit --add-topic computer-vision --add-topic agriculture-ai --add-topic deep-learning --add-topic image-classification --add-topic resnet18 --add-topic plantvillageplant disease detection, crop disease detection, AI agriculture, smart farming, plant leaf disease classification, PyTorch plant disease model, Streamlit machine learning app, ResNet18 transfer learning, computer vision agriculture, PlantVillage disease detection, crop health diagnosis, agriculture technology project.
This project is an educational AI assistant for crop disease screening. It should not replace advice from a qualified agriculture expert, plant pathologist, or local extension service.
This project is released under the MIT License.
