# aiconslab/3dino architecture

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

- Interactive diagram: https://gitdiagram.com/aiconslab/3dino
- Repository: https://github.com/aiconslab/3dino

## Overview

3DINO is a 3D medical-imaging self-supervised pretraining framework, with a pretrained 3D ViT intended for reuse in downstream tasks. The main workflow prepares unlabeled volumes, trains a student–teacher model, then uses pretrained features for classification or fine-tunes segmentation heads. The README also documents high-resolution adaptation and PCA visualization. Source excerpts and the index support the training and evaluation entry points; some internal data flow and unsampled evaluation details are shown only where documented.

Main entry points: [`dinov2/eval/segmentation3d.py`](https://github.com/aiconslab/3dino/blob/main/dinov2/eval/segmentation3d.py) (Segmentation fine-tuning), [`dinov2/train/ssl_meta_arch.py`](https://github.com/aiconslab/3dino/blob/main/dinov2/train/ssl_meta_arch.py) (SSL training architecture), [`dinov2/data/loaders.py`](https://github.com/aiconslab/3dino/blob/main/dinov2/data/loaders.py) (Dataset loaders), [`dinov2/eval/linear3d.py`](https://github.com/aiconslab/3dino/blob/main/dinov2/eval/linear3d.py) (Linear classification)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_data["Medical image data"]
  node_data_aug["Pretraining augmentation<br/>[augmentations.py]"]
  node_data_loader["Dataset loaders<br/>[loaders.py]"]
  node_samplers["Data samplers<br/>[samplers.py]"]
  node_transforms["Image transforms<br/>[transforms.py]"]
end

subgraph group_pretrain["Self-supervised pretraining"]
  node_train_entry["Training entry point<br/>[train3d.py]"]
  node_ssl_arch["SSL training architecture<br/>[ssl_meta_arch.py]"]
  node_dino_loss["DINO class loss"]
  node_ibot_loss["iBOT patch loss<br/>[ibot_patch_loss.py]"]
  node_koleo_loss["KoLeo loss<br/>[koleo_loss.py]"]
end

subgraph group_model["3DINO model"]
  node_vit["3D Vision Transformer"]
  node_vit_blocks["Transformer blocks<br/>[block.py]"]
  node_attention["Attention layer<br/>[attention.py]"]
  node_mlp["MLP layer<br/>[mlp.py]"]
  node_patch_embed["3D patch embedding<br/>[patch_embed3d.py]"]
end

subgraph group_eval["Downstream evaluation"]
  node_eval_setup["Evaluation setup<br/>[setup.py]"]
  node_linear_eval["Linear classification<br/>[linear3d.py]"]
  node_seg_eval["Segmentation fine-tuning<br/>[segmentation3d.py]"]
  node_seg_heads["Segmentation heads"]
  node_seg_adapter["ViT adapter<br/>[vit_adapter.py]"]
  node_seg_aug["Segmentation augmentation<br/>[augmentations.py]"]
  node_seg_metrics["Segmentation metrics<br/>[metrics.py]"]
  node_pca["Feature visualization<br/>[vis_pca.py]"]
end

node_researcher(("Researcher"))
node_volumes["Medical volumes"]
node_pretrained["Pretrained weights"]

node_researcher -->|"starts training"| node_train_entry
node_volumes -->|"provides dataset"| node_data_loader
node_data_loader -->|"uses sampler"| node_samplers
node_train_entry -->|"trains model"| node_ssl_arch
node_train_entry -->|"sets up data"| node_data_loader
node_ssl_arch -->|"builds backbone"| node_vit
node_ssl_arch -->|"computes class loss"| node_dino_loss
node_ssl_arch -->|"computes patch loss"| node_ibot_loss
node_ssl_arch -->|"computes KoLeo loss"| node_koleo_loss
node_vit -->|"constructs blocks"| node_vit_blocks
node_vit -->|"embeds patches"| node_patch_embed
node_vit_blocks -->|"uses attention"| node_attention
node_vit_blocks -->|"uses MLP"| node_mlp
node_researcher -->|"runs classification"| node_linear_eval
node_researcher -->|"runs segmentation"| node_seg_eval
node_pretrained -->|"loads weights"| node_linear_eval
node_pretrained -->|"loads weights"| node_seg_eval
node_linear_eval -->|"configures evaluation"| node_eval_setup
node_seg_eval -->|"configures evaluation"| node_eval_setup
node_linear_eval -->|"builds dataset"| node_data_loader
node_seg_eval -->|"builds datasets"| node_data_loader
node_seg_eval -->|"selects head"| node_seg_heads
node_seg_heads -->|"uses adapter"| node_seg_adapter
node_seg_eval -->|"uses transforms"| node_seg_aug
node_seg_eval -->|"evaluates metrics"| node_seg_metrics
node_researcher -->|"visualizes features"| node_pca

click node_data_aug "https://github.com/aiconslab/3dino/blob/main/dinov2/data/augmentations.py"
click node_data_loader "https://github.com/aiconslab/3dino/blob/main/dinov2/data/loaders.py"
click node_samplers "https://github.com/aiconslab/3dino/blob/main/dinov2/data/samplers.py"
click node_transforms "https://github.com/aiconslab/3dino/blob/main/dinov2/data/transforms.py"
click node_train_entry "https://github.com/aiconslab/3dino/blob/main/dinov2/train/train3d.py"
click node_ssl_arch "https://github.com/aiconslab/3dino/blob/main/dinov2/train/ssl_meta_arch.py"
click node_dino_loss "https://github.com/aiconslab/3dino/blob/main/dinov2/loss/dino_clstoken_loss.py"
click node_ibot_loss "https://github.com/aiconslab/3dino/blob/main/dinov2/loss/ibot_patch_loss.py"
click node_koleo_loss "https://github.com/aiconslab/3dino/blob/main/dinov2/loss/koleo_loss.py"
click node_vit "https://github.com/aiconslab/3dino/blob/main/dinov2/models/vision_transformer.py"
click node_vit_blocks "https://github.com/aiconslab/3dino/blob/main/dinov2/layers/block.py"
click node_attention "https://github.com/aiconslab/3dino/blob/main/dinov2/layers/attention.py"
click node_mlp "https://github.com/aiconslab/3dino/blob/main/dinov2/layers/mlp.py"
click node_patch_embed "https://github.com/aiconslab/3dino/blob/main/dinov2/layers/patch_embed3d.py"
click node_eval_setup "https://github.com/aiconslab/3dino/blob/main/dinov2/eval/setup.py"
click node_linear_eval "https://github.com/aiconslab/3dino/blob/main/dinov2/eval/linear3d.py"
click node_seg_eval "https://github.com/aiconslab/3dino/blob/main/dinov2/eval/segmentation3d.py"
click node_seg_heads "https://github.com/aiconslab/3dino/blob/main/dinov2/eval/segmentation_3d/segmentation_heads.py"
click node_seg_adapter "https://github.com/aiconslab/3dino/blob/main/dinov2/eval/segmentation_3d/vit_adapter.py"
click node_seg_aug "https://github.com/aiconslab/3dino/blob/main/dinov2/eval/segmentation_3d/augmentations.py"
click node_seg_metrics "https://github.com/aiconslab/3dino/blob/main/dinov2/eval/segmentation_3d/metrics.py"
click node_pca "https://github.com/aiconslab/3dino/blob/main/dinov2/eval/vis_pca.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_data_aug,node_data_loader,node_samplers,node_transforms toneBlue
class node_train_entry,node_ssl_arch,node_dino_loss,node_ibot_loss,node_koleo_loss toneAmber
class node_vit,node_vit_blocks,node_attention,node_mlp,node_patch_embed toneMint
class node_eval_setup,node_linear_eval,node_seg_eval,node_seg_heads,node_seg_adapter,node_seg_aug,node_seg_metrics,node_pca toneRose
class node_researcher,node_volumes,node_pretrained toneIndigo
```

## Components

### Medical image data

- [Pretraining augmentation](https://github.com/aiconslab/3dino/blob/main/dinov2/data/augmentations.py): `dinov2/data/augmentations.py`
- [Dataset loaders](https://github.com/aiconslab/3dino/blob/main/dinov2/data/loaders.py): `dinov2/data/loaders.py`
- [Data samplers](https://github.com/aiconslab/3dino/blob/main/dinov2/data/samplers.py): `dinov2/data/samplers.py`
- [Image transforms](https://github.com/aiconslab/3dino/blob/main/dinov2/data/transforms.py): `dinov2/data/transforms.py`

### Self-supervised pretraining

- [Training entry point](https://github.com/aiconslab/3dino/blob/main/dinov2/train/train3d.py): `dinov2/train/train3d.py`
- [SSL training architecture](https://github.com/aiconslab/3dino/blob/main/dinov2/train/ssl_meta_arch.py): `dinov2/train/ssl_meta_arch.py`
- [DINO class loss](https://github.com/aiconslab/3dino/blob/main/dinov2/loss/dino_clstoken_loss.py): `dinov2/loss/dino_clstoken_loss.py`
- [iBOT patch loss](https://github.com/aiconslab/3dino/blob/main/dinov2/loss/ibot_patch_loss.py): `dinov2/loss/ibot_patch_loss.py`
- [KoLeo loss](https://github.com/aiconslab/3dino/blob/main/dinov2/loss/koleo_loss.py): `dinov2/loss/koleo_loss.py`

### 3DINO model

- [3D Vision Transformer](https://github.com/aiconslab/3dino/blob/main/dinov2/models/vision_transformer.py): `dinov2/models/vision_transformer.py`
- [Transformer blocks](https://github.com/aiconslab/3dino/blob/main/dinov2/layers/block.py): `dinov2/layers/block.py`
- [Attention layer](https://github.com/aiconslab/3dino/blob/main/dinov2/layers/attention.py): `dinov2/layers/attention.py`
- [MLP layer](https://github.com/aiconslab/3dino/blob/main/dinov2/layers/mlp.py): `dinov2/layers/mlp.py`
- [3D patch embedding](https://github.com/aiconslab/3dino/blob/main/dinov2/layers/patch_embed3d.py): `dinov2/layers/patch_embed3d.py`

### Downstream evaluation

- [Evaluation setup](https://github.com/aiconslab/3dino/blob/main/dinov2/eval/setup.py): `dinov2/eval/setup.py`
- [Linear classification](https://github.com/aiconslab/3dino/blob/main/dinov2/eval/linear3d.py): `dinov2/eval/linear3d.py`
- [Segmentation fine-tuning](https://github.com/aiconslab/3dino/blob/main/dinov2/eval/segmentation3d.py): `dinov2/eval/segmentation3d.py`
- [Segmentation heads](https://github.com/aiconslab/3dino/blob/main/dinov2/eval/segmentation_3d/segmentation_heads.py): `dinov2/eval/segmentation_3d/segmentation_heads.py`
- [ViT adapter](https://github.com/aiconslab/3dino/blob/main/dinov2/eval/segmentation_3d/vit_adapter.py): `dinov2/eval/segmentation_3d/vit_adapter.py`
- [Segmentation augmentation](https://github.com/aiconslab/3dino/blob/main/dinov2/eval/segmentation_3d/augmentations.py): `dinov2/eval/segmentation_3d/augmentations.py`
- [Segmentation metrics](https://github.com/aiconslab/3dino/blob/main/dinov2/eval/segmentation_3d/metrics.py): `dinov2/eval/segmentation_3d/metrics.py`
- [Feature visualization](https://github.com/aiconslab/3dino/blob/main/dinov2/eval/vis_pca.py): `dinov2/eval/vis_pca.py`

### Other components

- **Researcher**
- **Medical volumes**
- **Pretrained weights**

## Connections

- Researcher → Training entry point: starts training
- Medical volumes → Dataset loaders: provides dataset
- Dataset loaders → Data samplers: uses sampler (evidence: `dinov2/data/loaders.py`)
- Training entry point → SSL training architecture: trains model (evidence: `dinov2/train/train3d.py`)
- Training entry point → Dataset loaders: sets up data (evidence: `dinov2/train/train3d.py`)
- SSL training architecture → 3D Vision Transformer: builds backbone (evidence: `dinov2/train/ssl_meta_arch.py`)
- SSL training architecture → DINO class loss: computes class loss (evidence: `dinov2/train/ssl_meta_arch.py`)
- SSL training architecture → iBOT patch loss: computes patch loss (evidence: `dinov2/train/ssl_meta_arch.py`)
- SSL training architecture → KoLeo loss: computes KoLeo loss (evidence: `dinov2/train/ssl_meta_arch.py`)
- 3D Vision Transformer → Transformer blocks: constructs blocks (evidence: `dinov2/models/vision_transformer.py`)
- 3D Vision Transformer → 3D patch embedding: embeds patches (evidence: `dinov2/models/vision_transformer.py`)
- Transformer blocks → Attention layer: uses attention (evidence: `dinov2/layers/block.py`)
- Transformer blocks → MLP layer: uses MLP (evidence: `dinov2/layers/block.py`)
- Researcher → Linear classification: runs classification
- Researcher → Segmentation fine-tuning: runs segmentation
- Pretrained weights → Linear classification: loads weights
- Pretrained weights → Segmentation fine-tuning: loads weights
- Linear classification → Evaluation setup: configures evaluation (evidence: `dinov2/eval/linear3d.py`)
- Segmentation fine-tuning → Evaluation setup: configures evaluation (evidence: `dinov2/eval/segmentation3d.py`)
- Linear classification → Dataset loaders: builds dataset (evidence: `dinov2/eval/linear3d.py`)
- Segmentation fine-tuning → Dataset loaders: builds datasets (evidence: `dinov2/eval/segmentation3d.py`)
- Segmentation fine-tuning → Segmentation heads: selects head (evidence: `dinov2/eval/segmentation3d.py`)
- Segmentation heads → ViT adapter: uses adapter (evidence: `dinov2/eval/segmentation_3d/segmentation_heads.py`)
- Segmentation fine-tuning → Segmentation augmentation: uses transforms (evidence: `dinov2/eval/segmentation3d.py`)
- Segmentation fine-tuning → Segmentation metrics: evaluates metrics (evidence: `dinov2/eval/segmentation3d.py`)
- Researcher → Feature visualization: visualizes features
