Skip to content

Soyebsoyeb/Maize_Disease_Classification

Repository files navigation

Dataset 1 : /kaggle/input/corn-or-maize-leaf-disease-dataset/data

🌽 Maize Leaf Disease Classification


πŸ“ Dataset Info

  • Dataset Path: /kaggle/input/corn-or-maize-leaf-disease-dataset/data
  • Detected Classes:
    • 🌱 Blight
    • πŸ‚ Common Rust
    • 🍁 Gray Leaf Spot
    • βœ… Healthy

πŸ”„ Dataset Split

Split Percentage
πŸ‹οΈβ€β™‚οΈ Training 80%
πŸ§ͺ Validation 10%
🧾 Test 10%

πŸ€– Project Objective

This program classifies maize leaf images into the above four categories using:

  • πŸ“· CNN with MobileNetV2
  • 🧠 CBAM (Convolutional Block Attention Module) for better feature attention
  • πŸ’‘ Support Vector Machine (SVM) on extracted features to enhance classification performance

🧠 CBAM Attention Module

CBAM helps the network focus on important regions of the image.

πŸ“Œ Structure

  • πŸ”΄ Channel Attention
    GlobalAvgPool + GlobalMaxPool β†’ MLP β†’ Add + Sigmoid

  • πŸ”΅ Spatial Attention
    Channel-wise mean/max β†’ Concat β†’ Conv2D β†’ Sigmoid

βœ… This is implemented in the function cbam_block(input_feature)


🧬 Full Architecture

Input β†’ MobileNetV2 β†’ CBAM β†’ GAP β†’ Dense(256) β†’ BN β†’ Dropout(0.5) ↓ Dense(128) β†’ BN β†’ Dropout(0.5) ↓ Dense(4, softmax)


πŸ‹οΈβ€β™‚οΈ Training Results

Metric Value
🎯 Accuracy 97.16%
πŸ“‰ Final Loss 0.4247
⏱️ Epochs ~41

πŸ“ˆ Training Graph: Accuracy and loss plotted across epochs.


πŸ“Š Evaluation (CNN Output)

Class Precision Recall F1-Score Support
🌱 Blight 0.96 0.93 0.95 116
πŸ‚ Common_Rust 1.00 1.00 1.00 132
🍁 Gray_Leaf_Spot 0.87 0.93 0.90 58
βœ… Healthy 1.00 1.00 1.00 117
Weighted Avg 0.97 0.97 0.97 423

πŸ“Š Confusion Matrix: Displayed using Seaborn heatmap.


βœ… Final Summary

πŸ” Component πŸ”’ Result/Value
🎯 Deep Model Accuracy 97.16%
🧠 SVM Accuracy 98.11%
🧩 Base Architecture MobileNetV2 + CBAM
πŸ“ Feature Dimension 128
πŸ‹οΈ Training Images 3348
🧾 Test Images 423
πŸ† Best Classifier SVM on features
❌ Misclassifications Minimal (mostly in Gray Leaf Spot)

Dataset 2: /kaggle/input/maizeleaf/MaizeLeafDataset

🌽 Maize Leaf Disease Classification – Advanced (5-Class)


1. Dataset and Preprocessing

πŸ“‚ Dataset Structure

  • Source: /kaggle/input/maizeleaf/MaizeLeafDataset
  • Classes:
    • πŸ‚ Common Rust
    • 🍁 Gray Leaf Spot
    • βœ… Healthy
    • 🌫️ Northern Leaf Blight
    • ❌ Not Maize Leaf

πŸ“Έ Sample Visualization

  • 4 random images per class displayed using matplotlib to ensure data integrity.

πŸ”€ Dataset Splitting

Split Percentage Destination Folder
πŸ‹οΈβ€β™‚οΈ Train 80% /kaggle/working/split_data/train/
πŸ§ͺ Validation 10% /kaggle/working/split_data/val/
🧾 Test 10% /kaggle/working/split_data/test/

2. Image Data Generators (Augmentation)

  • Training Generator includes:

    • rescale, rotation_range, horizontal_flip, vertical_flip, brightness_range, zoom_range, fill_mode
  • Validation & Test:

    • Only rescale
  • Output Shape: (224, 224, 3)

  • Labels: One-hot encoded


3. 🧠 CBAM Attention Mechanism

The Convolutional Block Attention Module (CBAM) improves the model’s ability to focus on relevant leaf regions.

πŸ” Module Structure:

  • πŸ”΄ Channel Attention:
    GlobalAvgPool + GlobalMaxPool β†’ MLP β†’ Add β†’ Sigmoid
  • πŸ”΅ Spatial Attention:
    Mean + Max β†’ Concatenate β†’ Conv2D β†’ Sigmoid

πŸ’‘ Integrated via cbam_block(input_feature) into the main model.


4. πŸ— Model Architecture

πŸ“ Structure:

Input β†’ MobileNetV2 β†’ CBAM β†’ GAP β†’ Dense(256) β†’ BN β†’ Dropout(0.5) ↓ Dense(128) β†’ BN β†’ Dropout(0.5) ↓ Dense(5, softmax)

  • 🧠 Backbone: MobileNetV2 (include_top=False, pretrained on ImageNet)
  • πŸ”§ Trainable Parameters: ~3M
  • πŸ§ͺ Activation: softmax
  • πŸ“‰ Loss: CategoricalCrossentropy (with label_smoothing=0.1)
  • βš™οΈ Optimizer: Adam (lr=0.001)

🧬 Callbacks:

  • EarlyStopping(patience=5)
  • ReduceLROnPlateau

5. πŸ‹οΈ Training Pipeline

  • πŸ“ˆ Training completed in ~45 epochs
  • βœ… Final Validation Accuracy: ~99.66%
  • πŸ’Ύ Model saved as: final_trained_model.h5

6. πŸ“Š Evaluation (CNN)

πŸ“‰ Test Results:

  • Loss: ~0.43
  • Accuracy: ~99.00%

πŸ“Œ Classification Metrics:

Metric Value
🎯 Precision (weighted) 0.9903
πŸ” Recall (weighted) 0.9899
🧠 F1-Score (weighted) 0.9899

πŸ” Confusion Matrix:

  • Visualized using Seaborn heatmap
  • Minimal misclassification across all 5 classes

βœ… 7. πŸ“¦ Feature Extraction (CNN + SVM Hybrid)

  • 🧬 Output: 128-dimensional feature vector per image (from CBAM-enhanced MobileNetV2)

πŸ“Œ Feature Shapes

Set Shape
πŸ‹οΈ Train (7079, 128)
🧾 Test (891, 128)

πŸ“ˆ Performance

πŸ§ͺ Metric πŸ“Š Value
🎯 Test Accuracy 99.44%
🧠 F1, Precision, Recall > 0.98 for all classes

πŸš€ SVM slightly outperforms the CNN softmax classifier!


βœ… Conclusion & Summary

🧩 Component πŸ’‘ Description
πŸ— Model Backbone MobileNetV2 (ImageNet pre-trained) + CBAM
🧠 Classification Softmax and SVM (on extracted 128-dim features)
πŸ–ΌοΈ Input Size 224x224 RGB
πŸ”„ Data Augmentation βœ… Applied to training set
πŸ”Ž CBAM βœ… Channel + Spatial attention
🎯 Final Accuracy ~99.4% (combined CNN + SVM performance)
🌽 Use Case Maize Leaf Disease Classification
πŸš€ Deployment Ready βœ… Saved model (.h5) and feature extractor exported

About

No description, website, or topics provided.

Resources

Stars

3 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors