# dinosaurerer/spd architecture

> Architecture diagram of the GitHub repository dinosaurerer/spd, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-04-18). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/dinosaurerer/spd
- Repository: https://github.com/dinosaurerer/spd

## Overview

1. This repository is split into two main subsystems: a desktop GUI application under `GUI/` and a separate training/inference workspace under `YOLO/`. The GUI is the user-facing product; the YOLO tree contains experiment artifacts, training scripts, configs, and a second copy of the Ultralytics codebase used for model development.

2. The primary runtime entrypoints are `GUI/main.py`, `GUI/gui.py`, and the platform launchers `GUI/run.sh` / `GUI/run.bat`. In the YOLO workspace, `YOLO/train.py`, `YOLO/predict.py`, and `YOLO/show_labels.py` support offline model training and inspection.

3. The GUI layer is built with Qt/PyQt-style generated UI files in `GUI/ui/` plus custom widgets in `GUI/ui/utils/`. These include window framing, tables, camera dialogs, drawing helpers, and splash-screen behavior, so the UI is not just a thin shell; it manages most user interaction and visualization.

4. Model execution is orchestrated through `GUI/yoloshow/` and `GUI/yolocode/`. These modules contain window logic, thread-pool management, and version-specific inference threads for YOLOv8 and YOLOv11 variants. The architecture is asynchronous: frames are captured in the UI, handed to worker threads, processed, and returned to the UI for rendering.

5. The inference backend is a local Ultralytics-style stack, duplicated in both `GUI/ultralytics/` and `YOLO/ultralytics/`. This fork includes core engine code (`predictor`, `trainer`, `validator`, `exporter`), model definitions, dataset configs, trackers, and utility functions. The repository’s custom model work appears centered on a YOLOv11 variant with MSCA attention (`yolo11-MSCAAttention1.yaml`, `YOLO/yolo11-MSCAAttention1-n.yaml`).

6. Pretrained weights are bundled locally in `GUI/ptfiles/` and `YOLO/yolo11n.pt`, including detection, segmentation, pose, and custom posture-specific models. This makes the app file-system driven: the GUI selects a local `.pt` checkpoint and runs inference without depending on an external model service.

7. The data flow for live posture detection is: camera/video/file input → optional skeleton/keypoint preprocessing described in the README via Mediapipe → YOLO-based posture classification → annotated output frames and status feedback in the GUI. The app is designed to support multiple sources, including webcam, RTSP/network camera, video files, images, and folders.

8. Results and user-facing analytics are handled inside the GUI rather than in a separate server. The project includes config files like `GUI/config/result.json`, `save.json`, `setting.json`, and `model.json`, which suggest persistent settings, selected model state, output paths, and result summaries. The UI utilities also include table views and custom drawing components for displaying detections and statistics.

9. Offline training and evaluation live in the `YOLO/` subtree. `YOLO/runs/` stores experiment outputs such as `args.yaml`, TensorBoard event files, `results.csv`, and `weights/best.pt` / `last.pt`. This is the training/output boundary: configs and datasets go in, training happens through the Ultralytics engine, and checkpoints/metrics come out into `runs/`.

10. The repository includes a substantial dataset/model configuration catalog under `GUI/ultralytics/cfg/` and `YOLO/ultralytics/cfg/`, covering detection, segmentation, pose, oriented boxes, RT-DETR, and multiple YOLO generations. That tells you the architecture is generalized around task-specific model heads, not a single fixed classifier.

11. `process_data/` contains one-off dataset preparation scripts such as renaming images/labels and capturing photos. This is the ingestion/preprocessing boundary for building or cleaning the posture datasets before training.

12. Supporting assets are bundled in `pngs/`, `demo_video/`, `GUI/images/`, and `GUI/fonts/`. These are presentation assets for the desktop app, including the splash video and screenshots used in the UI and README.

13. Architecturally, this is a single-machine, desktop-first system with no obvious backend service tier. The important boundaries are: UI and interaction, threaded inference orchestration, local model/runtime code, and offline training/data-prep workflows. If you draw the system, the central path should be GUI input → worker threads → local Ultralytics/YOLO model → annotated results back to GUI, with a separate training lane feeding the `.pt` weights used by the GUI.

