Skip to content

Latest commit

Β 

History

15 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ… Tomato Ripeness Detection

A full pipeline for detecting and classifying tomato ripeness using:

  • Faster R-CNN β†’ tomato object detection
  • MobileNetV2 (fine-tuned) β†’ ripeness classification
  • Real-time webcam demo β†’ bounding boxes + labels + confidence

Ripeness levels:

  • unripe (green)
  • semi-ripe (orange)
  • fully-ripe (red)

This project supports training, preprocessing, conversion from COCO annotations, and real-time inference.


πŸ“ Project Structure

project_root/
β”‚
β”œβ”€ data/
β”‚   β”œβ”€ raw/                    # Original images + COCO annotations
β”‚   └─ processed/              # Cropped images for 3-class classification
β”‚
β”œβ”€ models/
β”‚   β”œβ”€ mobilenet_tomato_classifier.h5     # Base MobileNetV2
β”‚   └─ mobilenet_tomato_finetune.h5       # Fine-tuned MobileNetV2
β”‚
β”œβ”€ notebooks/               
β”‚   β”œβ”€ MobileNet_V2_training.ipynb           # MobileNetV2 base training 
β”‚
β”œβ”€ src/
β”‚    β”œβ”€ check.py                           # Check the labels
β”‚   └─ convert_coco_to_classification.py  # Convert COCO β†’ cropped dataset
β”‚
β”œβ”€ demos/
β”‚   β”œβ”€ camera_demo.py                     # MobileNetV2 webcam classifier
β”‚   └─ camera_demo_fasterrcnn.py          # Faster R-CNN + MobileNetV2 demo
β”œβ”€ dashboard/
β”‚   β”œβ”€ app.py             # Flask application
β”‚   └─ camera.py          # setup camera
β”‚
└─ requirements.txt

⚑ Environment Requirements

  • Python 3.8+
  • TensorFlow 2.x
  • PyTorch + torchvision
  • OpenCV
  • Pillow

Install:

pip install tensorflow torch torchvision opencv-python pillow

πŸ“ Usage Guide

1️⃣ Train MobileNetV2 Classifier (optional)

Open the fine-tuning notebook:

jupyter notebook notebooks/MobileNet_V2_training.ipynb

The 2 trained model will be saved to the directory and we will use:

models/mobilenet_tomato_finetune.h5

2️⃣ Run Webcam Demo – MobileNetV2 Only

python demos/camera_demo.py

This runs:

  • Webcam livestream
  • Full-frame classification
  • Displays predicted ripeness + confidence

3️⃣ Run Webcam Demo – Faster R-CNN + MobileNetV2

python demos/camera_demo_fasterrcnn.py

Pipeline:

  1. Faster R-CNN detects tomato bounding boxes
  2. Each crop is classified with MobileNetV2
  3. Bounding boxes + label + confidence displayed in real-time
  4. Press q to quit

πŸ’‘ Performance & Optimization Tips

  • Use good lighting β†’ improves detection accuracy
  • If FPS is low β†’ resize frame before sending to Faster R-CNN
  • For highest accuracy β†’ fine-tune Faster R-CNN on your tomato dataset
  • Convert model to TensorFlow Lite for IoT devices (optional)

πŸ“š Resources

  • Tomato dataset: tomatOD
  • MobileNetV2 pretrained on ImageNet
  • Faster R-CNN pretrained on COCO

πŸ‘€ Author

AIoT project for real-time tomato ripeness classification & detection.

About

πŸ… A real-time webcam tomato ripeness detection and classification

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages