Skip to main content
ProjectsLeaf Inference Engine

Project 11 / 12

Deep Learning CV Pipeline

Leaf Inference Engine

Plant disease detector: point a camera at a leaf and get a diagnosis. A custom CNN classifies 38 disease states at roughly 95% accuracy, served through a FastAPI backend that a Next.js proxy calls without ever exposing the model API directly.

plant-leaf-detection-production.up.railway.app
Leaf Inference Engine preview
Stack
TensorFlowFastAPIStreamlit
Modules
4
Key decisions
2

01Problem

What was broken

Farmers needed a fast, low-latency way to diagnose plant disease from a photo, without specialized agricultural equipment or reliable network access in rural areas.

02Impact

What it does now

A CNN trained on roughly 87,000 leaf images across 38 disease classes reaches about 95% accuracy on held-out images. The Next.js frontend never talks to the model directly; it goes through a proxy that keeps the FastAPI endpoint and its keys off the client.

03Architecture

How it is built

Training happens offline and produces a standard .h5 model file. In production, the Next.js server proxy holds the API keys and forwards requests to a FastAPI service running on Railway, which loads that Keras model into memory and serves inference from it.

Modules

  • CNN Model Builder
  • Vercel UI Proxy
  • FastAPI Inference Node
  • Heuristic Rejector

04Intelligence

Where the AI sits

A heuristic check rejects non-leaf images before inference runs, so a photo of a hand or a wall doesn't come back as a confident wrong diagnosis. A Gemini-powered companion then suggests organic treatment options for whatever gets identified.

05Decisions

Trade-offs I chose

  1. 01

    Proxy Security Layer

    The FastAPI endpoints and API keys never reach the browser. The Next.js API layer forwards multipart form data to Railway, so a client can't hit the inference endpoint directly or see what key it's using.

  2. 02

    Single Source Data Pipeline

    config.py and data_pipeline.py are the single source for preprocessing constraints, used both when the dataset gets compiled and when a live image gets validated. The same resize and normalization logic runs in training and production, so there's no drift between the two.