← Back to Projects
Completed
Machine Learning

Coffee Disease Detection

Computer vision classifier that detects four coffee leaf diseases from a photo, built with TensorFlow transfer learning and served through a FastAPI service.

Streamlit demo: if nobody has opened it in a while, it takes a moment to wake up.

Coffee Disease Detection

Main result

96.8%

disease recall on test (EfficientNetB0, 25% of the dataset)

Date

November 15, 2025

Final project, Le Wagon Data Science & AI bootcamp

Team

4 people

Project lead

Objective

Catch coffee leaf diseases early, accepting false alarms over missed infections.

Classifies leaf images into five classes (healthy, Cercospora, Leaf Rust, Miner, Phoma), comparing VGG16, EfficientNetB0 and a custom CNN with runs tracked in MLflow.

Challenges

  1. 01Visually similar diseases in an imbalanced dataset
  2. 02A missed disease costs more than a false alarm
  3. 03Aggressive augmentation can erase the color cues that identify a disease

How it was solved

  1. 01Class weights from the train distribution, with a boost for the rarest disease
  2. 02Custom disease-recall metric that excludes the healthy class, monitored during training
  3. 03Horizontal flips and subtle brightness/contrast only; hue and saturation untouched

Results

  • No diseased test leaf was classified as healthy

Overview

Classifies a coffee leaf photo as healthy or as one of four diseases.

Technical Implementation

Models

VGG16 and EfficientNetB0 with ImageNet weights, plus a lightweight custom CNN. Training runs in two phases, frozen base then fine-tuning, with dropout, early stopping and a learning rate chosen by dataset size. The loader detects the architecture from the saved model’s layers.

Data

Images are letterboxed to 224x224 and split per class into train, validation and test sets.

Serving

FastAPI validates the image format, runs inference on a cached model and returns the top class plus every class probability. The API ships as a Docker image; trained models are uploaded to Google Cloud Storage.

Features

  • Image upload endpoint and health check that reports whether the model is loaded
  • Separate Streamlit app for upload and prediction
  • Evaluation with confusion matrix and false-negative analysis
  • Train, evaluate and predict commands through Make targets

Technologies

  • TensorFlow/Keras
  • VGG16
  • EfficientNetB0
  • FastAPI
  • Streamlit
  • MLflow
  • Docker
  • Google Cloud Storage
  • Python

Impact

A grower photographs a leaf and gets the predicted class with the probability of each class. Training favors a false alarm over a missed disease.

Ask my portfolio

AI

I answer from what's published on this site and link the project each answer comes from. If you'd rather talk to Fer, tell me and I'll pass on your details.