A deep learning-based web application for detecting and classifying plant diseases from leaf images. The system uses Convolutional Neural Networks (CNNs) with EfficientNetV2S architecture to identify 38 different classes of plant diseases across 14 crop species, achieving 96.81% validation accuracy.
- Features
- Demo
- Supported Plants & Diseases
- Tech Stack
- Project Structure
- Installation
- Usage
- Model Architecture
- Dataset
- Performance
- API Reference
- Contributing
- License
- Acknowledgments
- Multi-Class Detection: Identifies 38 different plant disease classes
- 14 Crop Species: Supports Apple, Blueberry, Cherry, Corn, Grape, Orange, Peach, Pepper, Potato, Raspberry, Soybean, Squash, Strawberry, and Tomato
- High Accuracy: 96.81% validation accuracy, 96.92% training accuracy
- EfficientNetV2S Architecture: State-of-the-art deep learning model with transfer learning
- Real-time Inference: Fast prediction with confidence scores
- User-Friendly Interface: Clean and intuitive Streamlit web interface
- Confidence Metrics: Visual confidence indicators for predictions
- Healthy/Diseased Classification: Identifies both healthy and diseased plants
The application provides a simple interface where users can:
- Upload an image of a crop leaf (JPG, JPEG, or PNG format)
- View the uploaded image
- Get instant prediction results including:
- Plant species identification
- Disease classification
- Confidence percentage
- Health status indicator
Access the app at: http://localhost:8502
The model can identify the following plant species and their associated diseases:
| Plant Species | Diseases Detected |
|---|---|
| Apple | Apple Scab, Black Rot, Cedar Apple Rust, Healthy |
| Blueberry | Healthy |
| Cherry | Powdery Mildew, Healthy |
| Corn (Maize) | Cercospora Leaf Spot, Common Rust, Northern Leaf Blight, Healthy |
| Grape | Black Rot, Esca (Black Measles), Leaf Blight, Healthy |
| Orange | Huanglongbing (Citrus Greening) |
| Peach | Bacterial Spot, Healthy |
| Pepper (Bell) | Bacterial Spot, Healthy |
| Potato | Early Blight, Late Blight, Healthy |
| Raspberry | Healthy |
| Soybean | Healthy |
| Squash | Powdery Mildew |
| Strawberry | Leaf Scorch, Healthy |
| Tomato | Bacterial Spot, Early Blight, Late Blight, Leaf Mold, Septoria Leaf Spot, Spider Mites, Target Spot, Yellow Leaf Curl Virus, Mosaic Virus, Healthy |
Total Classes: 38 (including healthy variants)
- Python 3.10: Programming language
- TensorFlow 2.21: Deep learning framework
- Keras 3.12: High-level neural networks API
- Streamlit 1.55: Web application framework
- NumPy: Numerical computations and array operations
- Pillow: Image processing and manipulation
- Pandas: Data handling (via Streamlit)
- H5Py: Model file handling
plant_disease_detection/
โโโ app.py # Main Streamlit application
โโโ notebooks/ # Jupyter notebooks
โ โโโ plant_disease_training.ipynb # Training notebook (Colab-ready)
โโโ saved_model/ # TensorFlow SavedModel (download from Drive)
โ โโโ saved_model.pb # Model architecture and weights
โ โโโ variables/ # Model variables
โ โโโ assets/ # Model assets
โ โโโ fingerprint.pb # Model fingerprint
โโโ class_labels.json # Disease class mappings (38 classes)
โโโ screenshots/ # Application screenshots
โโโ requirements.txt # Python dependencies
โโโ .gitignore # Git ignore rules
โโโ LICENSE # MIT License
โโโ README.md # Project documentation
Note: Model files are hosted separately on Google Drive due to size constraints.
- Python 3.10 or compatible version (3.8-3.11)
- pip package manager
- Model files (download separately)
-
Clone the repository
git clone https://github.com/gamferno/plant-disease-detection.git cd plant_disease_detection -
Download the model files
Download
saved_model.zipfrom Google Drive:- Google Drive Link: Download saved_model.zip
- Extract to project root:
unzip saved_model.zip
The
saved_model/directory should be in the project root. -
Create a virtual environment
python -m venv tf-env
-
Activate the virtual environment
On Linux/Mac:
source tf-env/bin/activateOn Windows:
tf-env\Scripts\activate
-
Install dependencies
pip install --upgrade pip pip install -r requirements.txt
python -m venv tf-env && source tf-env/bin/activate && pip install -r requirements.txtNote: Don't forget to download and extract the model files before running the app!
-
Activate the virtual environment (if not already activated)
source tf-env/bin/activate # Linux/Mac # or tf-env\Scripts\activate # Windows
-
Start the Streamlit app
streamlit run app.py
-
Access the application
- Open your browser and navigate to
http://localhost:8501 - The application will automatically open in your default browser
- Open your browser and navigate to
- Click on "Choose a leaf image" to upload an image
- Select an image file (JPG, JPEG, or PNG) of a crop leaf
- Wait for the model to process the image
- View the results:
- Plant Type: Identified crop species
- Disease: Disease classification
- Confidence: Prediction confidence percentage with visual progress bar
- Health Status: Clear indicator if the plant is healthy or diseased
Run with custom configuration:
streamlit run app.py --server.port 8080
streamlit run app.py --server.address 0.0.0.0 # For network access
streamlit run app.py --theme.base dark # Dark theme- Type: Convolutional Neural Network (CNN)
- Architecture: EfficientNetV2S (Transfer Learning)
- Framework: TensorFlow/Keras
- Pre-trained Weights: ImageNet
- Input Size: 300x300x3 (RGB images)
- Output: 38 classes (softmax activation)
- Model Format: TensorFlow SavedModel
- Model Size: ~5 MB (SavedModel format)
- Validation Accuracy: 96.81%
- Training Accuracy: 96.92%
- Architecture: EfficientNetV2S with custom classification head
- Training Strategy: Two-phase (frozen backbone โ fine-tuning)
- Image resizing to 300x300 pixels
- RGB conversion (3 channels)
- Normalization: pixel values scaled to [0, 1]
- Batch dimension expansion for model input
- Uses TensorFlow SavedModel signature for inference
- Serving endpoint:
serving_default - Output: Softmax probabilities for all 38 classes
- Prediction: argmax of output probabilities
The model is trained on the New Plant Diseases Dataset from Kaggle, a comprehensive augmented dataset for plant disease classification.
- Source: New Plant Diseases Dataset (Kaggle)
- Total Classes: 38 (including healthy variants)
- Plant Species: 14
- Image Type: RGB leaf images
- Resolution: Resized to 300x300 pixels
- Augmentation: Includes rotation, zoom, flip, and shift transformations
- Split: Training and validation sets provided
- Multiple disease types per plant species
- Healthy class for most plant types
- Balanced representation across major crops
- Over 70,000 augmented training images
@dataset{new_plant_diseases_dataset,
author = {Vipoooool},
title = {New Plant Diseases Dataset},
year = {2020},
publisher = {Kaggle},
url = {https://www.kaggle.com/datasets/vipoooool/new-plant-diseases-dataset}
}
- Validation Accuracy: 96.81%
- Training Accuracy: 96.92%
- Architecture: EfficientNetV2S with transfer learning
- Dataset: New Plant Diseases Dataset (Augmented)
The model provides:
- 38-Class Classification: High accuracy across all disease types
- Confidence Score: Probability-based confidence metric (0-100%)
- Real-time Inference: Fast prediction (<3 seconds on CPU)
- Robust Performance: Validated on diverse leaf images
- CPU: Modern multi-core processor (Intel/AMD)
- RAM: Minimum 4 GB, Recommended 8 GB
- Storage: 500 MB for model and dependencies
- GPU: Optional (CUDA-compatible GPU for faster inference)
- oneDNN: Optimized for Intel CPU instructions (AVX2, AVX512F)
- Model Caching: Streamlit caching for fast reloads
- Efficient Memory: Lightweight inference pipeline
The notebooks/ directory contains Jupyter notebooks for model training and experimentation:
- plant_disease_training.ipynb: Clean, production-ready training notebook
- Complete training pipeline from data download to model export
- Google Colab compatible with GPU support
- Well-documented with markdown sections
- Includes data augmentation, transfer learning, and evaluation
- Two-phase training: frozen backbone โ fine-tuning
See notebooks/README.md for running instructions and TRAINING.md for detailed training guide.
import tensorflow as tf
import numpy as np
from PIL import Image
# Load model
model = tf.saved_model.load("saved_model")
infer = model.signatures["serving_default"]
# Prepare image
image = Image.open("leaf.jpg").convert("RGB")
img = image.resize((300, 300))
img_array = np.array(img, dtype=np.float32) / 255.0
img_array = np.expand_dims(img_array, axis=0)
# Predict
outputs = infer(tf.constant(img_array))
predictions = list(outputs.values())[0].numpy()
# Get result
predicted_class = np.argmax(predictions[0])
confidence = predictions[0][predicted_class]The application uses:
st.file_uploader: Image upload widgetst.image: Display uploaded imagesst.spinner: Loading indicatorst.metric: Display plant and disease infost.progress: Confidence visualizationst.success/st.warning: Status messages
Contributions are welcome! Here's how you can help:
- Fork the repository
- Create a feature branch
git checkout -b feature/AmazingFeature
- Commit your changes
git commit -m 'Add some AmazingFeature' - Push to the branch
git push origin feature/AmazingFeature
- Open a Pull Request
- Add more plant species and diseases
- Improve model accuracy
- Add mobile responsiveness
- Implement batch processing
- Add disease treatment recommendations
- Create REST API endpoint
- Add multilingual support
- Improve UI/UX design
This project is licensed under the MIT License - see the LICENSE file for details.
- Dataset: New Plant Diseases Dataset by Vipoooool on Kaggle
- TensorFlow Team: For the deep learning framework
- Streamlit: For the amazing web app framework
- EfficientNet: For the state-of-the-art architecture
- Kaggle: For hosting the dataset and providing GPU resources
For questions, suggestions, or issues, please open an issue on the GitHub repository.
- Mobile application (iOS/Android)
- Batch image processing
- Disease treatment recommendations
- Historical tracking of plant health
- REST API for integration
- Model retraining pipeline
- Multi-language support
- Severity assessment
- Geolocation-based disease prevalence
- Export reports as PDF
- New Plant Diseases Dataset: https://www.kaggle.com/datasets/vipoooool/new-plant-diseases-dataset
- EfficientNetV2: https://arxiv.org/abs/2104.00298
- TensorFlow Documentation: https://www.tensorflow.org/
- Streamlit Documentation: https://docs.streamlit.io/
Made with โค๏ธ for sustainable agriculture

