A real-time, computer-vision-powered automated billing system for supermarket fruit & vegetable checkout using YOLOv8 detection + segmentation, DeepSORT tracking, OCR weight reading, and automatic pricing.
| Feature | Description |
|---|---|
| 🎥 Real-time Detection | YOLOv8-powered fruit/vegetable detection at 30 FPS |
| 🔍 Instance Segmentation | YOLOv8-seg with watershed splitting for overlapping fruits |
| 🆔 Object Tracking | DeepSORT maintains unique IDs across frames |
| ⚖️ Weight Measurement | LED OCR-based weight reading from digital scale display |
| 💰 Automatic Billing | Weight-based pricing with itemized receipts |
| 📊 Live Display | Real-time video feed with billing panel overlay |
| 🎯 Scale Zone | ROI-based weighing trigger for precise auto-billing |
| 🧠 Active Learning | Iterative model improvement pipeline |
Super-Market-Classification/
├── config/
│ └── settings.py # All system configuration
├── data/
│ └── fruits.yaml # Dataset class definitions
├── src/
│ ├── billing/
│ │ └── billing_engine.py # Price calculation & receipt generation
│ ├── camera/
│ │ └── capture.py # Webcam / video capture
│ ├── detection/
│ │ ├── detector.py # YOLOv8 detection pipeline
│ │ ├── segmentation_detector.py # YOLOv8-seg instance segmentation
│ │ └── detection_utils.py # Shared utilities
│ ├── roi/
│ │ └── roi_manager.py # Region-of-interest handling
│ ├── scale/
│ │ ├── weight_reader.py # HX711 / simulation weight reader
│ │ └── led_ocr.py # OCR-based LED digit reader
│ ├── tracking/
│ │ └── tracker.py # DeepSORT multi-object tracker
│ └── ui/
│ └── display.py # Real-time display manager
├── training/
│ ├── prepare_dataset.py # Fruits-360 → YOLO format conversion
│ ├── train.py # Basic YOLOv8 training
│ ├── train_advanced.py # Advanced training with augmentations
│ ├── train_segmentation.py # Segmentation model training
│ ├── copy_paste_aug.py # Copy-paste data augmentation
│ ├── data_merge.py # Multi-dataset merger (COCO format)
│ ├── sam_annotate.py # SAM-based auto-annotation
│ ├── active_learning.py # Active learning loop
│ ├── canonical_classes.py # Unified class taxonomy
│ └── scene_split.py # Scene-aware train/val/test split
├── main.py # Main detection billing app
├── segmentation_demo.py # Segmentation billing demo
├── requirements.txt # Python dependencies
└── README.md
- Python 3.10+
- OS: Windows 10/11 (tested), Linux, macOS
- GPU: NVIDIA GPU with CUDA recommended
- Webcam: Any USB or laptop camera
- RAM: 8 GB minimum, 16 GB recommended
# 1. Clone the repository
git clone https://github.com/prakharsahup/Super-Market-Classification.git
cd Super-Market-Classification
# 2. Create & activate virtual environment
python -m venv env
# Windows PowerShell
.\env\Scripts\Activate.ps1
# Linux / macOS
source env/bin/activate
# 3. Install dependencies
pip install -r requirements.txtNote: Model weights (
.ptfiles) are excluded from the repo. They will be auto-downloaded by Ultralytics on first run.
python main.pypython segmentation_demo.pyThe system will:
- Initialize camera (webcam)
- Download YOLOv8 model weights automatically
- Start real-time detection / segmentation
- Display video feed with live billing panel
python training/prepare_dataset.pypython training/train.py --epochs 50 --batch 16 --model yolov8n.ptpython training/train_segmentation.pypython training/train_advanced.py| Option | Default | Description |
|---|---|---|
--epochs |
50 | Training epochs |
--batch |
16 | Batch size (reduce for low VRAM) |
--imgsz |
640 | Input image size |
--model |
yolov8n.pt | Base model |
--device |
auto | cuda, cpu, or GPU id |
| Script | Purpose |
|---|---|
copy_paste_aug.py |
Copy-paste augmentation for training data |
data_merge.py |
Merge multiple datasets in COCO format |
sam_annotate.py |
Auto-annotate using SAM |
active_learning.py |
Iterative active learning pipeline |
canonical_classes.py |
Unified class taxonomy across datasets |
scene_split.py |
Scene-aware train/val/test splitting |
All settings are in config/settings.py:
# Camera
CAMERA_ID = 0
CAMERA_WIDTH = 1280
CAMERA_HEIGHT = 720
# Detection
MODEL_PATH = "models/yolov8n.pt"
DETECTION_CONFIDENCE = 0.5
# Segmentation
USE_SEGMENTATION = True
SEGMENTATION_MODEL_PATH = "yolov8s-seg.pt"
# Scale Zone ROI
ROI_SCALE = {"x": 440, "y": 400, "width": 400, "height": 280}| Key | Action |
|---|---|
q |
Quit |
r |
Reset / clear bill |
p |
Print receipt to console |
s |
Save receipt to file |
w |
Trigger weight reading (simulation) |
1-9 |
Set weight 100–900g (simulation) |
┌─────────────────────────────────┬──────────────────┐
│ │ BILLING PANEL │
│ VIDEO FEED │ │
│ [Bounding boxes / masks] │ Status: Ready │
│ │ Current: Apple │
│ ┌───────────────────┐ │ Weight: 250g │
│ │ SCALE ZONE │ │ Cost: ₹45.00 │
│ │ (Magenta box) │ │ │
│ └───────────────────┘ │ BILLED ITEMS: │
│ │ Apple ₹45.00 │
│ │ Banana ₹30.00 │
│ │ TOTAL: ₹75.00 │
└─────────────────────────────────┴──────────────────┘
| Issue | Solution |
|---|---|
| PowerShell script error | Set-ExecutionPolicy -ExecutionPolicy Bypass -Scope Process |
| Camera not found | Try different camera ID: CAMERA_ID = 1 in settings |
| Out of memory (GPU) | Use smaller model (yolov8n.pt) or reduce batch size |
| No objects detected | Improve lighting, move closer, lower confidence threshold |
| Component | Minimum | Recommended |
|---|---|---|
| CPU | Intel i5 / Ryzen 5 | Intel i7 / Ryzen 7 |
| RAM | 8 GB | 16 GB |
| GPU | — | NVIDIA GTX 1060+ (CUDA) |
| Storage | 2 GB | 5 GB |
| Webcam | 720p | 1080p |
This project is for educational and academic purposes.
Happy Billing! 🛒