A newer version of the Gradio SDK is available:
6.1.0
title: Smart Pest Disease Detection For Crops
emoji: ๐
colorFrom: indigo
colorTo: indigo
sdk: gradio
sdk_version: 6.0.2
app_file: app.py
pinned: false
license: mit
short_description: Smart-Pest-Disease-Detection-for-Crops
๐ฑ Plant Disease Detection & Treatment System
A comprehensive AI-powered plant disease detection and treatment recommendation system
Group 13 - AgriTech Innovators ๐พ
๐ Live Demo on Hugging Face | ๐ Documentation | ๐ค Team
๐ Table of Contents
- Overview
- Features
- Demo
- Technologies Used
- System Architecture
- Installation & Setup
- Usage Guide
- Deployment
- Team Members
- Contributing
- License
๐ฏ Overview
The Plant Disease Detection & Treatment System is an intelligent application that helps farmers, gardeners, and agricultural professionals identify plant diseases and receive AI-powered treatment recommendations. Built by Group 13, this system combines state-of-the-art computer vision and large language models to provide accurate disease detection and comprehensive treatment guidance.
Key Highlights
- ๐ Accurate Detection: Uses pre-trained MobileNetV2 model for disease classification
- ๐ค AI-Powered Recommendations: Leverages Groq's Llama 3.3 70B for detailed treatment advice
- ๐ฑ User-Friendly Interface: Simple web interface built with Gradio
- ๐ Deployed on Hugging Face: Accessible anywhere, anytime
- ๐ฏ Free to Use: No API costs - completely free LLM via Groq
โจ Features
๐ฌ Disease Detection
- โ Upload plant images or capture from webcam
- โ AI-powered disease classification with confidence scores
- โ Top 3 disease predictions for comprehensive analysis
- โ Support for multiple plant species and diseases
๐ Treatment Recommendations
- โ Disease Overview: Detailed description of the detected disease
- โ Symptoms: Key symptoms to identify the disease
- โ Causes: Root causes and contributing factors
- โ
Treatment Options:
- โก Immediate actions to take
- ๐ฑ Organic/natural remedies
- ๐งช Chemical treatments (when necessary)
- ๐ก๏ธ Preventive measures
- โ Recovery Timeline: Expected recovery duration
- โ Additional Tips: Expert advice for disease management
๐จ Enhanced UI/UX
- โ Beautiful Markdown-formatted output
- โ Custom CSS styling for better readability
- โ Emoji-enhanced sections for visual appeal
- โ Responsive design for all devices
๐ฌ Demo
Live Application
Access the deployed application: Plant Disease Detection on Hugging Face
How It Works
Upload/Capture Image ๐ธ
- Upload a plant image from your device
- Or use your webcam to capture a live image
AI Analysis ๐
- The system analyzes the image using a pre-trained model
- Provides top 3 disease predictions with confidence scores
Get Treatment ๐
- Receive comprehensive AI-generated treatment recommendations
- Formatted with clear sections and actionable advice
๐ ๏ธ Technologies Used
Machine Learning & AI
| Technology | Purpose | Version |
|---|---|---|
| Hugging Face Transformers | Disease classification model | 4.35+ |
| Groq | Free LLM API provider | Latest |
| Llama 3.3 70B | Treatment recommendation generation | Latest |
| LangChain | LLM orchestration and chaining | 1.0+ |
| PyTorch | Deep learning framework | 2.0+ |
Web Interface
| Technology | Purpose | Version |
|---|---|---|
| Gradio | Web UI framework | 4.0+ |
| Pillow | Image processing | 10.0+ |
| Python-dotenv | Environment variable management | 1.0+ |
Model Details
- Classification Model:
linkanjarad/mobilenet_v2_1.0_224-plant-disease-identification- Architecture: MobileNetV2
- Input Size: 224x224
- Pre-trained on plant disease dataset
- Supports 38+ disease classes
๐๏ธ System Architecture
โโโโโโโโโโโโโโโโโโโ
โ User Interface โ
โ (Gradio) โ
โโโโโโโโโโฌโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Image Input โ
โ (Upload / Webcam Capture) โ
โโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Disease Classification โ
โ (Hugging Face MobileNetV2) โ
โ - Top 3 Predictions โ
โ - Confidence Scores โ
โโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Treatment Generation โ
โ (Groq + Llama 3.3 70B) โ
โ via LangChain โ
โ - Disease Overview โ
โ - Symptoms & Causes โ
โ - Treatment Recommendations โ
โโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Formatted Output โ
โ (Markdown with CSS Styling) โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
๐ฆ Installation & Setup
Prerequisites
- Python 3.8 or higher
- pip (Python package manager)
- Internet connection (for first-time model download)
Step 1: Clone the Repository
git clone https://github.com/Vidhi35/Smart-Pest-Disease-Detection-for-Crops.git
cd Smart-Pest-Disease-Detection-for-Crops
Step 2: Create Virtual Environment (Recommended)
Windows:
python -m venv venv
venv\Scripts\activate
Linux/Mac:
python3 -m venv venv
source venv/bin/activate
Step 3: Install Dependencies
pip install -r requirements.txt
Dependencies include:
- gradio>=4.0.0
- transformers>=4.35.0
- torch>=2.0.0
- torchvision>=0.15.0
- Pillow>=10.0.0
- langchain>=1.0.0
- langchain-core>=1.0.0
- langchain-groq>=1.0.0
- python-dotenv>=1.0.0
Step 4: Get Free Groq API Key
- Visit Groq Console
- Sign up for a free account (no credit card required)
- Navigate to "API Keys" in the sidebar
- Click "Create API Key"
- Copy your API key (starts with
gsk_...)
Step 5: Configure Environment Variables
Create a .env file in the project root:
# .env file
GROQ_API_KEY="gsk_your_actual_api_key_here"
Alternative: Set environment variable directly
Windows (PowerShell):
$env:GROQ_API_KEY="gsk_your_api_key_here"
Windows (Command Prompt):
set GROQ_API_KEY=gsk_your_api_key_here
Linux/Mac:
export GROQ_API_KEY=gsk_your_api_key_here
Step 6: Run the Application
python app.py
The application will launch at: http://localhost:7860
๐ Usage Guide
Basic Usage
Launch the Application
python app.pyAccess the Web Interface
- Open your browser
- Navigate to
http://localhost:7860
Upload or Capture Image
- Click on the image upload area
- Choose "Upload" to select an image from your device
- Or choose "Webcam" to capture a live image
Analyze Disease
- Click the "๐ฌ Analyze Disease" button
- Wait for the AI to process the image (usually 2-5 seconds)
View Results
- Left Panel: Disease predictions with confidence scores
- Right Panel: Comprehensive treatment recommendations
Tips for Best Results
โ Image Quality
- Use clear, well-lit images
- Focus on affected plant areas
- Avoid blurry or dark images
โ Image Content
- Capture leaves, stems, or fruits showing disease symptoms
- Include close-up shots of affected areas
- Ensure the disease symptoms are visible
โ Multiple Angles
- Try different angles if first result is uncertain
- Compare predictions from multiple images
๐ Deployment
Deployed on Hugging Face Spaces
This project is deployed on Hugging Face Spaces under Vidhi's account.
Live URL: https://huggingface.co/spaces/Vidhi35/Smart-Pest-Disease-Detection-for-Crops
Deployment Steps (For Reference)
Create Hugging Face Account
- Sign up at huggingface.co
Create New Space
- Click "New Space"
- Choose "Gradio" as the SDK
- Name:
plant-disease-detection
Upload Files
app.py- Main application filerequirements.txt- Dependencies.env- Environment variables (add Groq API key as a Space secret)README.md- This documentation
Configure Secrets
- Go to Space Settings
- Add
GROQ_API_KEYas a secret - Paste your Groq API key
Deploy
- Space will automatically build and deploy
- Access via the provided URL
Alternative Deployment Options
Deploy on Render
# Add Procfile
web: python app.py
Deploy on Railway
# Add railway.json
{
"build": {
"builder": "NIXPACKS"
},
"deploy": {
"startCommand": "python app.py"
}
}
๐ฅ Team Members
Group 13 - AgriTech Innovators ๐พ
Our team of passionate developers and agricultural technology enthusiasts working together to revolutionize plant disease detection.
| Name | Roll Number | Role | Contribution |
|---|---|---|---|
| Roshan Khatri | 300012723047 | Backend Developer & LLM Integration | Implemented Groq/Llama integration, LangChain setup, and prompt engineering |
| Suman Kumar | 300012723065 | Model Integration Specialist | Disease classification model setup, optimization, and testing |
| Vedshree Shrawan | 300012723070 | UI/UX Designer | Gradio interface design, CSS styling, and user experience enhancement |
| Vidhirani Netam | 300012723071 | Deployment Lead | Hugging Face Spaces deployment, configuration, and maintenance |
| Yash Shukla | 300012723073 | Documentation & Testing | Comprehensive documentation, testing, debugging, and quality assurance |
๐ฏ Team Contributions
Our collaborative efforts resulted in a comprehensive plant disease detection system:
๐ค AI/ML Development:
- Integrated Hugging Face MobileNetV2 for disease classification
- Implemented Groq + Llama 3.3 70B for intelligent treatment recommendations
- Optimized model performance and response time
๐ป Backend Development:
- Migrated from Google Gemini to free Groq LLM
- Updated to modern LangChain 1.1.0 (LCEL syntax)
- Implemented robust error handling and validation
๐จ Frontend & UI/UX:
- Designed beautiful Gradio interface
- Created custom CSS styling for Markdown rendering
- Enhanced user experience with emoji-rich formatted output
๐ Documentation:
- Created 10+ comprehensive documentation files
- Wrote detailed setup and deployment guides
- Prepared user manuals and troubleshooting guides
๐ Deployment & DevOps:
- Deployed on Hugging Face Spaces
- Configured environment variables and secrets
- Set up continuous integration workflow
๐งช Testing & Quality Assurance:
- Comprehensive testing of all features
- Bug fixes and performance optimization
- User acceptance testing
๐ Team Achievements
- โ Successfully built a production-ready AI application
- โ Migrated to 100% FREE LLM solution (zero API costs)
- โ Created professional-grade documentation
- โ Deployed on Hugging Face for public access
- โ Achieved fast response times (2-5 seconds)
- โ Implemented modern best practices and coding standards
๐ค Contributing
We welcome contributions from the community! Here's how you can help:
Reporting Issues
- Use GitHub Issues to report bugs
- Provide detailed description and steps to reproduce
- Include screenshots if applicable
Suggesting Features
- Open a GitHub Issue with the "enhancement" label
- Describe the feature and its benefits
- Discuss implementation approach
Pull Requests
- 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
๐ License
This project is licensed under the MIT License - see the LICENSE file for details.
MIT License
Copyright (c) 2024 Group 13
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
๐ Acknowledgments
- Hugging Face for providing the disease classification model
- Groq for free access to Llama 3.3 70B
- LangChain for LLM orchestration framework
- Gradio for the amazing web interface framework
- Our Instructors for guidance and support
๐ Contact & Support
- Project Repository: [GitHub Link]
- Live Demo: Hugging Face Spaces - Vidhi
- Issues: GitHub Issues
- Discussions: GitHub Discussions
โ ๏ธ Disclaimer
This system provides suggestions only. Always consult with agricultural experts, agronomists, or plant pathologists for serious plant health issues. The AI-generated recommendations should be used as a supplementary tool, not as a replacement for professional agricultural advice.
๐ Project Statistics
- Lines of Code: ~380
- Dependencies: 9 main packages
- Model Size: ~14MB (MobileNetV2)
- Supported Diseases: 38+ plant disease classes
- Average Response Time: 2-5 seconds
- Deployment Platform: Hugging Face Spaces
๐ฎ Future Enhancements
- Add support for more plant species
- Implement disease severity assessment
- Add multi-language support
- Create mobile application
- Integrate weather data for better predictions
- Add user feedback mechanism
- Implement disease tracking over time
- Create API endpoints for integration
Made with โค๏ธ by Group 13
โญ Star this repository if you found it helpful!
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference