AI-powered plant disease detection from leaf images. Upload a photo and get instant diagnosis with treatment recommendations.
- 🖼️ Drag-and-drop image upload with instant preview
- 🔬 38 disease classes across 14 crop species (PlantVillage dataset)
- 🧠 EfficientNetB3 deep learning model with transfer learning
- 💊 Treatment recommendations for every detected disease
- 📊 Confidence scores with animated progress bars
- 📱 Responsive design — works on desktop and mobile
- 🐳 Docker support for one-command deployment
- Python 3.11+ and pip
- Node.js 20+ and npm
cd backend
pip install -r requirements.txt
uvicorn app.main:app --reload --port 8000
⚠️ The backend will print a warning if no trained model is found atbackend/model/plant_disease_model.h5. The/predictendpoint returns HTTP 503 until a model is provided.
cd frontend
npm install
npm run devOpen http://localhost:3000 in your browser.
cd backend
python train.py /path/to/plantvillage/dataset --epochs 10The dataset directory should have one sub-folder per class:
dataset/
├── Apple___Apple_scab/
├── Apple___Black_rot/
├── ...
└── Tomato___healthy/
The trained model is saved to backend/model/plant_disease_model.h5.
docker-compose up --build| Service | URL |
|---|---|
| Frontend | http://localhost:3000 |
| Backend | http://localhost:8000 |
| Health | http://localhost:8000/health |
leafscan/
├── backend/
│ ├── app/
│ │ ├── main.py # FastAPI entry point
│ │ ├── routes/predict.py # /predict and /health endpoints
│ │ ├── services/model.py # Model loading & inference
│ │ ├── services/disease_info.py # 38-class disease mapping
│ │ └── utils/image_utils.py # Image preprocessing
│ ├── model/ # Trained model (gitignored)
│ ├── train.py # Model training script
│ ├── requirements.txt
│ └── Dockerfile
├── frontend/
│ ├── src/
│ │ ├── components/ # Navbar, ImageUploader, ResultCard
│ │ ├── pages/ # Home, About
│ │ ├── api/predict.js # Axios API client
│ │ ├── App.jsx
│ │ └── main.jsx
│ ├── tailwind.config.js
│ ├── package.json
│ └── Dockerfile
├── docker-compose.yml
└── README.md
| Layer | Technology |
|---|---|
| Frontend | React 18, Vite, Tailwind CSS |
| Backend | Python 3.11, FastAPI, Uvicorn |
| ML Model | TensorFlow / Keras, EfficientNetB3 |
| Deploy | Docker, Docker Compose, Nginx |
Returns {"status": "ok"}.
| Parameter | Type | Description |
|---|---|---|
file |
File | Leaf image (JPEG/PNG) |
Response:
{
"predicted_class": "Tomato___Early_blight",
"confidence": 0.97,
"plant": "Tomato",
"disease": "Early Blight",
"is_healthy": false,
"treatment": "Apply copper-based fungicide. Remove affected leaves."
}MIT