Logo Lanfrica

Bereket-11/Ethiopian-coffee-leaf-disease-detector

Domaine:

agriculture

Type de record:

modelsoftware
Créateur:
Ber
Hôte:
# Coffee Disease Classifier An explainable coffee leaf disease detection project. The notebook trains and evaluates a PyTorch CNN, the FastAPI backend serves the saved model, and the Next.js UI lets users upload a leaf image, view predictions, confidence scores, farmer guidance, and a Grad-CAM heatmap. ## Features - Classifies coffee leaves into `Cerscospora`, `Healthy`, `Leaf rust`, and `Phoma`. - Uses deterministic test preprocessing for evaluation. - Reports accuracy, macro precision, macro recall, and per-class recall. - Saves the trained PyTorch model to `coffee_disease_model.pth`. - Serves predictions through a FastAPI backend. - Provides a polished Next.js diagnosis UI and a `/presentation` page for project defense. - Adds a `/learn` teaching page that explains the model, libraries, and system flow in non-technical language. - Includes Grad-CAM heatmaps to show which image regions influenced the prediction. ## Project Structure ```text coffee-disease/ ├── backend/ │ └── api.py # FastAPI prediction service ├── UI/ │ ├── app/page.tsx # Main diagnosis UI │ ├── app/learn/ # Non-technical teaching page │ ├── app/presentation/ # Presentation/explanation page │ └── app/api/predict/ # Next.js proxy to FastAPI backend ├── code.ipynb # Training, evaluation, charts, Grad-CAM notebook ├── coffee_disease_model.pth # Saved model checkpoint ├── dataset/ # Local train/test image dataset, gitignored └── README.md ``` ## Requirements - Python 3.12+ - Node.js and npm - A trained model file at `coffee_disease_model.pth` - Dataset folders if you want to retrain or rerun evaluation: ```text dataset/ ├── train/ │ ├── Cerscospora/ │ ├── Healthy/ │ ├── Leaf rust/ │ └── Phoma/ └── test/ ├── Cerscospora/ ├── Healthy/ ├── Leaf rust/ └── Phoma/ ``` ## Python Setup From the project root: ```bash python -m venv .venv .venv/Scripts/python -m pip install --upgrade pip .venv/Scrip …