Skip to content

Aryanjstar/Plant_Disease_Classification

Repository files navigation

🌿 Plant Disease Classification System

A modern, web-based application for detecting and classifying plant diseases using deep learning. Built with Flask and TensorFlow, featuring a beautiful, farmer-friendly interface with real-time camera integration.


πŸ“‹ Table of Contents


✨ Features

πŸ” Disease Detection

  • 38 Disease Classes: Classifies diseases across 9 different plant types
  • High Accuracy: CNN-based model trained on large dataset
  • Real-time Analysis: Fast prediction on uploaded images
  • Health Report: Professional results display with disease badges

πŸ“· Image Input Methods

  • File Upload: Upload images from your device
  • Direct Camera Capture: Take photos directly using device camera
  • Camera Switching: Toggle between front and back cameras
  • Live Preview: Real-time camera feed with viewfinder overlay

πŸ’‘ Treatment Recommendations

  • Fertilizer Recommendations: Specific fertilizer advice for each disease
  • Treatment Tips: Practical tips for disease management
  • Tabbed Interface: Easy navigation between fertilizer and tips
  • Expert Guidance: Detailed recommendations based on disease type

🎨 Modern UI/UX

  • Agricultural Theme: Deep forest green (#2D5A27) and earthy gold (#D4A373) color scheme
  • Responsive Design: Fully optimized for mobile and laptop
  • Card-Based Layout: Clean, modern card design
  • Smooth Animations: Fade-in effects and scanning animations
  • High Contrast: Optimized for outdoor/sunlight viewing

πŸ“± Mobile Features

  • Hamburger Menu: Collapsible navigation on mobile
  • Large Touch Targets: Minimum 50px buttons for easy tapping
  • Full-Width Layout: 95% width on mobile devices
  • Camera Integration: Native camera access on mobile devices

πŸ’» Desktop Features

  • Two-Column Layout: Side-by-side upload and camera options
  • Full Navigation: Always-visible navigation bar
  • Optimized Spacing: Professional desktop layout

🌾 Supported Plants & Diseases

The system can detect diseases in the following plants:

πŸ«‘ Bell Pepper

  • Bacterial Spot
  • Healthy

🌿 Cassava

  • Bacterial Blight (CBB)
  • Brown Streak Disease (CBSD)
  • Green Mottle (CGM)
  • Healthy
  • Mosaic Disease (CMD)

🌽 Corn (Maize)

  • Cercospora Leaf Spot (Gray Leaf Spot)
  • Common Rust
  • Healthy
  • Northern Leaf Blight

πŸ‡ Grape

  • Black Rot
  • Esca (Black Measles)
  • Healthy
  • Leaf Blight (Isariopsis Leaf Spot)

πŸ₯­ Mango

  • Anthracnose Fungal Leaf Disease
  • Healthy Leaf
  • Rust Leaf Disease

πŸ₯” Potato

  • Early Blight
  • Healthy
  • Late Blight

🌾 Rice

  • Brown Spot
  • Healthy
  • Hispa
  • Leaf Blast

🌹 Rose

  • Healthy Leaf
  • Rust
  • Sawfly Slug

πŸ… Tomato

  • Bacterial Spot
  • Early Blight
  • Healthy
  • Late Blight
  • Leaf Mold
  • Mosaic Virus
  • Septoria Leaf Spot
  • Spider Mites (Two-Spotted Spider Mite)
  • Target Spot
  • Yellow Leaf Curl Virus

Total: 38 Disease Classes


πŸš€ Installation

Prerequisites

  • Python 3.8 or higher
  • pip (Python package manager)

Step 1: Clone the Repository

git clone <repository-url>
cd Plant_Disease_Classification

Step 2: Create Virtual Environment

python -m venv venv

Step 3: Activate Virtual Environment

Windows:

.\venv\Scripts\Activate.ps1

Linux/Mac:

source venv/bin/activate

Step 4: Install Dependencies

pip install -r requirements.txt

Step 5: Download and Place Model File

The model file (Team3model.h5) is too large for GitHub. Download it from Google Drive:

πŸ“₯ Download Team3model.h5 from Google Drive

After downloading:

  1. Place the Team3model.h5 file in the project root directory
  2. Ensure the file is named exactly Team3model.h5
  3. The application will automatically load this model on startup

Note: The model file is required for the application to function. Without it, the disease detection feature will not work.


πŸ’» Usage

Starting the Application

  1. Activate Virtual Environment (if not already activated)

    .\venv\Scripts\Activate.ps1  # Windows
    # or
    source venv/bin/activate     # Linux/Mac
  2. Run the Flask Application

    python app.py
  3. Access the Application

    • Open your browser and navigate to: http://localhost:5000
    • The application will start on port 5000 by default

Using the Application

  1. Login

    • Enter any email and password (authentication is bypassed for demo)
    • Click "Login"
  2. Upload or Capture Image

    • Option 1: Click "Upload Image" and select a file from your device
    • Option 2: Click "Open Camera" to capture a photo directly
  3. View Results

    • Disease name with color-coded badge (red for infected, green for healthy)
    • Fertilizer recommendations tab
    • Treatment tips tab
    • Uploaded/captured image with scanning animation
  4. Analyze Another Image

    • Click "Analyze Another Image" to start over

πŸ“ Project Structure

Plant_Disease_Classification/
β”‚
β”œβ”€β”€ app.py                          # Main Flask application
β”œβ”€β”€ requirements.txt                 # Python dependencies
β”œβ”€β”€ Team3model.h5                    # Trained CNN model
β”œβ”€β”€ README.md                        # Project documentation
β”‚
β”œβ”€β”€ static/
β”‚   β”œβ”€β”€ style.css                    # Shared stylesheet
β”‚   └── uploads/                     # Uploaded images directory
β”‚
β”œβ”€β”€ templates/
β”‚   β”œβ”€β”€ login.html                   # Login page
β”‚   β”œβ”€β”€ home.html                    # Home page
β”‚   β”œβ”€β”€ disease-recognition.html     # Disease detection page
β”‚   └── prediction.html              # Results page
β”‚
└── venv/                            # Virtual environment (created after setup)

πŸ›  Technologies Used

Backend

  • Python 3.11: Programming language
  • Flask 3.0.0: Web framework
  • TensorFlow 2.15.0: Deep learning framework
  • Keras 2.15.0: High-level neural networks API
  • NumPy 1.24.3: Numerical computing
  • Pillow 10.1.0: Image processing

Frontend

  • HTML5: Markup language
  • CSS3: Styling with modern features
  • JavaScript: Client-side interactivity
  • Inter Font: Modern typography (Google Fonts)

Machine Learning

  • Convolutional Neural Network (CNN): Model architecture
  • Image Preprocessing: Resizing, normalization
  • Transfer Learning: Pre-trained model optimization

🧠 Model Architecture

The CNN model consists of:

  • Input Layer: 256x256x3 (RGB images)
  • Convolutional Layers: Multiple Conv2D layers with ReLU activation
  • Pooling Layers: MaxPooling2D for dimensionality reduction
  • Dropout Layers: Regularization to prevent overfitting
  • Dense Layers: Fully connected layers for classification
  • Output Layer: 38 classes (softmax activation)

Model Details

  • Total Parameters: ~59 million
  • Training Accuracy: ~65%
  • Validation Accuracy: ~81%
  • Test Accuracy: ~65%

Model File Download

The trained model file (Team3model.h5) is available for download:

πŸ“₯ Download Team3model.h5

Important:

  • The model file is not included in the repository due to its large size
  • You must download it separately and place it in the project root directory
  • The file must be named Team3model.h5 for the application to work

🎨 UI/UX Features

Design System

  • Primary Color: Deep Forest Green (#2D5A27)
  • Accent Color: Earthy Gold (#D4A373)
  • Background: Clean Off-White (#F8F9FA)
  • Typography: Inter font family
  • Border Radius: 16px for modern look

Key UI Components

  1. Sticky Navigation Bar: Always accessible navigation
  2. Card-Based Layout: Clean, organized content cards
  3. Health Report Style Results: Professional disease report display
  4. Scanning Animation: Visual feedback during image processing
  5. Tabbed Interface: Easy navigation between fertilizer and tips
  6. Responsive Grid: Adapts to screen size

Animations

  • Fade-in: Smooth page load animations
  • Scanning Line: Green laser scan over uploaded images
  • Button Hover: Scale and shadow effects
  • Smooth Transitions: All interactive elements

πŸ”Œ API Endpoints

Routes

Method Endpoint Description
GET / Redirects to login page
GET/POST /login Login page and authentication
GET /home Home page with features and supported plants
GET/POST /disease-recognition Disease detection page (upload/camera)
GET /logout Logout and redirect to login

Form Submission

  • Endpoint: /disease-recognition
  • Method: POST
  • Content-Type: multipart/form-data
  • Field: file (image file)
  • Response: Renders prediction page with results

πŸ“Š Treatment Recommendations

Each disease includes:

🌾 Fertilizer Recommendations

  • Specific fertilizer types (e.g., Potassium Sulfate, NPK 10-10-10)
  • Application methods and timing
  • Nutrient requirements

πŸ’‘ Treatment Tips

  • Cultural practices
  • Chemical treatments
  • Prevention strategies
  • Environmental management

Examples:

  • Bacterial Diseases: Copper-based bactericides, pathogen-free seeds
  • Fungal Diseases: Fungicides, proper spacing, crop rotation
  • Viral Diseases: Vector control, resistant varieties
  • Healthy Plants: Maintenance recommendations

πŸ“± Responsive Design

Mobile (< 992px)

  • Hamburger menu navigation
  • Single-column stacked layout
  • Full-width buttons (95% screen width)
  • Large touch targets (50px minimum)
  • Camera view optimized for mobile
  • Vertical scrolling only

Desktop (β‰₯ 992px)

  • Full navigation bar
  • Two-column layout for upload/camera
  • Standard button sizes
  • Side-by-side content arrangement
  • Optimized spacing and padding

πŸ”’ Security Features

  • Session Management: Flask sessions for user authentication
  • File Upload Security: Secure filename handling
  • Input Validation: Form validation on client and server
  • Error Handling: Graceful error messages

🚧 Future Enhancements

Potential improvements:

  • User authentication system
  • Disease history tracking
  • Export reports (PDF)
  • Multi-language support (Telugu ready)
  • Batch image processing
  • Disease severity assessment
  • Treatment cost calculator
  • Integration with agricultural databases

🀝 Contributing

Contributions are welcome! Please feel free to:

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Submit a pull request

πŸ“„ License

This project is open-source and free to use under the MIT License.


πŸ‘¨β€πŸ’» Development

Running in Development Mode

The application runs with debug=True by default, enabling:

  • Auto-reload on code changes
  • Detailed error messages
  • Development server

Production Deployment

For production, set debug=False in app.py:

if __name__ == '__main__':
    app.run(debug=False, host='0.0.0.0', port=5000)

πŸ“ž Support

For issues, questions, or contributions, please open an issue on the repository.


🌾 Empowering farmers with AI-powered plant disease detection
Β© 2025 Plant Disease Classification System – All rights reserved.

About

Deep learning-based web app that classifies plant leaf diseases using a CNN model with 90%+ accuracy. Built with Python, Flask, and HTML/CSS for real-time agricultural support.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors