# ttlabtuat/tinycardiounet architecture

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

- Interactive diagram: https://gitdiagram.com/ttlabtuat/tinycardiounet
- Repository: https://github.com/ttlabtuat/tinycardiounet

## Overview

TinyCardioUNet reconstructs a single-lead ECG from six-axis chest IMU signals. The inference example loads the base model, applies VBMF-guided compression, loads compressed fine-tuned weights, and runs prediction. The model encodes the IMU signal, applies graph-based inter-axis aggregation at its bottleneck, then decodes the features into ECG. Compression is a separate capability; the repository includes pretrained weights but no training workflow. Relationships are based on the excerpts and README; no unsampled implementation is assumed.

Main entry points: [`main.py`](https://github.com/ttlabtuat/tinycardiounet/blob/main/main.py) (Inference Example), [`decompose_tinycardiounet_vbmf.py`](https://github.com/ttlabtuat/tinycardiounet/blob/main/decompose_tinycardiounet_vbmf.py) (Compression Driver), [`TinyCardioUNet/model.py`](https://github.com/ttlabtuat/tinycardiounet/blob/main/TinyCardioUNet/model.py) (Graph Bottleneck), [`TinyCardioUNet/graph.py`](https://github.com/ttlabtuat/tinycardiounet/blob/main/TinyCardioUNet/graph.py) (IMU Graph)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_inference["ECG Inference"]
  node_runner["Inference Example<br/>[main.py]"]
  node_weights["Pretrained Weights"]
  node_ecg["Predicted ECG"]
end

subgraph group_architecture["Graph U-Net"]
  node_encoder["Signal Encoder<br/>[model.py]"]
  node_graph_config["IMU Graph<br/>[graph.py]"]
  node_sage["Graph Bottleneck<br/>[model.py]"]
  node_decoder["ECG Decoder<br/>[model.py]"]
end

subgraph group_compression["Model Compression"]
  node_compressor["Compression Driver"]
  node_rank_selection["VBMF Rank Selection"]
  node_vbmf["EVBMF Solver<br/>[vbmf.py]"]
  node_factorization["Layer Factorization"]
end

node_user(("IMU User"))

node_user -->|"provides IMU"| node_runner
node_runner -->|"loads weights"| node_weights
node_runner -->|"compresses model"| node_compressor
node_runner -->|"runs model"| node_encoder
node_encoder -->|"forwards features"| node_sage
node_graph_config -->|"configures graph"| node_sage
node_sage -->|"forwards features"| node_decoder
node_decoder -->|"produces ECG"| node_ecg
node_compressor -->|"selects ranks"| node_rank_selection
node_rank_selection -->|"estimates ranks"| node_vbmf
node_compressor -->|"replaces layers"| node_factorization
node_runner -->|"returns prediction"| node_ecg

click node_runner "https://github.com/ttlabtuat/tinycardiounet/blob/main/main.py"
click node_weights "https://github.com/ttlabtuat/tinycardiounet/tree/main/weights"
click node_encoder "https://github.com/ttlabtuat/tinycardiounet/blob/main/TinyCardioUNet/model.py"
click node_graph_config "https://github.com/ttlabtuat/tinycardiounet/blob/main/TinyCardioUNet/graph.py"
click node_sage "https://github.com/ttlabtuat/tinycardiounet/blob/main/TinyCardioUNet/model.py"
click node_decoder "https://github.com/ttlabtuat/tinycardiounet/blob/main/TinyCardioUNet/model.py"
click node_compressor "https://github.com/ttlabtuat/tinycardiounet/blob/main/decompose_tinycardiounet_vbmf.py"
click node_rank_selection "https://github.com/ttlabtuat/tinycardiounet/blob/main/decompose_tinycardiounet_vbmf.py"
click node_vbmf "https://github.com/ttlabtuat/tinycardiounet/blob/main/src/vbmf.py"
click node_factorization "https://github.com/ttlabtuat/tinycardiounet/blob/main/decompose_tinycardiounet_vbmf.py"

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_runner,node_weights,node_ecg,node_user toneBlue
class node_encoder,node_graph_config,node_sage,node_decoder toneAmber
class node_compressor,node_rank_selection,node_vbmf,node_factorization toneMint
```

## Components

### ECG Inference

- [Inference Example](https://github.com/ttlabtuat/tinycardiounet/blob/main/main.py): `main.py`
- [Pretrained Weights](https://github.com/ttlabtuat/tinycardiounet/tree/main/weights): `weights`
- **Predicted ECG**

### Graph U-Net

- [Signal Encoder](https://github.com/ttlabtuat/tinycardiounet/blob/main/TinyCardioUNet/model.py): `TinyCardioUNet/model.py`
- [IMU Graph](https://github.com/ttlabtuat/tinycardiounet/blob/main/TinyCardioUNet/graph.py): `TinyCardioUNet/graph.py`
- [Graph Bottleneck](https://github.com/ttlabtuat/tinycardiounet/blob/main/TinyCardioUNet/model.py): `TinyCardioUNet/model.py`
- [ECG Decoder](https://github.com/ttlabtuat/tinycardiounet/blob/main/TinyCardioUNet/model.py): `TinyCardioUNet/model.py`

### Model Compression

- [Compression Driver](https://github.com/ttlabtuat/tinycardiounet/blob/main/decompose_tinycardiounet_vbmf.py): `decompose_tinycardiounet_vbmf.py`
- [VBMF Rank Selection](https://github.com/ttlabtuat/tinycardiounet/blob/main/decompose_tinycardiounet_vbmf.py): `decompose_tinycardiounet_vbmf.py`
- [EVBMF Solver](https://github.com/ttlabtuat/tinycardiounet/blob/main/src/vbmf.py): `src/vbmf.py`
- [Layer Factorization](https://github.com/ttlabtuat/tinycardiounet/blob/main/decompose_tinycardiounet_vbmf.py): `decompose_tinycardiounet_vbmf.py`

### Other components

- **IMU User**

## Connections

- IMU User → Inference Example: provides IMU (evidence: `README.md`)
- Inference Example → Pretrained Weights: loads weights (evidence: `main.py`)
- Inference Example → Compression Driver: compresses model (evidence: `main.py`)
- Inference Example → Signal Encoder: runs model (evidence: `main.py`)
- Signal Encoder → Graph Bottleneck: forwards features (evidence: `TinyCardioUNet/model.py`)
- IMU Graph → Graph Bottleneck: configures graph (evidence: `TinyCardioUNet/model.py`)
- Graph Bottleneck → ECG Decoder: forwards features (evidence: `TinyCardioUNet/model.py`)
- ECG Decoder → Predicted ECG: produces ECG (evidence: `TinyCardioUNet/model.py`)
- Compression Driver → VBMF Rank Selection: selects ranks (evidence: `decompose_tinycardiounet_vbmf.py`)
- VBMF Rank Selection → EVBMF Solver: estimates ranks (evidence: `decompose_tinycardiounet_vbmf.py`)
- Compression Driver → Layer Factorization: replaces layers (evidence: `decompose_tinycardiounet_vbmf.py`)
- Inference Example → Predicted ECG: returns prediction (evidence: `main.py`)