Main entry points: [`GUI/yoloshow/YOLOSHOW.py`](https://github.com/dinosaurerer/spd/blob/main/GUI/yoloshow/YOLOSHOW.py) (Show runtime), [`YOLO/ultralytics/engine/trainer.py`](https://github.com/dinosaurerer/spd/blob/main/YOLO/ultralytics/engine/trainer.py) (Ultralytics core), [`GUI/gui.py`](https://github.com/dinosaurerer/spd/blob/main/GUI/gui.py) (GUI shell), [`GUI/ultralytics/engine/model.py`](https://github.com/dinosaurerer/spd/blob/main/GUI/ultralytics/engine/model.py) (Model stack)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_gui["Desktop GUI"]
  node_gui_entry["App entry<br/>launcher<br/>[main.py]"]
  node_gui_shell["GUI shell<br/>window bootstrap<br/>[gui.py]"]
  node_gui_runtime["Show runtime<br/>ui controller<br/>[YOLOSHOW.py]"]
  node_gui_pool(("Thread pool<br/>async orchestration<br/>[YOLOThreadPool.py]"))
  node_gui_threads(("Inference threads<br/>model workers<br/>[YOLOv11Thread.py]"))
  node_gui_ui["Generated UI<br/>Qt forms<br/>[YOLOSHOWUI.ui]"]
  node_gui_widgets["UI widgets<br/>custom widgets<br/>[drawFigure.py]"]
  node_gui_config["App state<br/>persistent config<br/>[setting.json]"]
  node_gui_models["Model stack<br/>embedded runtime<br/>[model.py]"]
  node_gui_backend["Autobackend<br/>runtime backend<br/>[autobackend.py]"]
  node_gui_attention{{"MSCA attention<br/>custom layer<br/>[MSCA.py]"}}
  node_gui_weights[("Bundled weights<br/>checkpoints<br/>[yolo11n.pt]")]
  node_gui_launchers["Run scripts<br/>platform launchers<br/>[run.sh]"]
  node_assets["Media assets<br/>presentation assets<br/>[splash.mp4]"]
end

subgraph group_yolo["YOLO Workspace"]
  node_yolo_entry["Train entry<br/>training CLI<br/>[train.py]"]
  node_yolo_predict["Predict CLI<br/>inference CLI<br/>[predict.py]"]
  node_yolo_labels["Label viewer<br/>inspection tool<br/>[show_labels.py]"]
  node_yolo_runs[("Run outputs<br/>experiment artifacts<br/>[best.pt]")]
  node_yolo_models["Ultralytics core<br/>training runtime<br/>[trainer.py]"]
  node_yolo_cfg["Configs<br/>model catalog<br/>[default.yaml]"]
  node_yolo_custom["MSCA model<br/>custom architecture"]
end

subgraph group_prep["Data Prep"]
  node_prep_scripts["Prep scripts<br/>data prep<br/>[rename.py]"]
end

node_gui_launchers -->|"start"| node_gui_entry
node_gui_entry -->|"boot"| node_gui_shell
node_gui_shell -->|"loads"| node_gui_ui
node_gui_shell -->|"uses"| node_gui_widgets
node_gui_shell -->|"opens"| node_gui_runtime
node_gui_runtime -->|"dispatches"| node_gui_pool
node_gui_pool -->|"runs"| node_gui_threads
node_gui_threads -->|"call into"| node_gui_models
node_gui_models -->|"executes via"| node_gui_backend
node_gui_models -->|"includes"| node_gui_attention
node_gui_runtime -->|"persists"| node_gui_config
node_gui_runtime -->|"selects"| node_gui_weights
node_gui_runtime -->|"renders"| node_assets
node_yolo_entry -->|"uses"| node_yolo_models
node_yolo_predict -->|"uses"| node_yolo_models
node_yolo_labels -->|"reads"| node_yolo_cfg
node_yolo_models -->|"loads"| node_yolo_cfg
node_yolo_models -->|"writes"| node_yolo_runs
node_yolo_custom -->|"specializes"| node_yolo_models
node_prep_scripts -.->|"prepares"| node_yolo_cfg
node_gui_weights -.->|"originates from"| node_yolo_runs

click node_gui_entry "https://github.com/dinosaurerer/spd/blob/main/GUI/main.py"
click node_gui_shell "https://github.com/dinosaurerer/spd/blob/main/GUI/gui.py"
click node_gui_runtime "https://github.com/dinosaurerer/spd/blob/main/GUI/yoloshow/YOLOSHOW.py"
click node_gui_pool "https://github.com/dinosaurerer/spd/blob/main/GUI/yoloshow/YOLOThreadPool.py"
click node_gui_threads "https://github.com/dinosaurerer/spd/blob/main/GUI/yolocode/yolov11/YOLOv11Thread.py"
click node_gui_ui "https://github.com/dinosaurerer/spd/blob/main/GUI/ui/YOLOSHOWUI.ui"
click node_gui_widgets "https://github.com/dinosaurerer/spd/blob/main/GUI/ui/utils/drawFigure.py"
click node_gui_config "https://github.com/dinosaurerer/spd/blob/main/GUI/config/setting.json"
click node_gui_models "https://github.com/dinosaurerer/spd/blob/main/GUI/ultralytics/engine/model.py"
click node_gui_backend "https://github.com/dinosaurerer/spd/blob/main/GUI/ultralytics/nn/autobackend.py"
click node_gui_attention "https://github.com/dinosaurerer/spd/blob/main/GUI/ultralytics/nn/attention/MSCA.py"
click node_gui_weights "https://github.com/dinosaurerer/spd/blob/main/GUI/ptfiles/yolo11n.pt"
click node_gui_launchers "https://github.com/dinosaurerer/spd/blob/main/GUI/run.sh"
click node_yolo_entry "https://github.com/dinosaurerer/spd/blob/main/YOLO/train.py"
click node_yolo_predict "https://github.com/dinosaurerer/spd/blob/main/YOLO/predict.py"
click node_yolo_labels "https://github.com/dinosaurerer/spd/blob/main/YOLO/show_labels.py"
click node_yolo_runs "https://github.com/dinosaurerer/spd/blob/main/YOLO/runs/train/exp2/weights/best.pt"
click node_yolo_models "https://github.com/dinosaurerer/spd/blob/main/YOLO/ultralytics/engine/trainer.py"
click node_yolo_cfg "https://github.com/dinosaurerer/spd/blob/main/YOLO/ultralytics/cfg/default.yaml"
click node_yolo_custom "https://github.com/dinosaurerer/spd/blob/main/YOLO/yolo11-MSCAAttention1-n.yaml"
click node_prep_scripts "https://github.com/dinosaurerer/spd/blob/main/process_data/rename.py"
click node_assets "https://github.com/dinosaurerer/spd/blob/main/GUI/images/splash.mp4"

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_gui_entry,node_gui_shell,node_gui_runtime,node_gui_pool,node_gui_threads,node_gui_ui,node_gui_widgets,node_gui_config,node_gui_models,node_gui_backend,node_gui_attention,node_gui_weights,node_gui_launchers,node_assets toneBlue
class node_yolo_entry,node_yolo_predict,node_yolo_labels,node_yolo_runs,node_yolo_models,node_yolo_cfg,node_yolo_custom toneAmber
class node_prep_scripts toneMint
```

## Components

### Desktop GUI

User-facing Qt application, local inference orchestration, and presentation assets.

- [App entry](https://github.com/dinosaurerer/spd/blob/main/GUI/main.py): launcher · Desktop startup and OS launch scripts. · `GUI/main.py`
- [GUI shell](https://github.com/dinosaurerer/spd/blob/main/GUI/gui.py): window bootstrap · Main application shell and top-level window wiring. · `GUI/gui.py`
- [Show runtime](https://github.com/dinosaurerer/spd/blob/main/GUI/yoloshow/YOLOSHOW.py): ui controller · Window logic, state, and user interaction flow for the desktop app. · `GUI/yoloshow/YOLOSHOW.py`
- [Thread pool](https://github.com/dinosaurerer/spd/blob/main/GUI/yoloshow/YOLOThreadPool.py): async orchestration · Worker scheduling and asynchronous frame processing coordination. · `GUI/yoloshow/YOLOThreadPool.py`
- [Inference threads](https://github.com/dinosaurerer/spd/blob/main/GUI/yolocode/yolov11/YOLOv11Thread.py): model workers · Version-specific YOLOv8 and YOLOv11 worker threads for inference tasks. · `GUI/yolocode/yolov11/YOLOv11Thread.py`
- [Generated UI](https://github.com/dinosaurerer/spd/blob/main/GUI/ui/YOLOSHOWUI.ui): Qt forms · Generated Qt UI definitions and resource bindings. · `GUI/ui/YOLOSHOWUI.ui`
- [UI widgets](https://github.com/dinosaurerer/spd/blob/main/GUI/ui/utils/drawFigure.py): custom widgets · Custom dialogs, tables, drawing helpers, camera widgets, and frame utilities. · `GUI/ui/utils/drawFigure.py`
- [App state](https://github.com/dinosaurerer/spd/blob/main/GUI/config/setting.json): persistent config · Saved settings, selected model, file/folder choices, and results state. · `GUI/config/setting.json`
- [Model stack](https://github.com/dinosaurerer/spd/blob/main/GUI/ultralytics/engine/model.py): embedded runtime · Local Ultralytics-style runtime used by the GUI for loading and running checkpoints. · `GUI/ultralytics/engine/model.py`
- [Autobackend](https://github.com/dinosaurerer/spd/blob/main/GUI/ultralytics/nn/autobackend.py): runtime backend · Backend wrapper for loading and executing local models. · `GUI/ultralytics/nn/autobackend.py`
- [MSCA attention](https://github.com/dinosaurerer/spd/blob/main/GUI/ultralytics/nn/attention/MSCA.py): custom layer · Custom attention module used by the repository's YOLOv11 variant. · `GUI/ultralytics/nn/attention/MSCA.py`
- [Bundled weights](https://github.com/dinosaurerer/spd/blob/main/GUI/ptfiles/yolo11n.pt): checkpoints · Pretrained and custom local .pt checkpoints selected by the GUI. · `GUI/ptfiles/yolo11n.pt`
- [Run scripts](https://github.com/dinosaurerer/spd/blob/main/GUI/run.sh): platform launchers · Shell and batch entrypoints for starting the desktop application. · `GUI/run.sh`
- [Media assets](https://github.com/dinosaurerer/spd/blob/main/GUI/images/splash.mp4): presentation assets · Splash video, demo clips, screenshots, and fonts used by the GUI and documentation. · `GUI/images/splash.mp4`

### YOLO Workspace

Offline training, prediction, experiment outputs, and the embedded Ultralytics stack.

- [Train entry](https://github.com/dinosaurerer/spd/blob/main/YOLO/train.py): training CLI · Offline training and prediction entrypoints for the YOLO workspace. · `YOLO/train.py`
- [Predict CLI](https://github.com/dinosaurerer/spd/blob/main/YOLO/predict.py): inference CLI · Standalone prediction script for running models outside the GUI. · `YOLO/predict.py`
- [Label viewer](https://github.com/dinosaurerer/spd/blob/main/YOLO/show_labels.py): inspection tool · Dataset label inspection and visualization utility. · `YOLO/show_labels.py`
- [Run outputs](https://github.com/dinosaurerer/spd/blob/main/YOLO/runs/train/exp2/weights/best.pt): experiment artifacts · Training logs, metrics, TensorBoard files, and saved checkpoints. · `YOLO/runs/train/exp2/weights/best.pt`
- [Ultralytics core](https://github.com/dinosaurerer/spd/blob/main/YOLO/ultralytics/engine/trainer.py): training runtime · Embedded Ultralytics engine, models, data pipelines, trackers, and utilities for experimentation. · `YOLO/ultralytics/engine/trainer.py`
- [Configs](https://github.com/dinosaurerer/spd/blob/main/YOLO/ultralytics/cfg/default.yaml): model catalog · Dataset, model, tracker, and solution configuration catalogs. · `YOLO/ultralytics/cfg/default.yaml`
- [MSCA model](https://github.com/dinosaurerer/spd/blob/main/YOLO/yolo11-MSCAAttention1-n.yaml): custom architecture · Custom YOLOv11 MSCA attention configuration used for the project's model work. · `YOLO/yolo11-MSCAAttention1-n.yaml`

### Data Prep

One-off dataset cleanup and capture scripts.

- [Prep scripts](https://github.com/dinosaurerer/spd/blob/main/process_data/rename.py): data prep · Dataset cleanup, renaming, and capture scripts used before training. · `process_data/rename.py`

## Connections

- Run scripts → App entry: start · Platform scripts launch the desktop app.
- App entry → GUI shell: boot · Main entry initializes the application shell.
- GUI shell → Generated UI: loads · The shell binds generated Qt forms and resources.
- GUI shell → UI widgets: uses · Custom widgets provide interaction and visualization.
- GUI shell → Show runtime: opens · Shell transitions into the main show window.
- Show runtime → Thread pool: dispatches · Frame work is handed off to the thread pool.
- Thread pool → Inference threads: runs · Pool schedules YOLOv8/YOLOv11 worker threads.
- Inference threads → Model stack: call into · Workers invoke the embedded model runtime.
- Model stack → Autobackend: executes via · Runtime loads checkpoints through the backend adapter.
- Model stack → MSCA attention: includes · Custom model layers extend the embedded network stack.
- Show runtime → App state: persists · UI state, selected model, and results are stored locally.
- Show runtime → Bundled weights: selects · The UI chooses a local checkpoint for inference.
- Show runtime → Media assets: renders · Splash, icons, and demo media support the desktop experience.
- Train entry → Ultralytics core: uses · Training entrypoint invokes the local Ultralytics engine.
- Predict CLI → Ultralytics core: uses · Standalone prediction runs through the same engine.
- Label viewer → Configs: reads · Inspection tools rely on dataset/config metadata.
- Ultralytics core → Configs: loads · Core engine consumes model and dataset configs.
- Ultralytics core → Run outputs: writes · Training produces metrics, events, and weights in runs/
- MSCA model → Ultralytics core: specializes · Custom architecture config feeds the training runtime.
- Prep scripts → Configs: prepares · Prep scripts help shape datasets used by the model configs.
- Bundled weights → Run outputs: originates from · GUI checkpoints are typically trained artifacts from the YOLO workspace.
