Watch the complete system in action — from uploading a plant leaf image to disease prediction, confidence score, treatment/prevention recommendations, fertilizer guidance, and prediction history.
https://github.com/user-attachments/assets/c9a22658-1487-4bd1-a0cc-2c4a18fd5279
Plant Disease Detection System is a full-stack AI application that combines Deep Learning, Computer Vision, and Web Technologies to identify plant diseases from leaf images.
The system uses a MobileNetV2-based Convolutional Neural Network (CNN) trained on the PlantVillage dataset and provides:
This project is designed for:
┌─────────────────┐
│ React Frontend │
│ (Vite) │
└────────┬────────┘
│ Axios API Calls
▼
┌─────────────────────┐
│ Django REST API │
│ (DRF Backend) │
└────────┬────────────┘
│
▼
┌─────────────────────┐
│ TensorFlow Model │
│ MobileNetV2 CNN │
└────────┬────────────┘
│
▼
┌─────────────────────┐
│ SQLite/PostgreSQL │
└─────────────────────┘
| Plant | Classes |
|---|---|
| Apple | 4 |
| Blueberry | 1 |
| Cherry | 2 |
| Corn | 4 |
| Grape | 4 |
| Orange | 1 |
| Peach | 2 |
| Pepper | 2 |
| Potato | 3 |
| Raspberry | 1 |
| Soybean | 1 |
| Squash | 1 |
| Strawberry | 2 |
| Tomato | 10 |
✅ 38 Plant Disease Classes
[ Upload Plant Image ]

Disease:
Tomato Early Blight
Confidence:
98.74%
Treatment:
Apply Copper Fungicide
Prevention:
Crop Rotation

Image | Disease | Confidence | Date

Disease
Description
Symptoms
Treatment
Prevention
—
Plant-Disease-Detection/
│
├── backend/
│ │
│ ├── settings.py
│ ├── urls.py
│ └── wsgi.py
│
├── frontend/
│ │
│ ├── src/
│ │ ├── api/
│ │ │ └── api.js
│ │ │
│ │ ├── components/
│ │ │ ├── Navbar.jsx
│ │ │ ├── ImageUploader.jsx
│ │ │ ├── PredictionCard.jsx
│ │ │ ├── HistoryCard.jsx
│ │ │ └── Loading.jsx
│ │ │
│ │ ├── pages/
│ │ │ ├── Home.jsx
│ │ │ ├── History.jsx
│ │ │ └── DiseaseInfo.jsx
│ │ │
│ │ ├── App.jsx
│ │ ├── main.jsx
│ │ └── index.css
│ │
│ ├── package.json
│ └── vite.config.js
│
├── predictions/
│ ├── migrations/
│ ├── models.py
│ ├── serializers.py
│ ├── views.py
│ ├── urls.py
│ └── admin.py
│
├── media/
├── models/
│ ├── plant_disease_model.keras
│ ├── plant_disease_model.h5
│ └── class_names.json
│
├── requirements.txt
├── screenshots/
├── download_data.py
├── manage.py
├── predict.py
├── train_with_evaluate.py
└── README.md
git clone https://github.com/buildwithsomnath/plant-disease-detection.git
cd plant-disease-detection
python -m venv venv
venv\Scripts\activate
python -m venv venv
source venv/bin/activate
pip install -r requirements.txt
python manage.py makemigrations
python manage.py migrate
python manage.py createsuperuser
python manage.py runserver
Backend URL:
http://127.0.0.1:8000
cd frontend
npm install
npm run dev
Frontend URL:
http://localhost:5173
/api/predict/
curl -X POST \
-F "image=@leaf.jpg" \
http://localhost:8000/api/predict/
{
"success": true,
"prediction": {
"disease": "Tomato___Early_blight",
"confidence": 98.74,
"plant_type": "Tomato",
"description": "...",
"treatment": "...",
"fertilizer": "...",
"prevention": "..."
}
}
/api/history/
/api/history/<id>/
/api/diseases/
/api/diseases/<id>/
Input Image
│
▼
Resize 224x224
│
▼
MobileNetV2
│
▼
Global Average Pooling
│
▼
Dense Layer
│
▼
Dropout
│
▼
38-Class Softmax
| Metric | Value |
|---|---|
| Dataset | PlantVillage |
| Images | 54,000+ |
| Classes | 38 |
| Input Size | 224x224 |
| Framework | TensorFlow |
| Model | MobileNetV2 |
| Accuracy | ~81–84% |
Deploy on:
npm run build
Deploy on:
Install:
pip install gunicorn
Create Procfile:
web: gunicorn backend.wsgi
Create .env
SECRET_KEY=your-secret-key
DEBUG=False
ALLOWED_HOSTS=localhost,127.0.0.1
MODEL_PATH=models/plant_disease_model.keras
MAX_UPLOAD_SIZE=5242880
Contributions are welcome.
git checkout -b feature/new-feature
git commit -m "Added feature"
git push origin feature/new-feature
GitHub:
https://github.com/buildwithsomnath
LinkedIn:
https://linkedin.com/in/buildwithsomnath
Email:
somnathdas4462@gmail.com
If you found this project helpful:
⭐ Star the repository
🍴 Fork the project
📢 Share with others