← Back to selected work

Tomato Ripeness Classification

View on GitHub

Real-time computer vision system that detects and classifies tomato ripeness stages directly from video. YOLOv8 detection wrapped in a Streamlit and FastAPI app for live inference.

PythonYOLOv8PyTorchOpenCV
The problem

Simple image-level classification breaks down when several tomatoes appear in one frame at different ripeness stages. The project solves the object-level version instead, locating every tomato in a scene and classifying each one individually, then making the result usable through an interactive application rather than a notebook-only model.

The approach

The system is built around a YOLOv8 object detector trained on six classes covering size and ripeness stage. Two model sizes were fine-tuned and compared using saved training and evaluation artifacts, so the final choice was evidence-based rather than arbitrary. A Streamlit interface handles the confidence slider and source selection, with support for uploaded images, uploaded video, webcam, RTSP streams, and YouTube video, and a separate FastAPI module demonstrates serving the same model outside Streamlit, including a websocket live-feed path. Object detection was chosen over plain classification specifically because it handles multiple tomatoes at different ripeness stages independently in one frame.

Results
0.881
mAP50, best YOLOv8m checkpoint
0.777
mAP50-95, best YOLOv8m checkpoint
0.844
precision, best YOLOv8m checkpoint
643
training images, 7,781 annotated instances
5
supported inference sources
Stack
PythonYOLOv8UltralyticsPyTorchOpenCVStreamlitFastAPI
👋 Hi, I'm a digital version of Lasantha. Ask me about my work.