# kaai520/pgfa architecture

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

- Interactive diagram: https://gitdiagram.com/kaai520/pgfa
- Repository: https://github.com/kaai520/pgfa
- Video tour (about a minute): https://gitdiagram.com/kaai520/pgfa/video

## Overview

PGFA trains skeleton encoders to align action features with text embeddings, then evaluates unseen actions using prototype-guided alignment. It supports ST-GCN and Shift-GCN zero-shot settings, plus ST-GCN one-shot experiments. The README documents prepared skeleton data, label/description text features, and prototype-based testing; sampled source confirms the training components and backbone implementations. Test and one-shot wiring is represented at the workflow level because those implementations were not fully sampled.

Main entry points: [`main.py`](https://github.com/kaai520/pgfa/blob/main/main.py) (Zero-shot training), [`dataset.py`](https://github.com/kaai520/pgfa/blob/main/dataset.py) (Skeleton dataset), [`test_main.py`](https://github.com/kaai520/pgfa/blob/main/test_main.py) (Zero-shot testing), [`one_shot_test_main.py`](https://github.com/kaai520/pgfa/blob/main/one_shot_test_main.py) (One-shot testing)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_workflow["Experiment workflows"]
  node_train["Zero-shot training<br/>[main.py]"]
  node_test["Zero-shot testing<br/>[test_main.py]"]
  node_oneshot["One-shot workflow<br/>[one_shot_main.py]"]
  node_oneshot_test["One-shot testing"]
  node_config["Experiment settings<br/>[config.py]"]
end

subgraph group_data["Data and language"]
  node_dataset["Skeleton dataset<br/>[dataset.py]"]
  node_prepared[("Prepared data")]
  node_descriptions["Action descriptions"]
  node_embeddings[("Text embeddings")]
  node_embedder["Sentence embedding"]
end

subgraph group_models["Feature models"]
  node_stgcn["ST-GCN<br/>[st_gcn.py]"]
  node_shiftgcn["Shift-GCN<br/>[shift_gcn.py]"]
  node_adapter["Feature adapter<br/>[adapter.py]"]
end

subgraph group_evaluation["Alignment and evaluation"]
  node_objective["Contrastive losses<br/>[KLLoss.py]"]
  node_tools["Similarity and metrics<br/>[tool.py]"]
  node_prototype["Prototype alignment<br/>[test_main.py]"]
  node_results["Predictions and scores"]
end

node_researcher(("Researcher"))
node_sentencebert["Sentence-BERT"]

node_researcher -->|"starts training"| node_train
node_researcher -->|"starts testing"| node_test
node_researcher -->|"starts training"| node_oneshot
node_config -->|"configures"| node_train
node_config -->|"configures"| node_test
node_dataset -->|"loads skeletons"| node_prepared
node_dataset -->|"loads features"| node_embeddings
node_descriptions -.->|"supplies text"| node_embedder
node_embedder -.->|"encodes descriptions"| node_sentencebert
node_embedder -.->|"writes vectors"| node_embeddings
node_train -->|"loads batches"| node_dataset
node_train -->|"trains encoder"| node_stgcn
node_train -.->|"selects encoder"| node_shiftgcn
node_train -->|"trains adapter"| node_adapter
node_train -->|"computes loss"| node_objective
node_test -->|"loads evaluation data"| node_dataset
node_test -->|"evaluates alignment"| node_prototype
node_prototype -->|"scores features"| node_tools
node_prototype -->|"produces scores"| node_results
node_oneshot -->|"loads support data"| node_dataset
node_oneshot_test -->|"loads test data"| node_dataset
node_oneshot_test -->|"uses exemplars"| node_prototype
node_oneshot_test -->|"scores predictions"| node_tools
node_train -->|"saves checkpoints"| node_results

click node_train "https://github.com/kaai520/pgfa/blob/main/main.py"
click node_test "https://github.com/kaai520/pgfa/blob/main/test_main.py"
click node_oneshot "https://github.com/kaai520/pgfa/blob/main/one_shot_main.py"
click node_oneshot_test "https://github.com/kaai520/pgfa/blob/main/one_shot_test_main.py"
click node_config "https://github.com/kaai520/pgfa/blob/main/config.py"
click node_dataset "https://github.com/kaai520/pgfa/blob/main/dataset.py"
click node_descriptions "https://github.com/kaai520/pgfa/tree/main/descriptions"
click node_embedder "https://github.com/kaai520/pgfa/blob/main/sentence_bert_embedding.py"
click node_stgcn "https://github.com/kaai520/pgfa/blob/main/module/gcn/st_gcn.py"
click node_shiftgcn "https://github.com/kaai520/pgfa/blob/main/module/shift_gcn.py"
click node_adapter "https://github.com/kaai520/pgfa/blob/main/module/adapter.py"
click node_objective "https://github.com/kaai520/pgfa/blob/main/KLLoss.py"
click node_tools "https://github.com/kaai520/pgfa/blob/main/tool.py"
click node_prototype "https://github.com/kaai520/pgfa/blob/main/test_main.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_train,node_test,node_oneshot,node_oneshot_test,node_config toneBlue
class node_dataset,node_prepared,node_descriptions,node_embeddings,node_embedder toneAmber
class node_stgcn,node_shiftgcn,node_adapter toneMint
class node_objective,node_tools,node_prototype,node_results toneRose
class node_researcher,node_sentencebert toneIndigo
```

## Components

### Experiment workflows

- [Zero-shot training](https://github.com/kaai520/pgfa/blob/main/main.py): `main.py`
- [Zero-shot testing](https://github.com/kaai520/pgfa/blob/main/test_main.py): `test_main.py`
- [One-shot workflow](https://github.com/kaai520/pgfa/blob/main/one_shot_main.py): `one_shot_main.py`
- [One-shot testing](https://github.com/kaai520/pgfa/blob/main/one_shot_test_main.py): `one_shot_test_main.py`
- [Experiment settings](https://github.com/kaai520/pgfa/blob/main/config.py): `config.py`

### Data and language

- [Skeleton dataset](https://github.com/kaai520/pgfa/blob/main/dataset.py): `dataset.py`
- **Prepared data**
- [Action descriptions](https://github.com/kaai520/pgfa/tree/main/descriptions): `descriptions`
- **Text embeddings**
- [Sentence embedding](https://github.com/kaai520/pgfa/blob/main/sentence_bert_embedding.py): `sentence_bert_embedding.py`

### Feature models

- [ST-GCN](https://github.com/kaai520/pgfa/blob/main/module/gcn/st_gcn.py): `module/gcn/st_gcn.py`
- [Shift-GCN](https://github.com/kaai520/pgfa/blob/main/module/shift_gcn.py): `module/shift_gcn.py`
- [Feature adapter](https://github.com/kaai520/pgfa/blob/main/module/adapter.py): `module/adapter.py`

### Alignment and evaluation

- [Contrastive losses](https://github.com/kaai520/pgfa/blob/main/KLLoss.py): `KLLoss.py`
- [Similarity and metrics](https://github.com/kaai520/pgfa/blob/main/tool.py): `tool.py`
- [Prototype alignment](https://github.com/kaai520/pgfa/blob/main/test_main.py): `test_main.py`
- **Predictions and scores**

### Other components

- **Researcher**
- **Sentence-BERT**

## Connections

- Researcher → Zero-shot training: starts training
- Researcher → Zero-shot testing: starts testing
- Researcher → One-shot workflow: starts training
- Experiment settings → Zero-shot training: configures
- Experiment settings → Zero-shot testing: configures
- Skeleton dataset → Prepared data: loads skeletons
- Skeleton dataset → Text embeddings: loads features
- Action descriptions → Sentence embedding: supplies text
- Sentence embedding → Sentence-BERT: encodes descriptions
- Sentence embedding → Text embeddings: writes vectors
- Zero-shot training → Skeleton dataset: loads batches
- Zero-shot training → ST-GCN: trains encoder
- Zero-shot training → Shift-GCN: selects encoder
- Zero-shot training → Feature adapter: trains adapter
- Zero-shot training → Contrastive losses: computes loss
- Zero-shot testing → Skeleton dataset: loads evaluation data
- Zero-shot testing → Prototype alignment: evaluates alignment
- Prototype alignment → Similarity and metrics: scores features
- Prototype alignment → Predictions and scores: produces scores
- One-shot workflow → Skeleton dataset: loads support data
- One-shot testing → Skeleton dataset: loads test data
- One-shot testing → Prototype alignment: uses exemplars
- One-shot testing → Similarity and metrics: scores predictions
- Zero-shot training → Predictions and scores: saves checkpoints
