# kaichen-z/rad architecture

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

- Interactive diagram: https://gitdiagram.com/kaichen-z/rad
- Repository: https://github.com/kaichen-z/rad

## Overview

RAD is a multi-view anomaly-detection benchmark with utilities for validating its dataset and adapting it to several evaluation families. The primary workflow is to obtain a RAD archive, validate its layout and optional pose metadata, generate adapter metadata, then run a baseline or convert vision-language box responses into masks. The graph also preserves the documented 3D reconstruction and CLIP adapter branches. Source excerpts substantiate the core utility calls; some method capabilities are documented but their upstream implementations are not included here.

Main entry points: [`src/rad_benchmark/cli.py`](https://github.com/kaichen-z/rad/blob/master/src/rad_benchmark/cli.py) (Benchmark CLI), [`src/rad_benchmark/dataset.py`](https://github.com/kaichen-z/rad/blob/master/src/rad_benchmark/dataset.py) (Dataset validation), [`src/rad_benchmark/vlm.py`](https://github.com/kaichen-z/rad/blob/master/src/rad_benchmark/vlm.py) (Box-to-mask conversion), [`src/rad_benchmark/anomalib.py`](https://github.com/kaichen-z/rad/blob/master/src/rad_benchmark/anomalib.py) (Anomalib runner)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_data["Dataset utilities"]
  node_cli["Benchmark CLI<br/>[cli.py]"]
  node_dataset["Dataset validation<br/>[dataset.py]"]
  node_metadata["Adapter metadata<br/>[dataset.py]"]
end

subgraph group_feature["Feature and CLIP"]
  node_anomalib["Anomalib runner<br/>[anomalib.py]"]
  node_clip_baselines["2D feature baselines"]
  node_adaclip["AdaCLIP adapter"]
  node_vcpclip["VCP-CLIP converter<br/>[convert_rad.py]"]
end

subgraph group_reconstruction["3D reconstruction"]
  node_splat_prepare["SplatPose preparation"]
  node_reconstruction_run["Reconstruction adapter<br/>[run.py]"]
  node_piad_config["PIAD config output<br/>[run.py]"]
end

subgraph group_vision["Vision-language"]
  node_vlm_prompt["VLM evaluation prompt<br/>[prompt.json]"]
  node_vlm_masks["Box-to-mask conversion<br/>[vlm.py]"]
end

node_user(("Benchmark user"))
node_rad_archive[("RAD archive")]
node_anomalib_engine["Anomalib engine"]
node_adaclip_upstream["AdaCLIP upstream"]
node_splatpose["SplatPose upstream"]
node_vlm_provider["VLM provider"]
node_vlm_responses["VLM responses"]
node_mask_output["Predicted masks"]

node_user -->|"downloads"| node_rad_archive
node_user -->|"invokes"| node_cli
node_cli -->|"validates"| node_dataset
node_rad_archive -->|"reads"| node_dataset
node_cli -->|"generates metadata"| node_dataset
node_dataset -->|"writes"| node_metadata
node_metadata -->|"consumed by"| node_adaclip
node_adaclip -.->|"adapts"| node_adaclip_upstream
node_rad_archive -->|"reads"| node_vcpclip
node_vcpclip -->|"writes converted records"| node_metadata
node_cli -->|"dispatches"| node_anomalib
node_anomalib -->|"reads"| node_rad_archive
node_anomalib -->|"runs models"| node_anomalib_engine
node_clip_baselines -.->|"evaluates"| node_rad_archive
node_rad_archive -->|"reads views and poses"| node_splat_prepare
node_splat_prepare -->|"prepares dataset"| node_reconstruction_run
node_reconstruction_run -.->|"launches"| node_splatpose
node_reconstruction_run -->|"writes config"| node_piad_config
node_vlm_prompt -.->|"guides evaluation"| node_vlm_provider
node_vlm_provider -.->|"produces"| node_vlm_responses
node_user -->|"submits responses"| node_cli
node_cli -->|"dispatches"| node_vlm_masks
node_vlm_responses -->|"provides boxes"| node_vlm_masks
node_rad_archive -->|"provides images"| node_vlm_masks
node_vlm_masks -->|"writes"| node_mask_output

click node_cli "https://github.com/kaichen-z/rad/blob/master/src/rad_benchmark/cli.py"
click node_dataset "https://github.com/kaichen-z/rad/blob/master/src/rad_benchmark/dataset.py"
click node_metadata "https://github.com/kaichen-z/rad/blob/master/src/rad_benchmark/dataset.py"
click node_anomalib "https://github.com/kaichen-z/rad/blob/master/src/rad_benchmark/anomalib.py"
click node_clip_baselines "https://github.com/kaichen-z/rad/tree/master/methods/anomalib"
click node_adaclip "https://github.com/kaichen-z/rad/tree/master/methods/adaclip"
click node_vcpclip "https://github.com/kaichen-z/rad/blob/master/methods/vcpclip/convert_rad.py"
click node_splat_prepare "https://github.com/kaichen-z/rad/blob/master/methods/reconstruction/prepare_splatpose.py"
click node_reconstruction_run "https://github.com/kaichen-z/rad/blob/master/methods/reconstruction/run.py"
click node_piad_config "https://github.com/kaichen-z/rad/blob/master/methods/reconstruction/run.py"
click node_vlm_prompt "https://github.com/kaichen-z/rad/blob/master/methods/vlm/prompt.json"
click node_vlm_masks "https://github.com/kaichen-z/rad/blob/master/src/rad_benchmark/vlm.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_cli,node_dataset,node_metadata,node_user toneBlue
class node_anomalib,node_clip_baselines,node_adaclip,node_vcpclip,node_rad_archive toneAmber
class node_splat_prepare,node_reconstruction_run,node_piad_config toneMint
class node_vlm_prompt,node_vlm_masks toneRose
class node_anomalib_engine,node_adaclip_upstream,node_splatpose,node_vlm_provider,node_vlm_responses,node_mask_output toneIndigo
```

## Components

### Dataset utilities

- [Benchmark CLI](https://github.com/kaichen-z/rad/blob/master/src/rad_benchmark/cli.py): `src/rad_benchmark/cli.py`
- [Dataset validation](https://github.com/kaichen-z/rad/blob/master/src/rad_benchmark/dataset.py): `src/rad_benchmark/dataset.py`
- [Adapter metadata](https://github.com/kaichen-z/rad/blob/master/src/rad_benchmark/dataset.py): `src/rad_benchmark/dataset.py`

### Feature and CLIP

- [Anomalib runner](https://github.com/kaichen-z/rad/blob/master/src/rad_benchmark/anomalib.py): `src/rad_benchmark/anomalib.py`
- [2D feature baselines](https://github.com/kaichen-z/rad/tree/master/methods/anomalib): `methods/anomalib`
- [AdaCLIP adapter](https://github.com/kaichen-z/rad/tree/master/methods/adaclip): `methods/adaclip`
- [VCP-CLIP converter](https://github.com/kaichen-z/rad/blob/master/methods/vcpclip/convert_rad.py): `methods/vcpclip/convert_rad.py`

### 3D reconstruction

- [SplatPose preparation](https://github.com/kaichen-z/rad/blob/master/methods/reconstruction/prepare_splatpose.py): `methods/reconstruction/prepare_splatpose.py`
- [Reconstruction adapter](https://github.com/kaichen-z/rad/blob/master/methods/reconstruction/run.py): `methods/reconstruction/run.py`
- [PIAD config output](https://github.com/kaichen-z/rad/blob/master/methods/reconstruction/run.py): `methods/reconstruction/run.py`

### Vision-language

- [VLM evaluation prompt](https://github.com/kaichen-z/rad/blob/master/methods/vlm/prompt.json): `methods/vlm/prompt.json`
- [Box-to-mask conversion](https://github.com/kaichen-z/rad/blob/master/src/rad_benchmark/vlm.py): `src/rad_benchmark/vlm.py`

### Other components

- **Benchmark user**
- **RAD archive**
- **Anomalib engine**
- **AdaCLIP upstream**
- **SplatPose upstream**
- **VLM provider**
- **VLM responses**
- **Predicted masks**

## Connections

- Benchmark user → RAD archive: downloads
- Benchmark user → Benchmark CLI: invokes
- Benchmark CLI → Dataset validation: validates
- RAD archive → Dataset validation: reads
- Benchmark CLI → Dataset validation: generates metadata
- Dataset validation → Adapter metadata: writes
- Adapter metadata → AdaCLIP adapter: consumed by
- AdaCLIP adapter → AdaCLIP upstream: adapts
- RAD archive → VCP-CLIP converter: reads
- VCP-CLIP converter → Adapter metadata: writes converted records
- Benchmark CLI → Anomalib runner: dispatches
- Anomalib runner → RAD archive: reads
- Anomalib runner → Anomalib engine: runs models
- 2D feature baselines → RAD archive: evaluates
- RAD archive → SplatPose preparation: reads views and poses
- SplatPose preparation → Reconstruction adapter: prepares dataset
- Reconstruction adapter → SplatPose upstream: launches
- Reconstruction adapter → PIAD config output: writes config
- VLM evaluation prompt → VLM provider: guides evaluation
- VLM provider → VLM responses: produces
- Benchmark user → Benchmark CLI: submits responses
- Benchmark CLI → Box-to-mask conversion: dispatches
- VLM responses → Box-to-mask conversion: provides boxes
- RAD archive → Box-to-mask conversion: provides images
- Box-to-mask conversion → Predicted masks: writes
