Vidhi35's picture
Update README.md
92e8329 verified

A newer version of the Gradio SDK is available: 6.1.0

Upgrade
metadata
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

Plant Disease Detection Groq Hugging Face Gradio

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

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

  1. Upload/Capture Image ๐Ÿ“ธ

    • Upload a plant image from your device
    • Or use your webcam to capture a live image
  2. AI Analysis ๐Ÿ”

    • The system analyzes the image using a pre-trained model
    • Provides top 3 disease predictions with confidence scores
  3. 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

  1. Visit Groq Console
  2. Sign up for a free account (no credit card required)
  3. Navigate to "API Keys" in the sidebar
  4. Click "Create API Key"
  5. 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

  1. Launch the Application

    python app.py
    
  2. Access the Web Interface

    • Open your browser
    • Navigate to http://localhost:7860
  3. 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
  4. Analyze Disease

    • Click the "๐Ÿ”ฌ Analyze Disease" button
    • Wait for the AI to process the image (usually 2-5 seconds)
  5. 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)

  1. Create Hugging Face Account

  2. Create New Space

    • Click "New Space"
    • Choose "Gradio" as the SDK
    • Name: plant-disease-detection
  3. Upload Files

    • app.py - Main application file
    • requirements.txt - Dependencies
    • .env - Environment variables (add Groq API key as a Space secret)
    • README.md - This documentation
  4. Configure Secrets

    • Go to Space Settings
    • Add GROQ_API_KEY as a secret
    • Paste your Groq API key
  5. 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

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. 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


โš ๏ธ 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