Skip to content

GreenGuard is a multilingual AI-powered chatbot for crop disease detection, integrating AGDFNet Model. It enables farmers to upload plant images and receive real-time, text-based treatment recommendations. Using Adaptive Lesion Modules and Feature Aggregation, it enhances disease detection, helping mitigate crop losses efficiently.

Notifications You must be signed in to change notification settings

ddihora1604/GreenGuard

Repository files navigation

GreenGuard - An AI-driven Interactive Chatbot for Real-time Crop Disease Detection using AGDFNet

Prototype: https://youtu.be/OE9KS9Ulcos?si=G_Co71CIU6b5h9o2

Research Paper: https://docs.google.com/document/d/16dlcJQwMlwsY-dh49TIpj6FXRT9mQ0T65wFbP-Y_faE/edit?tab=t.0

Project Overview

GreenGuard is an AI-powered, interactive web application designed to assist farmers and agricultural specialists in detecting and identifying plant diseases using image-based diagnostics. By leveraging the AGDFNet (Attention-Guided Multi-Scale Disease Feature Network) deep learning model, the system provides real-time disease identification, treatment recommendations, and preventive insights, all integrated into an intuitive chatbot interface.

πŸ’‘ Key Features

🧠 Real-time Plant Disease Detection

  • Upload or capture leaf images for instant analysis
  • Offline model inference using AGDFNet architecture
  • Real-time feedback with disease probability scores
  • Support for both online and offline modes

🌾 Multi-Crop, Multi-Disease Coverage

  • Comprehensive coverage of 61 disease classes
  • Support for 11 major crop types:
    • Bean
    • Cotton
    • Groundnut
    • Maize
    • Pepper Bell
    • Potato
    • Rice
    • Spinach
    • Sugarcane
    • Tomato
    • Turmeric

πŸ“Š Rich Disease Reports

  • Class-specific precision, recall, and F1-scores
  • Disease probability heatmaps
  • Growth stage analysis
  • Severity assessment
  • Environmental factor correlation

πŸ’Š Treatment & Prevention

  • Personalized treatment prescriptions
  • Preventive measures and best practices
  • Fertilizer recommendations
  • Integrated pest management suggestions
  • Seasonal care guidelines

πŸ’¬ AI Chatbot Interface

  • Interactive diagnosis conversations
  • Treatment recommendations
  • Fertilizer information
  • Location-based mapping
  • Weather integration
  • Growth stage advice

πŸ•’ Detection History

  • Comprehensive scan history
  • Progress tracking
  • Treatment effectiveness analysis
  • Exportable reports
  • Seasonal comparison
  • Growth pattern analysis

πŸ“± Mobile Optimization

  • Offline model inference
  • Online treatment recommendations
  • Camera integration
  • Mobile-friendly UI
  • Offline storage
  • Network-optimized images

πŸ“š Usage Guide

1. Home Page

  • Upload or capture a crop leaf image
  • Support for JPG, PNG, and JPEG formats
  • Maximum file size: 5MB
  • Real-time image preview

2. Detection Process

  • Image processed through AGDFNet
  • Multi-scale feature extraction
  • Attention-based disease localization
  • Real-time probability calculation

3. Report Generation

  • Display of detected disease class
  • Probability score visualization
  • Treatment recommendations
  • Prevention measures
  • Export options

4. Chatbot Interaction

  • Ask questions about diagnosis
  • Get localized advice
  • Treatment follow-up
  • Prevention queries
  • Growth stage information

5. History Management

  • Access previous scans
  • Compare results
  • Track treatment progress
  • Export historical data
  • Analyze patterns

πŸ›  Troubleshooting

1. Upload Errors

  • Error: Unsupported file format

    • Solution: Use JPG, PNG, or JPEG only
    • Tip: Convert images using free tools
  • Error: File size too large

    • Solution: Compress image before upload
    • Tip: Use image compression tools

2. Backend Connection

  • Error: Flask server not running
    • Solution: Start backend server
    • Command: python backend.py
    • Port: 5000

3. Model Loading

  • Error: Missing model file
    • Solution: Place adgf_net.keras in models/
    • Location: backend/models/adgf_net.keras
    • Tip: Verify file permissions

