Live demo

LeafLens — Multitask Plant Disease Analyzer

One TensorFlow/Keras model, one forward pass: segments the leaf and diagnoses it at the same time.

  • Python 3.11+
  • TensorFlow/Keras
  • FastAPI
  • React 18
  • Vite
  • Docker
Segmentation IoU 0.58 · Classification 37% (28 classes)

A user uploads a single crop-leaf photo and gets two answers from one model in one forward pass:

  1. Where the leaf is — a pixel mask separating leaf from background (segmentation), shown as an overlay.
  2. What's wrong with it — the predicted disease / leaf type out of 28 classes (classification), with a confidence score.

It ships as a Python training package, a FastAPI inference service, and a React UI (upload → mask overlay + disease label).

Try it live → — running right here on this site: upload a leaf photo and get the segmentation overlay plus the predicted disease class, from the real multitask model in a single forward pass.

Why this architecture

The original project (LeafDiseaseDetection-DL, a senior Bachelor's project) used two completely separate models: a U-Net for segmentation and a MobileNetV2 classifier for disease. They shared nothing — not weights, not a pipeline, not an inference path. That's wasteful (two full backbones to train and serve) and misses an obvious synergy: knowing where the leaf is should help diagnose it. The multitask redesign trains a single shared backbone on both signals, reducing inference cost and encoding richer visual features from both tasks simultaneously.

Results

Trained on deliberately disjoint datasets — segmentation images had no class labels, classification images had no masks:

TaskMetricScore
SegmentationIoU (705 validation images)0.58
SegmentationDice0.66
ClassificationAccuracy (236 held-out images, 28 classes)37%

Tech stack

LayerChoice
ML / trainingPython 3.11+ · TensorFlow/Keras · numpy · scikit-learn · Pydantic
BackendFastAPI · Uvicorn
FrontendReact 18 · Vite
ContainerizationDocker

The live demo above runs this exact backend; to see the shared-backbone training pipeline and inference API, view the source.