# oonat/ezpc architecture

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

- Interactive diagram: https://gitdiagram.com/oonat/ezpc
- Repository: https://github.com/oonat/ezpc

## Overview

EZPC learns a concept-space projection that explains CLIP/SigLIP zero-shot predictions. The main workflow prepares image embeddings and class splits, caches text embeddings for class names and concepts, trains a projection, then evaluates generalized zero-shot accuracy and fidelity. Separate analysis tools inspect concept geometry, faithfulness, transfer, and visual explanations. The README documents the data-to-training-to-evaluation flow; experiment relationships beyond imports and named utilities are shown only where supported, with uncertain links omitted.

Main entry points: [`utils.py`](https://github.com/oonat/ezpc/blob/main/utils.py) (Shared utilities), [`train.py`](https://github.com/oonat/ezpc/blob/main/train.py) (Projection training), [`test.py`](https://github.com/oonat/ezpc/blob/main/test.py) (Zero-shot evaluation), [`dataset.py`](https://github.com/oonat/ezpc/blob/main/dataset.py) (Raw image datasets)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_data["Data preparation"]
  node_download["Dataset download"]
  node_extract["Image embeddings"]
  node_split["Class splits<br/>[split_dataset.py]"]
  node_textcache["Text embeddings<br/>[save_text_embs.py]"]
  node_dataset["Raw image datasets<br/>[dataset.py]"]
end

subgraph group_core["Projection and evaluation"]
  node_utils["Shared utilities<br/>[utils.py]"]
  node_trainer["Projection training<br/>[train.py]"]
  node_model["EZPC projection<br/>[model.py]"]
  node_evaluator["Zero-shot evaluation<br/>[test.py]"]
end

subgraph group_analysis["Model analysis"]
  node_conceptspace["Concept-space analysis"]
  node_faithfulness["Faithfulness analysis"]
  node_transfer["Cross-dataset transfer<br/>[cross_train.py]"]
  node_vocab["Vocabulary ablation<br/>[train.py]"]
  node_clustering["Concept clustering<br/>[clustering.py]"]
end

subgraph group_visual["Visual explanations"]
  node_iou["Region IoU metrics"]
  node_heatmap["Patch heatmaps"]
  node_classview["Class explanations"]
  node_imageview["Image explanations"]
end

node_user(("Researcher"))
node_raw[("Benchmark data")]
node_embeddings[("Cached embeddings")]
node_checkpoint[("Learned projection")]

node_user -->|"prepares data"| node_download
node_raw -->|"download source"| node_download
node_download -->|"supplies images"| node_extract
node_extract -->|"writes image vectors"| node_embeddings
node_embeddings -->|"splits vectors"| node_split
node_split -->|"writes class splits"| node_embeddings
node_embeddings -->|"stores text vectors"| node_textcache
node_user -->|"trains projection"| node_trainer
node_embeddings -->|"loads training vectors"| node_trainer
node_trainer -->|"uses helpers"| node_utils
node_trainer -->|"optimizes"| node_model
node_trainer -->|"saves weights"| node_checkpoint
node_user -->|"evaluates model"| node_evaluator
node_evaluator -->|"loads weights"| node_checkpoint
node_evaluator -->|"loads test vectors"| node_embeddings
node_evaluator -.->|"uses helpers"| node_utils
node_conceptspace -->|"uses helpers"| node_utils
node_faithfulness -->|"uses helpers"| node_utils
node_transfer -->|"uses helpers"| node_utils
node_transfer -->|"optimizes"| node_model
node_vocab -->|"uses helpers"| node_utils
node_vocab -->|"optimizes"| node_model
node_heatmap -->|"uses helpers"| node_utils
node_heatmap -->|"loads images"| node_dataset
node_classview -->|"uses helpers"| node_utils
node_classview -->|"loads images"| node_dataset
node_imageview -->|"uses dataset"| node_dataset
node_clustering -->|"uses dataset"| node_dataset
node_iou -->|"uses helpers"| node_utils

click node_download "https://github.com/oonat/ezpc/blob/main/data/download_dataset.py"
click node_extract "https://github.com/oonat/ezpc/blob/main/data/extract_clip_features.py"
click node_split "https://github.com/oonat/ezpc/blob/main/data/split_dataset.py"
click node_textcache "https://github.com/oonat/ezpc/blob/main/data/save_text_embs.py"
click node_utils "https://github.com/oonat/ezpc/blob/main/utils.py"
click node_dataset "https://github.com/oonat/ezpc/blob/main/dataset.py"
click node_trainer "https://github.com/oonat/ezpc/blob/main/train.py"
click node_model "https://github.com/oonat/ezpc/blob/main/model.py"
click node_evaluator "https://github.com/oonat/ezpc/blob/main/test.py"
click node_conceptspace "https://github.com/oonat/ezpc/blob/main/experiments/concept_space_analysis.py"
click node_faithfulness "https://github.com/oonat/ezpc/blob/main/experiments/faithfulness_analysis.py"
click node_transfer "https://github.com/oonat/ezpc/blob/main/experiments/cross_dataset_transfer/cross_train.py"
click node_vocab "https://github.com/oonat/ezpc/blob/main/experiments/vocab_size_ablation/train.py"
click node_iou "https://github.com/oonat/ezpc/blob/main/experiments/concept_region_alignment/calculate_iou_metrics.py"
click node_heatmap "https://github.com/oonat/ezpc/blob/main/experiments/concept_region_alignment/generate_patch_heatmap.py"
click node_classview "https://github.com/oonat/ezpc/blob/main/experiments/qualitative_experiments/class_level_analysis.py"
click node_imageview "https://github.com/oonat/ezpc/blob/main/experiments/qualitative_experiments/image_level_analysis.py"
click node_clustering "https://github.com/oonat/ezpc/blob/main/experiments/qualitative_experiments/clustering.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_download,node_extract,node_split,node_textcache,node_dataset toneBlue
class node_utils,node_trainer,node_model,node_evaluator,node_raw,node_embeddings,node_checkpoint toneAmber
class node_conceptspace,node_faithfulness,node_transfer,node_vocab,node_clustering toneMint
class node_iou,node_heatmap,node_classview,node_imageview toneRose
class node_user toneIndigo
```

## Components

### Data preparation

- [Dataset download](https://github.com/oonat/ezpc/blob/main/data/download_dataset.py): `data/download_dataset.py`
- [Image embeddings](https://github.com/oonat/ezpc/blob/main/data/extract_clip_features.py): `data/extract_clip_features.py`
- [Class splits](https://github.com/oonat/ezpc/blob/main/data/split_dataset.py): `data/split_dataset.py`
- [Text embeddings](https://github.com/oonat/ezpc/blob/main/data/save_text_embs.py): `data/save_text_embs.py`
- [Raw image datasets](https://github.com/oonat/ezpc/blob/main/dataset.py): `dataset.py`

### Projection and evaluation

- [Shared utilities](https://github.com/oonat/ezpc/blob/main/utils.py): `utils.py`
- [Projection training](https://github.com/oonat/ezpc/blob/main/train.py): `train.py`
- [EZPC projection](https://github.com/oonat/ezpc/blob/main/model.py): `model.py`
- [Zero-shot evaluation](https://github.com/oonat/ezpc/blob/main/test.py): `test.py`

### Model analysis

- [Concept-space analysis](https://github.com/oonat/ezpc/blob/main/experiments/concept_space_analysis.py): `experiments/concept_space_analysis.py`
- [Faithfulness analysis](https://github.com/oonat/ezpc/blob/main/experiments/faithfulness_analysis.py): `experiments/faithfulness_analysis.py`
- [Cross-dataset transfer](https://github.com/oonat/ezpc/blob/main/experiments/cross_dataset_transfer/cross_train.py): `experiments/cross_dataset_transfer/cross_train.py`
- [Vocabulary ablation](https://github.com/oonat/ezpc/blob/main/experiments/vocab_size_ablation/train.py): `experiments/vocab_size_ablation/train.py`
- [Concept clustering](https://github.com/oonat/ezpc/blob/main/experiments/qualitative_experiments/clustering.py): `experiments/qualitative_experiments/clustering.py`

### Visual explanations

- [Region IoU metrics](https://github.com/oonat/ezpc/blob/main/experiments/concept_region_alignment/calculate_iou_metrics.py): `experiments/concept_region_alignment/calculate_iou_metrics.py`
- [Patch heatmaps](https://github.com/oonat/ezpc/blob/main/experiments/concept_region_alignment/generate_patch_heatmap.py): `experiments/concept_region_alignment/generate_patch_heatmap.py`
- [Class explanations](https://github.com/oonat/ezpc/blob/main/experiments/qualitative_experiments/class_level_analysis.py): `experiments/qualitative_experiments/class_level_analysis.py`
- [Image explanations](https://github.com/oonat/ezpc/blob/main/experiments/qualitative_experiments/image_level_analysis.py): `experiments/qualitative_experiments/image_level_analysis.py`

### Other components

- **Researcher**
- **Benchmark data**
- **Cached embeddings**
- **Learned projection**

## Connections

- Researcher → Dataset download: prepares data (evidence: `README.md`)
- Benchmark data → Dataset download: download source (evidence: `README.md`)
- Dataset download → Image embeddings: supplies images (evidence: `README.md`)
- Image embeddings → Cached embeddings: writes image vectors (evidence: `README.md`)
- Cached embeddings → Class splits: splits vectors (evidence: `README.md`)
- Class splits → Cached embeddings: writes class splits (evidence: `README.md`)
- Cached embeddings → Text embeddings: stores text vectors (evidence: `README.md`)
- Researcher → Projection training: trains projection (evidence: `README.md`)
- Cached embeddings → Projection training: loads training vectors (evidence: `README.md`)
- Projection training → Shared utilities: uses helpers (evidence: `train.py`)
- Projection training → EZPC projection: optimizes (evidence: `train.py`)
- Projection training → Learned projection: saves weights (evidence: `README.md`)
- Researcher → Zero-shot evaluation: evaluates model (evidence: `README.md`)
- Zero-shot evaluation → Learned projection: loads weights (evidence: `README.md`)
- Zero-shot evaluation → Cached embeddings: loads test vectors (evidence: `README.md`)
- Zero-shot evaluation → Shared utilities: uses helpers
- Concept-space analysis → Shared utilities: uses helpers (evidence: `experiments/concept_space_analysis.py`)
- Faithfulness analysis → Shared utilities: uses helpers (evidence: `experiments/faithfulness_analysis.py`)
- Cross-dataset transfer → Shared utilities: uses helpers (evidence: `experiments/cross_dataset_transfer/cross_train.py`)
- Cross-dataset transfer → EZPC projection: optimizes (evidence: `experiments/cross_dataset_transfer/cross_train.py`)
- Vocabulary ablation → Shared utilities: uses helpers (evidence: `experiments/vocab_size_ablation/train.py`)
- Vocabulary ablation → EZPC projection: optimizes (evidence: `experiments/vocab_size_ablation/train.py`)
- Patch heatmaps → Shared utilities: uses helpers (evidence: `experiments/concept_region_alignment/generate_patch_heatmap.py`)
- Patch heatmaps → Raw image datasets: loads images (evidence: `experiments/concept_region_alignment/generate_patch_heatmap.py`)
- Class explanations → Shared utilities: uses helpers (evidence: `experiments/qualitative_experiments/class_level_analysis.py`)
- Class explanations → Raw image datasets: loads images (evidence: `experiments/qualitative_experiments/class_level_analysis.py`)
- Image explanations → Raw image datasets: uses dataset (evidence: `experiments/qualitative_experiments/image_level_analysis.py`)
- Concept clustering → Raw image datasets: uses dataset (evidence: `experiments/qualitative_experiments/clustering.py`)
- Region IoU metrics → Shared utilities: uses helpers (evidence: `experiments/concept_region_alignment/calculate_iou_metrics.py`)