4. Chatbot Issues

  • Error: API key not found
    • Solution: Check .env file
    • Variable: GROQ_API_KEY
    • Tip: Get key from Groq Dashboard

πŸ› οΈ Technologies Used

Layer Stack

Frontend

  • Framework: React 18+
  • Build Tool: Vite
  • Styling: TailwindCSS
  • Animations: Framer Motion
  • UI Components: Material UI
  • State Management: React Context
  • Image Processing: HTML5 Canvas

Backend

  • Framework: Flask 2.x
  • CORS: Flask-CORS
  • ML Integration: TensorFlow 2.x
  • Chat Integration: LangChain
  • API Routing: Flask-RESTful
  • Error Handling: Flask-Error

Machine Learning

  • Model Architecture: AGDFNet
  • Loss Function: Adaptive Focal Loss
  • Attention Mechanisms: Spatial & Channel Attention
  • Transfer Learning: Pre-trained CNN
  • Optimization: AdamW
  • Metrics: Precision, Recall, F1-Score

Storage & Data

  • Session Management: SessionStorage
  • Image Storage: Temporary filesystem
  • History: IndexedDB
  • Cache: Redis (optional)

API & Integration

  • LLM Provider: Groq
  • Weather API: OpenWeatherMap
  • Geolocation: Geolocation API
  • Image Processing: Pillow
  • Database: SQLite (optional)

πŸš€ Setup Instructions

Prerequisites

  • Node.js (v18+)
  • Python (v3.9+)
  • NPM or Yarn
  • Internet connection for API calls
  • Git
  • Python virtual environment

Frontend Setup

# Clone the repository
$ git clone <repository-url>
$ cd GreenGuard

# Install dependencies
$ npm install

# Run development server
$ npm run dev

# Access the application at http://localhost:5173

Backend Setup

# Navigate to the backend directory
$ cd backend

# Create and activate virtual environment
$ python -m venv venv
# On Windows:
$ venv\Scripts\activate
# On macOS/Linux:
$ source venv/bin/activate

# Install dependencies
$ pip install -r requirements.txt

# Run the backend server
$ python backend.py

# The API will be available at http://localhost:5000

Environment Configuration

  1. Create a .env file in the backend directory with:
GROQ_API_KEY=your_groq_api_key
OPENWEATHER_API_KEY=your_openweather_api_key
  1. Get your API keys from:

Project Structure

GreenGuard/
β”œβ”€β”€ backend/                  # Python Flask API
β”‚   β”œβ”€β”€ models/               # ML model files
β”‚   β”‚   └── adgf_net.keras    # Custom CNN model
β”‚   β”œβ”€β”€ temp_uploads/         # Temporary storage for uploaded images
β”‚   β”œβ”€β”€ backend.py            # Main Flask application
β”‚   β”œβ”€β”€ disease_predict.py    # ML model implementation
β”‚   β”œβ”€β”€ groq_demo.py          # Integration with Groq API
β”‚   └── requirements.txt      # Python dependencies
β”‚
β”œβ”€β”€ src/                      # React frontend
β”‚   β”œβ”€β”€ assets/               # Static assets
β”‚   β”œβ”€β”€ components/           # Reusable UI components
β”‚   β”œβ”€β”€ context/              # React context providers
β”‚   β”œβ”€β”€ hooks/                # Custom React hooks
β”‚   β”œβ”€β”€ pages/                # Application pages
β”‚   β”œβ”€β”€ App.jsx               # Main application component
β”‚   β”œβ”€β”€ App.css               # Application styles
β”‚   β”œβ”€β”€ index.css             # Global styles
β”‚   └── main.jsx              # Entry point
β”‚
β”œβ”€β”€ public/                   # Public static files
β”œβ”€β”€ .gitignore                # Git ignore rules
β”œβ”€β”€ package.json              # NPM dependencies
β”œβ”€β”€ tailwind.config.js        # Tailwind CSS configuration
└── vite.config.js            # Vite configuration

About

GreenGuard is a multilingual AI-powered chatbot for crop disease detection, integrating AGDFNet Model. It enables farmers to upload plant images and receive real-time, text-based treatment recommendations. Using Adaptive Lesion Modules and Feature Aggregation, it enhances disease detection, helping mitigate crop losses efficiently.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published