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) β
βββββββββββββββββββββββββββββββββββββ
- Module A β Disease Detection Model: Pretrained
MobileNetV2transfer learning CNN fine-tuned on 38 plant disease classes (>90% accuracy). - Module B β Severity Estimation Engine: Standalone
estimate_severityalgorithm using HSV color segmentation and lesion area thresholding. - Module C β Crop Yield Regressor:
Random Forest Regressortrained on soil nutrients ($N, P, K$), temperature, and fertilizer ($R^2 = 0.9908, \text{RMSE} = 0.1864$). - 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.
- 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
Inference Providers NEW
This model isn't deployed by any Inference Provider. π Ask for provider support