LeafLens — Multitask Plant Disease Analyzer
One TensorFlow/Keras model, one forward pass: segments the leaf and diagnoses it at the same time.
A user uploads a single crop-leaf photo and gets two answers from one model in one forward pass:
- Where the leaf is — a pixel mask separating leaf from background (segmentation), shown as an overlay.
- 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:
| Task | Metric | Score |
|---|---|---|
| Segmentation | IoU (705 validation images) | 0.58 |
| Segmentation | Dice | 0.66 |
| Classification | Accuracy (236 held-out images, 28 classes) | 37% |
Tech stack
| Layer | Choice |
|---|---|
| ML / training | Python 3.11+ · TensorFlow/Keras · numpy · scikit-learn · Pydantic |
| Backend | FastAPI · Uvicorn |
| Frontend | React 18 · Vite |
| Containerization | Docker |
The live demo above runs this exact backend; to see the shared-backbone training pipeline and inference API, view the source.