Skip to content

amirmughal44/smart-crop-disease-detector

Repository files navigation

Smart Crop Disease Detector

Python PyTorch Streamlit Computer Vision

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

Screenshot

Smart Crop Disease Detector Streamlit UI

Key Features

  • 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 newplantvillage image dataset.
  • Lightweight project structure suitable for GitHub portfolios, agriculture AI demos, and academic submissions.

Supported Crops

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.

Tech Stack

  • Python
  • PyTorch
  • Torchvision
  • Streamlit
  • Tkinter
  • Pillow
  • Scikit-learn
  • Matplotlib and Seaborn

Project Structure

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.

Installation

git clone https://github.com/amirmughal44/smart-crop-disease-detector.git
cd smart-crop-disease-detector
python -m venv .venv

Windows:

.venv\Scripts\activate
python -m pip install --upgrade pip
python -m pip install -r requirements.txt

macOS/Linux:

source .venv/bin/activate
python -m pip install --upgrade pip
python -m pip install -r requirements.txt

Run The Web App

python -m streamlit run crop_disease_web.py

Open the local URL shown in the terminal, upload a clear plant leaf image, and view the predicted disease result with recovery guidance.

Run The Desktop App

python crop_disease_app.py

Retrain The Model

Place 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.py

Full training and evaluation pipeline:

python train_crop_disease.py

GitHub Publishing Commands

These 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 plantvillage

SEO Keywords

plant 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.

Disclaimer

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.

License

This project is released under the MIT License.

About

AI-powered multi-crop plant disease detection app using PyTorch ResNet18 and Streamlit. Classifies 34 plant leaf disease and healthy classes with treatment guidance.

Topics

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages