# carrickcheah/yolo-detection-for-manufacturing architecture

> Architecture diagram of the GitHub repository carrickcheah/yolo-detection-for-manufacturing, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/carrickcheah/yolo-detection-for-manufacturing
- Repository: https://github.com/carrickcheah/yolo-detection-for-manufacturing

## Overview

Box Counter processes conveyor video into tracked object counts and an annotated output video. Its separate model-development workflow extracts frames, creates or auto-generates labels, trains a detector locally or on Modal, and downloads trained weights for counting. The runtime and Modal implementation are sampled; the frame-extraction and manual-labeling scripts are also sampled. The diagram keeps training stages distinct and does not imply they are all required for every run.

Main entry points: [`scripts/train_modal.py`](https://github.com/carrickcheah/yolo-detection-for-manufacturing/blob/main/scripts/train_modal.py) (Modal Workflow), [`src/counter.py`](https://github.com/carrickcheah/yolo-detection-for-manufacturing/blob/main/src/counter.py) (Counter Pipeline), [`scripts/train_local.py`](https://github.com/carrickcheah/yolo-detection-for-manufacturing/blob/main/scripts/train_local.py) (Local Training), [`data/images`](https://github.com/carrickcheah/yolo-detection-for-manufacturing/tree/main/data/images) (Training Images)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Video Counting"]
  node_input_video["Input Video"]
  node_counter_app["Counter Pipeline<br/>[counter.py]"]
  node_detector["YOLO Detector"]
  node_tracker["ByteTrack"]
  node_line_counter["Line Counter<br/>[counter.py]"]
  node_output_video["Annotated Video"]
end

subgraph group_dataset["Dataset Preparation"]
  node_frame_tool["Frame Extraction<br/>[extract_frames.py]"]
  node_images["Training Images"]
  node_manual_labeler["Manual Labeling<br/>[label.py]"]
  node_labels["YOLO Labels"]
  node_dataset_config["Dataset Config<br/>[dataset.yaml]"]
end

subgraph group_training["Model Training"]
  node_modal_entry["Modal Workflow<br/>[train_modal.py]"]
  node_cloud_volume[("Modal Dataset Volume")]
  node_autolabel["YOLO-World Labeling<br/>[train_modal.py]"]
  node_local_training["Local Training<br/>[train_local.py]"]
  node_cloud_training["H100 Training<br/>[train_modal.py]"]
  node_trained_weights["Trained Weights"]
end

node_operator(("Operator"))

node_operator -->|"runs"| node_counter_app
node_input_video -->|"reads"| node_counter_app
node_counter_app -->|"detects"| node_detector
node_counter_app -->|"tracks"| node_tracker
node_counter_app -->|"updates"| node_line_counter
node_counter_app -->|"writes"| node_output_video
node_operator -->|"runs"| node_frame_tool
node_input_video -->|"reads"| node_frame_tool
node_frame_tool -->|"writes"| node_images
node_operator -->|"runs"| node_manual_labeler
node_manual_labeler -->|"reads"| node_images
node_manual_labeler -->|"writes"| node_labels
node_operator -->|"selects action"| node_modal_entry
node_modal_entry -->|"packages"| node_images
node_modal_entry -->|"packages"| node_labels
node_modal_entry -->|"packages"| node_dataset_config
node_modal_entry -->|"uploads"| node_cloud_volume
node_modal_entry -->|"dispatches"| node_autolabel
node_autolabel -->|"reads images"| node_cloud_volume
node_autolabel -->|"writes labels"| node_cloud_volume
node_modal_entry -->|"dispatches"| node_cloud_training
node_cloud_training -->|"reads dataset"| node_cloud_volume
node_cloud_training -->|"writes weights"| node_cloud_volume
node_modal_entry -->|"downloads weights"| node_cloud_volume
node_modal_entry -->|"saves"| node_trained_weights
node_operator -->|"runs"| node_local_training
node_local_training -->|"reads"| node_dataset_config
node_local_training -->|"trains on"| node_images
node_local_training -->|"trains on"| node_labels
node_local_training -->|"produces"| node_trained_weights
node_trained_weights -->|"loads"| node_counter_app

click node_input_video "https://github.com/carrickcheah/yolo-detection-for-manufacturing/tree/main/data/videos"
click node_counter_app "https://github.com/carrickcheah/yolo-detection-for-manufacturing/blob/main/src/counter.py"
click node_line_counter "https://github.com/carrickcheah/yolo-detection-for-manufacturing/blob/main/src/counter.py"
click node_output_video "https://github.com/carrickcheah/yolo-detection-for-manufacturing/tree/main/data/videos"
click node_frame_tool "https://github.com/carrickcheah/yolo-detection-for-manufacturing/blob/main/scripts/extract_frames.py"
click node_images "https://github.com/carrickcheah/yolo-detection-for-manufacturing/tree/main/data/images"
click node_manual_labeler "https://github.com/carrickcheah/yolo-detection-for-manufacturing/blob/main/scripts/label.py"
click node_labels "https://github.com/carrickcheah/yolo-detection-for-manufacturing/tree/main/data/labels"
click node_dataset_config "https://github.com/carrickcheah/yolo-detection-for-manufacturing/blob/main/dataset.yaml"
click node_modal_entry "https://github.com/carrickcheah/yolo-detection-for-manufacturing/blob/main/scripts/train_modal.py"
click node_autolabel "https://github.com/carrickcheah/yolo-detection-for-manufacturing/blob/main/scripts/train_modal.py"
click node_local_training "https://github.com/carrickcheah/yolo-detection-for-manufacturing/blob/main/scripts/train_local.py"
click node_cloud_training "https://github.com/carrickcheah/yolo-detection-for-manufacturing/blob/main/scripts/train_modal.py"
click node_trained_weights "https://github.com/carrickcheah/yolo-detection-for-manufacturing/tree/main/models"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_input_video,node_counter_app,node_detector,node_tracker,node_line_counter,node_output_video toneBlue
class node_frame_tool,node_images,node_manual_labeler,node_labels,node_dataset_config toneAmber
class node_modal_entry,node_cloud_volume,node_autolabel,node_local_training,node_cloud_training,node_trained_weights toneMint
class node_operator toneIndigo
```

## Components

### Video Counting

- [Input Video](https://github.com/carrickcheah/yolo-detection-for-manufacturing/tree/main/data/videos): `data/videos`
- [Counter Pipeline](https://github.com/carrickcheah/yolo-detection-for-manufacturing/blob/main/src/counter.py): `src/counter.py`
- **YOLO Detector**
- **ByteTrack**
- [Line Counter](https://github.com/carrickcheah/yolo-detection-for-manufacturing/blob/main/src/counter.py): `src/counter.py`
- [Annotated Video](https://github.com/carrickcheah/yolo-detection-for-manufacturing/tree/main/data/videos): `data/videos`

### Dataset Preparation

- [Frame Extraction](https://github.com/carrickcheah/yolo-detection-for-manufacturing/blob/main/scripts/extract_frames.py): `scripts/extract_frames.py`
- [Training Images](https://github.com/carrickcheah/yolo-detection-for-manufacturing/tree/main/data/images): `data/images`
- [Manual Labeling](https://github.com/carrickcheah/yolo-detection-for-manufacturing/blob/main/scripts/label.py): `scripts/label.py`
- [YOLO Labels](https://github.com/carrickcheah/yolo-detection-for-manufacturing/tree/main/data/labels): `data/labels`
- [Dataset Config](https://github.com/carrickcheah/yolo-detection-for-manufacturing/blob/main/dataset.yaml): `dataset.yaml`

### Model Training

- [Modal Workflow](https://github.com/carrickcheah/yolo-detection-for-manufacturing/blob/main/scripts/train_modal.py): `scripts/train_modal.py`
- **Modal Dataset Volume**
- [YOLO-World Labeling](https://github.com/carrickcheah/yolo-detection-for-manufacturing/blob/main/scripts/train_modal.py): `scripts/train_modal.py`
- [Local Training](https://github.com/carrickcheah/yolo-detection-for-manufacturing/blob/main/scripts/train_local.py): `scripts/train_local.py`
- [H100 Training](https://github.com/carrickcheah/yolo-detection-for-manufacturing/blob/main/scripts/train_modal.py): `scripts/train_modal.py`
- [Trained Weights](https://github.com/carrickcheah/yolo-detection-for-manufacturing/tree/main/models): `models`

### Other components

- **Operator**

## Connections

- Operator → Counter Pipeline: runs
- Input Video → Counter Pipeline: reads
- Counter Pipeline → YOLO Detector: detects
- Counter Pipeline → ByteTrack: tracks
- Counter Pipeline → Line Counter: updates
- Counter Pipeline → Annotated Video: writes
- Operator → Frame Extraction: runs
- Input Video → Frame Extraction: reads
- Frame Extraction → Training Images: writes
- Operator → Manual Labeling: runs
- Manual Labeling → Training Images: reads
- Manual Labeling → YOLO Labels: writes
- Operator → Modal Workflow: selects action
- Modal Workflow → Training Images: packages
- Modal Workflow → YOLO Labels: packages
- Modal Workflow → Dataset Config: packages
- Modal Workflow → Modal Dataset Volume: uploads
- Modal Workflow → YOLO-World Labeling: dispatches
- YOLO-World Labeling → Modal Dataset Volume: reads images
- YOLO-World Labeling → Modal Dataset Volume: writes labels
- Modal Workflow → H100 Training: dispatches
- H100 Training → Modal Dataset Volume: reads dataset
- H100 Training → Modal Dataset Volume: writes weights
- Modal Workflow → Modal Dataset Volume: downloads weights
- Modal Workflow → Trained Weights: saves
- Operator → Local Training: runs
- Local Training → Dataset Config: reads
- Local Training → Training Images: trains on
- Local Training → YOLO Labels: trains on
- Local Training → Trained Weights: produces
- Trained Weights → Counter Pipeline: loads
