← Back to Projects
Deep Learning

Tomato Leaf Disease Detection

Transfer learning with VGG backbone for accurate classification of tomato leaf diseases using CNN with practical augmentation techniques

TensorFlow Keras VGG16 CNN Transfer Learning Image Processing

Project Overview

This deep learning project addresses a critical challenge in agriculture: early and accurate detection of tomato leaf diseases. Using transfer learning with a pre-trained VGG16 model, the system can identify multiple disease types from leaf images, enabling farmers to take timely action and prevent crop loss.

The model leverages state-of-the-art convolutional neural network architectures and extensive data augmentation to achieve high accuracy even with limited training samples, making it practical for real-world agricultural applications.

Key Features

🧠

Transfer Learning

VGG16 pre-trained on ImageNet provides robust feature extraction for disease patterns

🎯

Multi-class Detection

Identifies 10 different disease categories including healthy leaves for comparison

🔄

Data Augmentation

Rotation, flipping, zoom, and brightness adjustments for model robustness

Fast Inference

Optimized model architecture for quick predictions on edge devices

Disease Categories

✓ Bacterial Spot
✓ Early Blight
✓ Late Blight
✓ Leaf Mold
✓ Septoria Leaf Spot
✓ Spider Mites
✓ Target Spot
✓ Yellow Leaf Curl Virus
✓ Mosaic Virus
✓ Healthy

Model Architecture

Transfer Learning Approach

  • Base Model: VGG16 pre-trained on ImageNet (frozen layers)
  • Custom Layers: Flatten → Dense(512, ReLU) → Dropout(0.5) → Dense(10, Softmax)
  • Input Shape: 224x224x3 RGB images
  • Total Parameters: ~15M (14.7M frozen, 5.3M trainable)
  • Optimizer: Adam with learning rate 0.0001
  • Loss Function: Categorical Crossentropy

Data Preprocessing

  • Image resizing to 224x224 pixels
  • Pixel value normalization (0-1 range)
  • Train-validation-test split: 70-15-15
  • Augmentation: rotation (±20°), width/height shift (±10%), zoom (±15%)
  • Horizontal flip for natural variation

Training Strategy

Fine-tuning Process

  • Stage 1: Train custom layers with frozen VGG16 (20 epochs)
  • Stage 2: Unfreeze last 4 conv blocks of VGG16
  • Stage 3: Fine-tune with lower learning rate (0.00001, 30 epochs)
  • Callbacks: Early stopping, ReduceLROnPlateau, ModelCheckpoint
  • Batch Size: 32 for optimal GPU utilization

Regularization Techniques

  • Dropout layers (0.5) to prevent overfitting
  • L2 weight regularization on dense layers
  • Data augmentation for better generalization
  • Early stopping based on validation loss

Performance Results

94.3%
Validation Accuracy
92.7%
Test Accuracy
0.93
F1-Score

The model demonstrates excellent generalization with minimal overfitting, achieving consistent performance across all disease categories. Confusion matrix analysis shows particularly strong results for Early Blight and Late Blight detection.

Implementation Details

Dataset

  • PlantVillage dataset with 18,000+ tomato leaf images
  • Images captured under controlled lighting conditions
  • Balanced class distribution for fair training
  • Various growth stages and disease severities included

Evaluation Metrics

  • Accuracy, Precision, Recall for each class
  • Confusion matrix for misclassification analysis
  • ROC-AUC curves for multi-class performance
  • Training/validation loss curves for overfitting detection

Challenges & Solutions

Similar Disease Symptoms

Some diseases show visually similar symptoms. Addressed by focusing VGG16 on subtle texture and pattern differences through fine-tuning of deeper layers.

Limited Training Data

Certain disease classes had fewer samples. Implemented aggressive data augmentation and class weight balancing to handle imbalanced dataset.

Real-world Variations

Field conditions differ from controlled images. Added augmentations simulating various lighting, angles, and backgrounds to improve robustness.

Practical Applications

  • Mobile App: Farmers can capture leaf photos and get instant diagnosis
  • Automated Monitoring: Integration with drone imaging for large-scale farm surveillance
  • Early Warning System: Detect diseases before visible to human eye
  • Treatment Recommendations: Suggest appropriate fungicides or management practices
  • Crop Loss Prevention: Timely intervention reduces yield losses by up to 40%
  • Educational Tool: Training resource for agricultural students and extension workers

Future Enhancements

  • Expand to other crop types (potato, pepper, cucumber)
  • Real-time video stream analysis for continuous monitoring
  • Multi-disease detection in single image
  • Disease progression tracking over time
  • Integration with weather data for predictive modeling
  • Severity assessment (mild, moderate, severe)
  • Edge deployment on Raspberry Pi or mobile devices
  • Explainable AI with Grad-CAM visualization