How vmc-7645/yolov8-retail works
This repository is a model-development workspace for retail object detection, not a general application. The architecture centers on a YOLOv8 training pipeline, exported model artifacts, and several standalone inference scripts for different input types.
1. Core purpose
The project detects retail products on shelves using YOLOv8. The repo is organized around experimentation: train models, evaluate them, export them, and run them against images, video, or webcam feeds.
2. Primary subsystems
There are three main subsystems:
- Training under training/
- Testing / inference under testing/
- Saved model artifacts under model/
These are separate boundaries: training produces weights and metrics, while testing consumes exported weights to run detection.
3. Training pipeline
training/train.py, training/test.py, and the helper scripts in training/ drive YOLOv8 training and evaluation. The README shows training is typically done through the Ultralytics CLI with a custom.yaml dataset config and a pretrained base model such as yolov8n.pt. This layer depends on PyTorch/CUDA and the YOLOv8 implementation.
4. Dataset boundary
The training data comes from the SKU110k retail dataset, referenced in the README. That dataset is external to the repo and provides labeled shelf images. The repo’s custom.yaml is the key interface between the external dataset and the YOLOv8 training process.
5. Model versioning
The model/ directory is a versioned artifact store. Each version folder, such as model/0.0.1, model/0.1.3, model/0.2.1, and model/0.2.8, contains:
- trained weights (best.pt, last.pt)
- exported inference weights (best.onnx in some versions)
- training metadata (args.yaml)
- evaluation outputs (results.csv, sometimes predictions.json)
- TensorBoard logs (events.out.tfevents...)
This makes the repo’s “deployment boundary” explicit: the training pipeline produces versioned model packages.
6. Inference / testing layer
testing/ contains the runtime scripts used to apply trained models:
- image_object_detection.py
- video_object_detection.py
- webcam_object_detection.py
These are thin modality-specific entry points over the same detection logic. They load model files from testing/models/ and produce detections on static images, video files, or live camera streams.
7. Model format conversion
testing/convertPT.py and training/yolov8-convert.py indicate a conversion step between PyTorch .pt weights and ONNX .onnx models. That matters architecturally because training is done in PyTorch, but inference can be distributed or reused more easily via ONNX.
8. Shared YOLOv8 support code
testing/yolov8/YOLOv8.py and testing/yolov8/utils.py are local support modules that likely encapsulate model loading, preprocessing, postprocessing, and visualization. They form the reusable inference core shared by the image/video/webcam scripts.
9. Output and labeling flow
The testing side also includes vid-to-labeledvid.py, which suggests a pipeline to convert raw video into a labeled video with detections overlaid. This indicates the repo supports not only prediction, but also visualization/export of annotated results.
10. Artifact locations for inference
testing/models/ contains ONNX model files such as best.onnx and best18.onnx. This directory is the runtime model repository for test scripts, separate from the historical training artifacts in model/.
11. Experiment lifecycle
The lifecycle is: train on SKU110k-derived data -> evaluate -> export weights -> store artifacts in a versioned model/<version>/ folder -> copy a chosen model into testing/models/ -> run inference scripts. The architecture is therefore a research-to-field workflow rather than a continuous service.
12. Operational assumptions
The repository is optimized for local execution on Windows with CUDA, as stated in the README. The key external dependencies are Ultralytics YOLOv8, PyTorch, and CUDA-enabled GPU support. There is no evidence of a backend server, database, or message bus; the system is file-based and script-driven.
13. What an architecture diagram should show
A useful diagram would include:
- external dataset source → training config/scripts → YOLOv8 training/evaluation
- trained model artifacts → versioned model storage
- exported ONNX / PT weights → inference scripts
- inference inputs from image/video/webcam → annotated detection outputs
- optional conversion step between .pt and .onnx
Overall, this repo is best understood as an end-to-end YOLOv8 experiment and deployment toolkit for retail shelf detection, with versioned model artifacts as the central bridge between training and inference.
Main entry points: train.py Train · models testing/models · YOLOv8.py YOLOv8 core · 0.0.1 0.0.1
Components 21
Repo
Project overview and top-level orchestration.
Training
YOLOv8 training, evaluation, and export pipeline.
- Train · Main YOLOv8 training script.
training/train.py - Test · Training-side evaluation or validation script.
training/test.py - custom.yaml · Dataset interface between local training and external labels.
training/custom.yaml - yolov8n.pt · Pretrained YOLOv8 starting point for fine-tuning.
training/yolov8n.pt - Convert · Training-side conversion from PyTorch weights to ONNX.
training/yolov8-convert.py - Clean · Training-side helper for workspace cleanup or maintenance.
training/yolov8-clean.py
Testing
Inference entry points and shared runtime helpers.
- testing/models · Inference-time ONNX model repository.
testing/models - convertPT · Standalone conversion from .pt to .onnx for inference use.
testing/convertPT.py - Image detect · Runs detection on static images.
testing/image_object_detection.py - Video detect · Runs detection on video files.
testing/video_object_detection.py - Webcam detect · Runs detection on live camera input.
testing/webcam_object_detection.py - Label video · Creates annotated or labeled video output from detections.
testing/vid-to-labeledvid.py - YOLOv8 core · Reusable loader and inference logic shared by test scripts.
testing/yolov8/YOLOv8.py - Utils · Shared preprocessing, postprocessing, and visualization helpers.
testing/yolov8/utils.py
Model Store
Versioned trained artifacts and runtime model files.
Connections 23
- SKU110k → custom.yaml: labels · The external retail dataset is referenced through the dataset config.
- custom.yaml → Train: feeds · Training consumes the dataset configuration to locate images and annotations.
- yolov8n.pt → Train: initializes · Training starts from a pretrained YOLOv8 checkpoint.
- Train → Test: validates · Training is paired with evaluation of the trained detector.
- Train → Convert: exports · Training produces exportable model artifacts.
- Train → 0.0.1: produces · A training run is stored as a versioned model package.
- Train → 0.1.3: produces · A training run is stored as a versioned model package.
- Train → 0.2.1: produces · A training run is stored as a versioned model package.
- Train → 0.2.8: produces · A training run is stored as a versioned model package.
- Convert → 0.0.1: writes · Converted exports can be materialized inside versioned artifacts.
- 0.0.1 → testing/models: promotes · Chosen trained weights are copied into the inference model store.
- 0.1.3 → testing/models: promotes · Chosen trained weights are copied into the inference model store.
- 0.2.1 → testing/models: promotes · Chosen trained weights are copied into the inference model store.
- 0.2.8 → testing/models: promotes · Chosen trained weights are copied into the inference model store.
- convertPT → testing/models: writes · Standalone conversion populates ONNX files for inference.
- testing/models → YOLOv8 core: loads · Inference core loads the deployed model weights.
- YOLOv8 core → Utils: uses · Core inference depends on shared helper utilities.
- YOLOv8 core → Image detect: shared by · Image detection script uses the shared YOLOv8 runtime.
- YOLOv8 core → Video detect: shared by · Video detection script uses the shared YOLOv8 runtime.
- YOLOv8 core → Webcam detect: shared by · Webcam detection script uses the shared YOLOv8 runtime.
- Video detect → Label video: annotates · Video inference feeds labeled video generation.
- run.py → Train: orchestrates · Top-level script can invoke training workflows.
- run.py → Image detect: orchestrates · Top-level script can invoke inference workflows.