Deep learning pipeline for multi-class crop leaf disease classification using Convolutional Neural Networks (CNNs), built with TensorFlow/Keras and deployed via Streamlit for real-time inference.
The system includes:
• Structured data preprocessing & augmentation pipeline
• Custom CNN architecture with regularization for generalization
• Evaluation using precision, recall & confusion matrix analysis
• Exported model (.h5) integrated into a real-time Streamlit inference app
• Modular separation of training and deployment layers
This project simulates a real-world ML workflow — from dataset ingestion to deployable inference interface.
Early detection of crop diseases is critical for minimizing agricultural losses. Manual inspection is time-consuming and prone to error. This project builds a supervised image classification system capable of detecting crop leaf diseases from raw RGB images.
• Image-based leaf disease dataset (train/test split)
• Multi-class classification problem (Healthy + Disease classes)
• Images resized and normalized for CNN input
• Augmentation applied to reduce overfitting:
• Rotation
• Horizontal flip
• Zoom
• Shear
Custom CNN architecture built using Keras:
• Convolutional layers (ReLU activation)
• MaxPooling layers
• Dropout regularization
• Fully connected dense layers
• Softmax output layer (multi-class classification)
Loss Function: Categorical Crossentropy
Optimizer: Adam
Evaluation Metrics:
• Accuracy
• Precision
• Recall
• Confusion Matrix
1. Image preprocessing (resizing, normalization)
2. Train/validation split
3. Data augmentation pipeline
4. Model training with early stopping
5. Validation monitoring to prevent overfitting
6. Final evaluation on hold-out test set
• Training Accuracy: ~97%
• Validation Accuracy: ~92%
• Macro Precision: >90%
• Macro Recall: >90%
Confusion matrix indicates minor misclassification between visually similar disease classes.
The model demonstrates strong generalization with limited overfitting due to augmentation and dropout regularization.
- Applied data augmentation (rotation, zoom, shear, flip)
- Dropout layers for regularization
- Early stopping based on validation loss
- Train / validation split monitoring
- Confusion matrix analysis for class overlap
- Precision & recall evaluation beyond raw accuracy
- Model exported to
.h5 - Lightweight inference pipeline
- Modular separation of:
- Training pipeline
- Model storage
- Streamlit inference interface
- Architecture compatible with transfer learning (ResNet / EfficientNet)
- Ready for REST API serving via FastAPI
- Extendable to edge deployment (TensorFlow Lite)
Model exported as .h5 and integrated into a Streamlit application for:
• Real-time leaf image upload
• Instant disease prediction
• Confidence score display
This simulates a production inference pipeline.
• Python 3.x
• TensorFlow / Keras
• OpenCV
• NumPy / Pandas
• Matplotlib / Seaborn
• Streamlit
Clone the repository:
git clone https://github.com/akashcodes23/crop-disease-app.git
cd crop-disease-app
Install the dependencies:
pip install -r requirements.txt
Run the Streamlit application:
streamlit run app/app.py
Programming Language: Python Deep Learning: TensorFlow, Keras Data Processing: OpenCV, NumPy, Pandas Visualization: Matplotlib, Seaborn Frontend Prototype: Streamlit
├── data/ # Training & test datasets
├── notebooks/ # Model training & evaluation
├── models/ # Saved CNN models
├── app/ # Streamlit inference app
├── requirements.txt
└── README.md• Data augmentation for robustness
• Regularization via Dropout
• Validation monitoring to prevent overfitting
• Modular separation (training vs inference)
• Deployable inference pipeline
-Healthy leaves are detected with near-perfect accuracy, showing the model’s reliability in differentiating diseased vs non-diseased samples.
-Disease A & Disease B show minor overlap (misclassifications), which is expected due to visual similarities in leaf patterns.
-Disease C is identified with high confidence and minimal confusion.
-The model demonstrates strong generalization, with most errors being between visually similar disease classes.
• Replace custom CNN with EfficientNet (transfer learning)
• Implement weighted loss for class imbalance handling
• Add MLflow for experiment tracking & model versioning
• Containerize using Docker
• Deploy as REST API using FastAPI
• Implement CI/CD for model updates
• Optimize inference latency for edge devices
Contributions are welcome! You can contribute by:
• Adding new crop disease classes
• Improving model accuracy
• Enhancing the UI/UX
• Integrating APIs or mobile deployment
• Expanding datasets and preprocessing pipelines
Submit a Pull Request or open an Issue to get started.
This project is licensed under the MIT License — free to use, modify, and distribute with proper attribution.
This project demonstrates:
✔ End-to-end ML lifecycle implementation
✔ Data preprocessing & augmentation strategy
✔ Model evaluation beyond accuracy
✔ Regularization & overfitting control
✔ Deployment-ready inference system
✔ Modular ML architecture design
Designed to reflect real-world ML engineering workflows. Empowering farmers with AI-driven crop health diagnostics🌾

