Tea Grading System: Edge-AI Quality Grading
From a lit capture box to an on-device grade, end to end
Project Overview
The Tea Grading System grades processed tea from images using computer vision, and is built to run on the factory floor on a self-contained, Jetson-powered capture box rather than in the cloud. It's a complete MLOps pipeline—six sequential stages, each an independently runnable module with its own tests and walkthrough notebook—that takes a photographed sample all the way to a real-time grade and business-intelligence signals.
The Rig
A grade is only as good as the image it's made from, so the front end is a purpose-built piece of hardware, not a webcam on a desk:
- A Jetson Nano runs capture, inference, and the on-unit display—all on-device, no laptop and no connection required.
- A fixed camera and a small OLED screen, wired to the Nano on a custom-designed board, so the operator reads the grade and confidence straight off the unit.
- An enclosed box with constant LED lighting holds the camera at a fixed distance under controlled light. It turns an unpredictable factory floor into a repeatable capture environment: constant geometry and lighting keep the model honest, so it grades the tea rather than the surroundings.
The Pipeline
Data Collection → Data Validation → Feature Pipeline → Training → Edge Inference → Analytics- Data collection. Capture live from the rig's camera or ingest a directory; convert
.dng/.heic/ raw images to a working format and hold out a test split. - Data validation. Check every image for correctness and consistency before it can reach training—guarding the pipeline against bad data.
- Feature pipeline. Turn validated images into structured numerical features to complement the raw pixels.
- Training. Fit a hybrid model—a CNN backbone over the image plus the engineered numerical features—so visual variability and process noise are backed by structured signals. Exported to ONNX for portable deployment.
- Edge inference. Run the model on-device (live camera, single image, or batch), and reject out-of-distribution frames as "NOT TEA" with a confidence threshold.
- Analytics. Turn raw inference outputs into business-intelligence signals for the operation.
Built for Real Capture Conditions
Even inside the box, real capture drifts—a dimming bulb, a noisy sensor, a smudged frame. A dedicated on-device condition classifier (a MobileNetV2 model exported to ONNX and accelerated with TensorRT) tags each frame as normal, low-light, or noisy and applies the right fix before grading: CLAHE contrast recovery for dark frames, denoising for noisy ones. The grader always sees a cleaned-up image, and the out-of-distribution "NOT TEA" reject path keeps it from confidently mis-grading a frame that isn't tea at all.
The Data
Trained and validated on real captures of Kenyan processed teas—Java House BP1, Kericho Gold, and Melvins Orthodox—shot on the rig inside the box and converted from raw camera formats (DNG/HEIC) into a working dataset with a held-out test split.
Getting the Grade Off the Device
On-device grading is only useful if the results travel. Current work opens the box up: a service API exposes grades and health, and inference results are transmitted to an online datastore, so a run on the factory floor lands in a central database and dashboard in near-real-time—turning per-frame grades into operation-wide quality analytics.
Technology Stack
- Vision / ML: PyTorch + torchvision (hybrid CNN over image + engineered features), scikit-learn / XGBoost, exported to ONNX and served with ONNX Runtime + TensorRT.
- Edge & hardware: NVIDIA Jetson Nano, a fixed camera + OLED screen on a custom board inside a lit, enclosed capture box; OpenCV for capture and enhancement.
- Serving / tooling: a FastAPI service, a config-driven modular design (~60 Python modules, 11 test suites), Docker, and per-stage notebooks documenting each step.
Skills Demonstrated
- Edge-AI hardware—a self-contained Jetson capture box (camera + OLED + custom board + controlled-lighting enclosure) that runs grading on-device.
- Applied computer vision—a hybrid image-plus-features grading model and a separate light/noise condition classifier, not a toy classifier.
- Production robustness—out-of-distribution rejection and low-light / noise handling for messy real-world capture.
- MLOps & data plumbing—the full lifecycle as separable, tested stages, now extending to an API and an online datastore so on-device grades feed central BI.
A self-contained edge-AI capture box for processed-tea grading—from a lit camera rig, to an on-device grade, to central BI.