AI-Based Multi-Crop Disease Severity & Yield-Risk Prediction System

An end-to-end Machine Learning project featuring three linked prediction models feeding a rule-based Yield-Risk Fusion Engine, wrapped in an interactive single-page Streamlit Application.


🌟 Features & System Architecture

                               β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                               β”‚       User Uploads Leaf Image     β”‚
                               β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                                 β”‚
                        β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                        β–Ό                                                 β–Ό
        β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”               β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
        β”‚  Module A β€” Disease Detection β”‚               β”‚   Module B β€” Severity Estimation  β”‚
        β”‚  MobileNetV2 Transfer CNN     β”‚               β”‚   HSV Color & Lesion Area Proxy   β”‚
        β”‚  (38 Crop & Disease Classes)  β”‚               β”‚   (Healthy / Mild / Mod / Severe) β”‚
        β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜               β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                        β”‚                                                 β”‚
                        β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                                 β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”            β”‚
β”‚  User Soil & Climate Inputs       β”‚            β”‚
β”‚  (Temp, N, P, K, Fertilizer)      β”‚            β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜            β”‚
                  β”‚                              β”‚
                  β–Ό                              β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”            β”‚
β”‚   Module C β€” Yield Prediction     β”‚            β”‚
β”‚   Random Forest / XGBoost Regr.   β”‚            β”‚
β”‚   (Expected Yield in tonnes/ha)   β”‚            β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜            β”‚
                  β”‚                              β”‚
                  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜
                                         β”‚
                                         β–Ό
                       β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                       β”‚  Module D β€” Yield-Risk Fusion     β”‚
                       β”‚  Rule-Based Matrix & Recommender  β”‚
                       β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                         β”‚
                                         β–Ό
                       β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                       β”‚   Final Streamlit Report Card     β”‚
                       β”‚   (6 Outputs + Lesion Overlay)    β”‚
                       β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
  1. Module A β€” Disease Detection Model: Pretrained MobileNetV2 transfer learning CNN fine-tuned on 38 plant disease classes (>90% accuracy).
  2. Module B β€” Severity Estimation Engine: Standalone estimate_severity algorithm using HSV color segmentation and lesion area thresholding.
  3. Module C β€” Crop Yield Regressor: Random Forest Regressor trained on soil nutrients ($N, P, K$), temperature, and fertilizer ($R^2 = 0.9908, \text{RMSE} = 0.1864$).
  4. Module D β€” Yield-Risk Fusion Engine: Explainable rule matrix combining disease diagnosis, severity percentage, and expected yield vs historical benchmark ($8.53\text{ t/ha}$) to generate a 5-tier Risk Badge and 1-line actionable recommendation.
  5. Streamlit Interactive UI: Single-page web dashboard displaying side-by-side leaf image + segmented lesion mask alongside 6 live result cards.

πŸ“ Directory Structure

plant disese detection and crop yeld prediction/
β”œβ”€β”€ data/
β”‚   β”œβ”€β”€ disease/        # 38 Crop-Disease class folders (train/valid)
β”‚   β”œβ”€β”€ severity/       # Plant Pathology 2021 competition dataset
β”‚   └── yield/          # Crop Yiled with Soil and Weather.csv
β”œβ”€β”€ models/
β”‚   β”œβ”€β”€ disease_model.h5    # MobileNetV2 Keras CNN Model
β”‚   β”œβ”€β”€ disease_labels.json # Index to Disease Class Mapping
β”‚   β”œβ”€β”€ yield_model.pkl     # Fitted Random Forest Regressor
β”‚   β”œβ”€β”€ yield_scaler.pkl    # StandardScaler for Soil Features
β”‚   └── yield_stats.pkl     # Benchmark Yield Statistics
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ __init__.py
β”‚   β”œβ”€β”€ disease_detection.py # Module A training & inference
β”‚   β”œβ”€β”€ severity_estimation.py # Module B HSV lesion segmentation
β”‚   β”œβ”€β”€ yield_prediction.py # Module C regression training & evaluation
β”‚   └── risk_engine.py      # Module D yield-risk rule fusion engine
β”œβ”€β”€ app/
β”‚   └── main.py             # Streamlit Application Dashboard
β”œβ”€β”€ tests/
β”‚   └── test_severity.py    # Unit tests for severity estimation proxy
β”œβ”€β”€ requirements.txt        # Python package dependencies
└── README.md               # User guide & execution instructions

πŸš€ Setup & Execution Instructions

1. Install Dependencies

pip install -r requirements.txt

2. Run Module Unit Tests

python -m pytest tests/test_severity.py -s

3. Launch Streamlit Application

streamlit run app/main.py
Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support