AgriCv / README.md
datawizard116's picture
Update README.md
a7582e7 verified
|
Raw
History Blame Contribute Delete
6.83 kB

A newer version of the Gradio SDK is available: 6.20.0

Upgrade
metadata
title: AgriVision AI
emoji: 🌿
colorFrom: green
colorTo: blue
sdk: gradio
sdk_version: 5.34.2
python_version: '3.10'
app_file: app.py
pinned: false

🌿 AgriVision AI β€” Plant Disease Detection using Deep Learning

AgriVision AI is an end-to-end Deep Learning + Computer Vision project that detects plant diseases from leaf images using Transfer Learning with EfficientNetB0.

The system predicts 38 different plant disease categories with high accuracy and provides:

  • Disease Prediction
  • Confidence Scores
  • Grad-CAM Visualization
  • Disease Description
  • Symptoms
  • Prevention Methods
  • Cure Suggestions

Built using TensorFlow, OpenCV, EfficientNet, and Gradio.


πŸš€ Features

βœ… Plant Disease Detection using AI βœ… 38 Disease Categories βœ… Transfer Learning with EfficientNetB0 βœ… Fine-Tuned Deep Learning Model βœ… Leaf Segmentation for Better Predictions βœ… Grad-CAM Explainability Visualization βœ… Top-3 Predictions with Confidence Bars βœ… Disease Information & Cure Suggestions βœ… Interactive Gradio Web Application βœ… Real-Time Image Prediction System


🧠 Problem Statement

Plant diseases significantly reduce agricultural productivity and crop quality.

Traditional disease identification:

  • requires expert knowledge
  • is time-consuming
  • may delay treatment

AgriVision AI helps farmers and researchers instantly identify plant diseases using leaf images.


🌱 Why This Project Matters

This project combines:

  • Artificial Intelligence
  • Agriculture
  • Deep Learning
  • Computer Vision
  • Explainable AI

Applications:

  • Smart Farming
  • Precision Agriculture
  • AI-Based Crop Monitoring
  • Agricultural Decision Support Systems

πŸ—οΈ Project Workflow

Leaf Image
   ↓
Leaf Segmentation
   ↓
Image Preprocessing
   ↓
EfficientNetB0 Model
   ↓
Disease Prediction
   ↓
Grad-CAM Visualization
   ↓
Disease Information & Cure Suggestions

πŸ› οΈ Tech Stack

Programming Language

  • Python

Deep Learning Frameworks

  • TensorFlow
  • Keras

Computer Vision

  • OpenCV
  • Grad-CAM

Deployment

  • Gradio

Image Processing

  • NumPy
  • Pillow
  • rembg

πŸ“‚ Dataset

PlantVillage Dataset

  • 54,000+ Images
  • 38 Classes
  • Multiple Crops & Diseases

Dataset Source: https://www.kaggle.com/datasets/emmarex/plantdisease


πŸ“Š Disease Categories

The model supports 38 classes including:

  • Apple Diseases
  • Corn Diseases
  • Tomato Diseases
  • Potato Diseases
  • Grape Diseases
  • Strawberry Diseases
  • Peach Diseases
  • Pepper Diseases
  • Soybean Diseases
  • Healthy Leaf Detection

πŸ§ͺ Model Development Phases

Phase 1 β€” Dataset Preparation

Performed:

  • Data Loading
  • Train/Validation Split
  • Image Augmentation

Techniques:

  • Rotation
  • Zoom
  • Horizontal Flip
  • Rescaling

Phase 2 β€” Baseline CNN Model

Built a custom CNN using:

  • Conv2D
  • MaxPooling
  • BatchNormalization
  • Dropout
  • Dense Layers

Purpose:

  • Establish baseline performance
  • Understand CNN workflow

Phase 3 β€” Transfer Learning

Used:

EfficientNetB0

Advantages:

  • Better Feature Extraction
  • Higher Accuracy
  • Fewer Parameters
  • Faster Training

Initially froze pretrained layers.


Phase 4 β€” Fine Tuning

Unfroze upper EfficientNet layers and retrained using:

  • Low Learning Rate
  • Additional Epochs

Result: βœ… Significant performance improvement


πŸ“ˆ Final Results

Metric Value
Validation Accuracy 96%
Model EfficientNetB0
Classes 38
Dataset Size 54K+ Images
Framework TensorFlow/Keras

πŸ” Explainable AI with Grad-CAM

Grad-CAM highlights regions of the image influencing model predictions.

Benefits:

  • Improves transparency
  • Helps visualize model focus
  • Makes predictions explainable

βœ‚οΈ Leaf Segmentation

Implemented background removal using:

rembg

Benefits:

  • Reduces background noise
  • Improves internet image prediction
  • Better real-world generalization

🌐 Web Application

Built using:

Gradio

Features:

  • Upload Leaf Image
  • View Top Predictions
  • Confidence Bars
  • Grad-CAM Heatmap
  • Disease Information
  • Cure Suggestions

πŸ“ Project Structure

Plant_Disease/
β”‚
β”œβ”€β”€ app.py
β”œβ”€β”€ README.md
β”œβ”€β”€ requirements.txt
β”œβ”€β”€ .gitignore
β”‚
β”œβ”€β”€ utils/
β”‚   β”œβ”€β”€ predict.py
β”‚   β”œβ”€β”€ gradcam.py
β”‚   β”œβ”€β”€ segmentation.py
β”‚   └── disease_info.py
β”‚
β”œβ”€β”€ sample_images/
β”‚
└── notebooks/

βš™οΈ Installation

1. Clone Repository

git clone YOUR_GITHUB_REPO_LINK
cd Plant_Disease

2. Create Virtual Environment

python -m venv venv

3. Activate Environment

Windows

venv\Scripts\activate

Mac/Linux

source venv/bin/activate

4. Install Dependencies

pip install -r requirements.txt

πŸ“₯ Download Trained Model

Due to GitHub file size limitations, the trained model is hosted externally.

Download Model Here: _Click_HERE

After downloading, place the model inside:

Plant_Disease/
β”‚
β”œβ”€β”€ final_agrivision_model.keras
β”œβ”€β”€ app.py
└── utils/

▢️ Run Application

python app.py

Application runs at:

http://127.0.0.1:7860

πŸ“¦ Required Libraries

tensorflow
opencv-python
gradio
numpy
pillow
matplotlib
rembg
onnxruntime

🧠 Key Learnings

Through this project I learned:

  • Transfer Learning
  • EfficientNet Architecture
  • CNN Fundamentals
  • Fine Tuning
  • Grad-CAM Explainability
  • Leaf Segmentation
  • Deep Learning Deployment
  • Real-World Image Challenges
  • Domain Shift Problems
  • Model Generalization

⚠️ Real-World Challenges

The model performs strongly on PlantVillage-style images.

Challenges with internet images include:

  • Complex backgrounds
  • Different lighting conditions
  • Blurry images
  • Domain shift
  • Real-world variability

Future improvements:

  • Real farm dataset training
  • Lesion segmentation
  • Higher resolution models
  • Advanced explainability techniques

πŸš€ Future Improvements

  • Mobile App Deployment
  • Multi-Language Support
  • Real-Time Webcam Detection
  • Cloud Deployment
  • Disease Severity Estimation
  • PDF Report Generation
  • Advanced Explainability Methods
  • Farmer Advisory System

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

Mohd Faizanullah

AI/ML Enthusiast | Deep Learning | Computer Vision | Generative AI


⭐ Support

If you like this project, give it a star ⭐ on GitHub.