Skip to content

About

CNN-based plant disease detection system performing real-time image classification to support precision agriculture decision-making.

Resources

Stars

4 stars

Watchers

0 watching

Forks

 
 

Latest commit

 

History

18 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🌱 KrishiRakshak — CNN-Based Crop Disease Classification System

WhatsApp Image 2025-09-23 at 10 02 21

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.

Problem Statement

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.

📊 Dataset

•	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

🎥 Demo Video

Watch the Demo

🏗 Model Architecture

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

⚙️ Training Pipeline

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

📈 Model Performance

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

🏗 ML Engineering Design Decisions

1️⃣ Overfitting Mitigation

  • Applied data augmentation (rotation, zoom, shear, flip)
  • Dropout layers for regularization
  • Early stopping based on validation loss

2️⃣ Generalization Strategy

  • Train / validation split monitoring
  • Confusion matrix analysis for class overlap
  • Precision & recall evaluation beyond raw accuracy

3️⃣ Deployment Readiness

  • Model exported to .h5
  • Lightweight inference pipeline
  • Modular separation of:
    • Training pipeline
    • Model storage
    • Streamlit inference interface

4️⃣ Scalability Considerations

  • Architecture compatible with transfer learning (ResNet / EfficientNet)
  • Ready for REST API serving via FastAPI
  • Extendable to edge deployment (TensorFlow Lite)

🚀 Deployment

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.

🛠 Tech Stack

•	Python 3.x
•	TensorFlow / Keras
•	OpenCV
•	NumPy / Pandas
•	Matplotlib / Seaborn
•	Streamlit

🚀 Quick Start

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

Tech Stack

Programming Language: Python Deep Learning: TensorFlow, Keras Data Processing: OpenCV, NumPy, Pandas Visualization: Matplotlib, Seaborn Frontend Prototype: Streamlit

📂 Project Structure

├── data/                # Training & test datasets  
├── notebooks/           # Model training & evaluation  
├── models/              # Saved CNN models  
├── app/                 # Streamlit inference app  
├── requirements.txt  
└── README.md

Key ML Engineering Highlights

•	Data augmentation for robustness
•	Regularization via Dropout
•	Validation monitoring to prevent overfitting
•	Modular separation (training vs inference)
•	Deployable inference pipeline

🔍 Interpretation

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

🌍 Future Roadmap

• 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

🤝 Contributing

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.

📜 License

This project is licensed under the MIT License — free to use, modify, and distribute with proper attribution.

💼 ML Engineer Relevance

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🌾

About

CNN-based plant disease detection system performing real-time image classification to support precision agriculture decision-making.

Resources

Stars

4 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages