Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

6 Commits

Folders and files

Repository files navigation

🛒 Super-Market Classification — Automated Billing System

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.


✨ Features

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

📁 Project Structure

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

💻 Requirements

  • 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

🚀 Installation

# 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.txt

Note: Model weights (.pt files) are excluded from the repo. They will be auto-downloaded by Ultralytics on first run.


⚡ Quick Start

Detection Mode (YOLOv8 + DeepSORT)

python main.py

Segmentation Mode (YOLOv8-seg + OCR Weight)

python segmentation_demo.py

The system will:

  1. Initialize camera (webcam)
  2. Download YOLOv8 model weights automatically
  3. Start real-time detection / segmentation
  4. Display video feed with live billing panel

🍎 Training Pipeline

1. Prepare Dataset

python training/prepare_dataset.py

2. Train Detection Model

python training/train.py --epochs 50 --batch 16 --model yolov8n.pt

3. Train Segmentation Model

python training/train_segmentation.py

4. Advanced Training (with augmentations)

python training/train_advanced.py

Training Options

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

Additional Training Tools

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

⚙️ Configuration

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}

⌨️ Keyboard Controls

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)

🖥️ System Layout

┌─────────────────────────────────┬──────────────────┐
│                                 │  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   │
└─────────────────────────────────┴──────────────────┘

🔧 Troubleshooting

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

📊 System Requirements

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

🙏 Acknowledgments


📝 License

This project is for educational and academic purposes.


Happy Billing! 🛒

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages