(Deep Learning + FastAPI + Streamlit)
An Plant Disease Detection and Treatment System using PyTorch, ResNet-18, FastAPI REST API, and Streamlit UI. Upload a leaf image and instantly receive:
✔ Disease name ✔ Disease description ✔ Chemical treatment recommendations ✔ Bio-organic treatment suggestions ✔ Confidence score
🌐 Live Streamlit App
🚀 Try the Plant Disease Detection App here: 👉 https://plant-pest-disease-detection.streamlit.app/
- Fine-tuned ResNet-18 classifier
- Trained in Google Colab (dataset loading, augmentation, splits, training loops visible in your training PDF)
- Clean prediction formatting
- High-confidence softmax output
-
/predict/REST endpoint -
Accepts image → returns disease info
-
Handles:
- disease formatting
- treatment cleaning
- bio-organic treatment splitting
- User uploads image
- Displays model output neatly
- Shows treatments as bullet lists
- Clean centered UI
-
Reads
Treatment_dataset.csv -
Fetches:
- disease description
- chemical treatments
- bio/organic solutions
📦 plant-disease-detection
├── backend/
│ ├── main.py # FastAPI backend
│ ├── plant_disease_model.pth # Trained model
│ ├── Treatment_dataset.csv # Treatment data
├── frontend/
│ ├── app.py # Streamlit UI
├── notebooks/
│ ├── plant_disease_training.pdf
├── assets/
│ ├── plant_disease_demo.gif # (Add your GIF here)
└── README.md
Your included training notebook (PDF) contains:
- Reads plant disease folders
- Maps classes automatically
- Displays sample leaves (page 3 of your notebook)
- Train / Test / Validation (stratified)
- Resize
- Random Flip
- Random Rotation
- Normalization
- (Same transforms used in prediction)
- ResNet-18
- Custom final linear layer replacing the original
- Adam optimizer
- CrossEntropyLoss
- Forward → backward → optimizer step
- Epoch logging for training/validation
git clone https://github.com/your-username/plant-disease-detection.git
cd plant-disease-detection
pip install -r requirements.txt
Dependencies include:
fastapi
uvicorn
torch
torchvision
pandas
pillow
streamlit
cd backend
uvicorn main:app --host 0.0.0.0 --port 8000
POST /predict/ Send an image → receive prediction.
Response:
{
"prediction": {
"disease": "Strawberry - Leaf Scorch",
"description": "Fungal disease causing brown spots...",
"treatments": [
"Copper oxychloride 50% WP",
"Thiophanate methyl 70% WP"
],
"bio_treatments": [
"Neem oil 5ml/liter",
"Trichoderma viride 2g/liter"
]
},
"confidence": 0.96
}cd frontend
streamlit run app.py
Streamlit UI will open in the browser.
| Component | Technology |
|---|---|
| Model Training | PyTorch |
| Backend | FastAPI |
| Frontend | Streamlit |
| Deployment | Streamlit Cloud |
| Dataset | Custom Plant Disease Dataset + Treatment CSV |
