# katherlab/swarm-learning-hpe architecture

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

- Interactive diagram: https://gitdiagram.com/katherlab/swarm-learning-hpe
- Repository: https://github.com/katherlab/swarm-learning-hpe

## Overview

This repository is a collection of medical-imaging machine-learning projects intended for experiments in HPE Swarm Learning, rather than one unified application. The main workflows train or apply models to histopathology, MRI/radiology, and image-generation tasks; the README describes sharing learned model parameters between peers while keeping raw data local. The graph preserves these distinct project branches and their documented capabilities. Several ODELIA and diffusion connections are based on SOURCE INDEX references or README descriptions; unsampled implementation details and cross-project runtime wiring are not inferred.

Main entry points: [`workspace/swag-latent-diffusion/model/2d_ldm.py`](https://github.com/katherlab/swarm-learning-hpe/blob/main/workspace/swag-latent-diffusion/model/2d_ldm.py) (Latent Diffusion), [`workspace/marugoto_mri/model/main.py`](https://github.com/katherlab/swarm-learning-hpe/blob/main/workspace/marugoto_mri/model/main.py) (MRI MIL Workflow), [`workspace/odelia-breast-mri/model/main.py`](https://github.com/katherlab/swarm-learning-hpe/blob/main/workspace/odelia-breast-mri/model/main.py) (ODELIA Training), [`workspace/score-based-model/model/runners/ncsn_runner_cond.py`](https://github.com/katherlab/swarm-learning-hpe/blob/main/workspace/score-based-model/model/runners/ncsn_runner_cond.py) (Conditional Training)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_histology["Histopathology ML"]
  node_slide_data["Slide Features<br/>[data_utils.py]"]
  node_slide_training["Slide Training<br/>[train_function.py]"]
  node_clam["CLAM Attention<br/>[model_clam.py]"]
  node_gpu_entry["GPU Experiment<br/>[main.py]"]
  node_legacy_pipeline["Legacy Pipeline<br/>[main.py]"]
end

subgraph group_mri["MRI Classification"]
  node_mri_entry["MRI MIL Workflow<br/>[main.py]"]
  node_mri_data["MIL Data<br/>[data.py]"]
  node_mri_model["MIL Models<br/>[_mil.py]"]
  node_mri_helpers["MIL Training Helpers<br/>[helpers.py]"]
  node_categorical["Categorical Analysis<br/>[categorical.py]"]
  node_roc["ROC Evaluation<br/>[roc.py]"]
end

subgraph group_odelia["ODELIA MRI"]
  node_odelia_entry["ODELIA Training<br/>[main.py]"]
  node_odelia_config["Model Configuration<br/>[env_config.py]"]
  node_odelia_models["3D Model Selection<br/>[model_selector.py]"]
  node_odelia_data["MRI Data Pipeline<br/>[datamodule.py]"]
  node_odelia_predict["MRI Prediction<br/>[predict.py]"]
end

subgraph group_score["Score Generation"]
  node_score_entry["Score Model Runner<br/>[main.py]"]
  node_score_training["Conditional Training"]
  node_score_network["NCSN Network<br/>[ncsnv3.py]"]
  node_score_data["Image Datasets<br/>[__init__.py]"]
  node_score_loss["Denoising Loss<br/>[dsm.py]"]
end

subgraph group_swag["Latent Diffusion"]
  node_latent_entry["Latent Diffusion<br/>[2d_ldm.py]"]
  node_latent_data["Medical Image Datasets<br/>[fastmri_brain.py]"]
  node_latent_infer["Diffusion Inference<br/>[inferer.py]"]
  node_latent_losses["Perceptual Loss<br/>[perceptual.py]"]
  node_latent_adversarial["Adversarial Loss"]
  node_latent_unet["Diffusion U-Net"]
end

node_researcher(("Researcher"))

node_researcher -->|"configures experiment"| node_gpu_entry
node_gpu_entry -->|"uses features"| node_slide_data
node_gpu_entry -->|"uses training"| node_slide_training
node_researcher -.->|"starts experiment"| node_legacy_pipeline
node_legacy_pipeline -->|"loads data"| node_slide_data
node_researcher -->|"starts workflow"| node_mri_entry
node_mri_entry -->|"runs training"| node_mri_helpers
node_mri_entry -->|"aggregates predictions"| node_categorical
node_mri_entry -->|"plots ROC"| node_roc
node_mri_helpers -->|"uses data"| node_mri_data
node_mri_helpers -->|"uses MIL"| node_mri_model
node_mri_model -->|"builds datasets"| node_mri_data
node_researcher -->|"starts training"| node_odelia_entry
node_odelia_entry -->|"uses datamodule"| node_odelia_data
node_odelia_entry -->|"uses configuration"| node_odelia_config
node_odelia_config -->|"references prediction"| node_odelia_predict
node_odelia_config -->|"references datasets"| node_odelia_data
node_odelia_entry -->|"selects model"| node_odelia_models
node_researcher -->|"configures run"| node_score_entry
node_score_entry -->|"dispatches runner"| node_score_training
node_score_training -->|"trains network"| node_score_network
node_score_training -->|"loads datasets"| node_score_data
node_score_training -->|"computes loss"| node_score_loss
node_researcher -.->|"configures training"| node_latent_entry
node_latent_entry -->|"loads dataset"| node_latent_data
node_latent_entry -->|"uses inferer"| node_latent_infer
node_latent_entry -->|"uses loss"| node_latent_losses
node_latent_entry -->|"uses loss"| node_latent_adversarial
node_latent_entry -->|"uses network"| node_latent_unet

click node_slide_data "https://github.com/katherlab/swarm-learning-hpe/blob/main/workspace/katherlab-gpu/model/data_utils.py"
click node_slide_training "https://github.com/katherlab/swarm-learning-hpe/blob/main/workspace/katherlab-gpu/model/train_function.py"
click node_clam "https://github.com/katherlab/swarm-learning-hpe/blob/main/workspace/katherlab-gpu/model/models/model_clam.py"
click node_gpu_entry "https://github.com/katherlab/swarm-learning-hpe/blob/main/workspace/katherlab-gpu/model/main.py"
click node_legacy_pipeline "https://github.com/katherlab/swarm-learning-hpe/blob/main/workspace/katherlab-gpu/model_old/main.py"
click node_mri_entry "https://github.com/katherlab/swarm-learning-hpe/blob/main/workspace/marugoto_mri/model/main.py"
click node_mri_data "https://github.com/katherlab/swarm-learning-hpe/blob/main/workspace/marugoto_mri/model/mil/data.py"
click node_mri_model "https://github.com/katherlab/swarm-learning-hpe/blob/main/workspace/marugoto_mri/model/mil/_mil.py"
click node_mri_helpers "https://github.com/katherlab/swarm-learning-hpe/blob/main/workspace/marugoto_mri/model/mil/helpers.py"
click node_categorical "https://github.com/katherlab/swarm-learning-hpe/blob/main/workspace/marugoto_mri/model/categorical.py"
click node_roc "https://github.com/katherlab/swarm-learning-hpe/blob/main/workspace/marugoto_mri/model/roc.py"
click node_odelia_entry "https://github.com/katherlab/swarm-learning-hpe/blob/main/workspace/odelia-breast-mri/model/main.py"
click node_odelia_config "https://github.com/katherlab/swarm-learning-hpe/blob/main/workspace/odelia-breast-mri/model/env_config.py"
click node_odelia_models "https://github.com/katherlab/swarm-learning-hpe/blob/main/workspace/odelia-breast-mri/model/model_selector.py"
click node_odelia_data "https://github.com/katherlab/swarm-learning-hpe/blob/main/workspace/odelia-breast-mri/model/data/datamodules/datamodule.py"
click node_odelia_predict "https://github.com/katherlab/swarm-learning-hpe/blob/main/workspace/odelia-breast-mri/model/predict.py"
click node_score_entry "https://github.com/katherlab/swarm-learning-hpe/blob/main/workspace/score-based-model/model/main.py"
click node_score_training "https://github.com/katherlab/swarm-learning-hpe/blob/main/workspace/score-based-model/model/runners/ncsn_runner_cond.py"
click node_score_network "https://github.com/katherlab/swarm-learning-hpe/blob/main/workspace/score-based-model/model/models/ncsnv3.py"
click node_score_data "https://github.com/katherlab/swarm-learning-hpe/blob/main/workspace/score-based-model/model/datasets/__init__.py"
click node_score_loss "https://github.com/katherlab/swarm-learning-hpe/blob/main/workspace/score-based-model/model/losses/dsm.py"
click node_latent_entry "https://github.com/katherlab/swarm-learning-hpe/blob/main/workspace/swag-latent-diffusion/model/2d_ldm.py"
click node_latent_data "https://github.com/katherlab/swarm-learning-hpe/blob/main/workspace/swag-latent-diffusion/model/dataset/fastmri_brain.py"
click node_latent_infer "https://github.com/katherlab/swarm-learning-hpe/blob/main/workspace/swag-latent-diffusion/model/generative/inferers/inferer.py"
click node_latent_losses "https://github.com/katherlab/swarm-learning-hpe/blob/main/workspace/swag-latent-diffusion/model/generative/losses/perceptual.py"
click node_latent_adversarial "https://github.com/katherlab/swarm-learning-hpe/blob/main/workspace/swag-latent-diffusion/model/generative/losses/adversarial_loss.py"
click node_latent_unet "https://github.com/katherlab/swarm-learning-hpe/blob/main/workspace/swag-latent-diffusion/model/generative/networks/nets/diffusion_model_unet.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_slide_data,node_slide_training,node_clam,node_gpu_entry,node_legacy_pipeline toneBlue
class node_mri_entry,node_mri_data,node_mri_model,node_mri_helpers,node_categorical,node_roc toneAmber
class node_odelia_entry,node_odelia_config,node_odelia_models,node_odelia_data,node_odelia_predict toneMint
class node_score_entry,node_score_training,node_score_network,node_score_data,node_score_loss toneRose
class node_latent_entry,node_latent_data,node_latent_infer,node_latent_losses,node_latent_adversarial,node_latent_unet,node_researcher toneIndigo
```

## Components

### Histopathology ML

- [Slide Features](https://github.com/katherlab/swarm-learning-hpe/blob/main/workspace/katherlab-gpu/model/data_utils.py): `workspace/katherlab-gpu/model/data_utils.py`
- [Slide Training](https://github.com/katherlab/swarm-learning-hpe/blob/main/workspace/katherlab-gpu/model/train_function.py): `workspace/katherlab-gpu/model/train_function.py`
- [CLAM Attention](https://github.com/katherlab/swarm-learning-hpe/blob/main/workspace/katherlab-gpu/model/models/model_clam.py): `workspace/katherlab-gpu/model/models/model_clam.py`
- [GPU Experiment](https://github.com/katherlab/swarm-learning-hpe/blob/main/workspace/katherlab-gpu/model/main.py): `workspace/katherlab-gpu/model/main.py`
- [Legacy Pipeline](https://github.com/katherlab/swarm-learning-hpe/blob/main/workspace/katherlab-gpu/model_old/main.py): `workspace/katherlab-gpu/model_old/main.py`

### MRI Classification

- [MRI MIL Workflow](https://github.com/katherlab/swarm-learning-hpe/blob/main/workspace/marugoto_mri/model/main.py): `workspace/marugoto_mri/model/main.py`
- [MIL Data](https://github.com/katherlab/swarm-learning-hpe/blob/main/workspace/marugoto_mri/model/mil/data.py): `workspace/marugoto_mri/model/mil/data.py`
- [MIL Models](https://github.com/katherlab/swarm-learning-hpe/blob/main/workspace/marugoto_mri/model/mil/_mil.py): `workspace/marugoto_mri/model/mil/_mil.py`
- [MIL Training Helpers](https://github.com/katherlab/swarm-learning-hpe/blob/main/workspace/marugoto_mri/model/mil/helpers.py): `workspace/marugoto_mri/model/mil/helpers.py`
- [Categorical Analysis](https://github.com/katherlab/swarm-learning-hpe/blob/main/workspace/marugoto_mri/model/categorical.py): `workspace/marugoto_mri/model/categorical.py`
- [ROC Evaluation](https://github.com/katherlab/swarm-learning-hpe/blob/main/workspace/marugoto_mri/model/roc.py): `workspace/marugoto_mri/model/roc.py`

### ODELIA MRI

- [ODELIA Training](https://github.com/katherlab/swarm-learning-hpe/blob/main/workspace/odelia-breast-mri/model/main.py): `workspace/odelia-breast-mri/model/main.py`
- [Model Configuration](https://github.com/katherlab/swarm-learning-hpe/blob/main/workspace/odelia-breast-mri/model/env_config.py): `workspace/odelia-breast-mri/model/env_config.py`
- [3D Model Selection](https://github.com/katherlab/swarm-learning-hpe/blob/main/workspace/odelia-breast-mri/model/model_selector.py): `workspace/odelia-breast-mri/model/model_selector.py`
- [MRI Data Pipeline](https://github.com/katherlab/swarm-learning-hpe/blob/main/workspace/odelia-breast-mri/model/data/datamodules/datamodule.py): `workspace/odelia-breast-mri/model/data/datamodules/datamodule.py`
- [MRI Prediction](https://github.com/katherlab/swarm-learning-hpe/blob/main/workspace/odelia-breast-mri/model/predict.py): `workspace/odelia-breast-mri/model/predict.py`

### Score Generation

- [Score Model Runner](https://github.com/katherlab/swarm-learning-hpe/blob/main/workspace/score-based-model/model/main.py): `workspace/score-based-model/model/main.py`
- [Conditional Training](https://github.com/katherlab/swarm-learning-hpe/blob/main/workspace/score-based-model/model/runners/ncsn_runner_cond.py): `workspace/score-based-model/model/runners/ncsn_runner_cond.py`
- [NCSN Network](https://github.com/katherlab/swarm-learning-hpe/blob/main/workspace/score-based-model/model/models/ncsnv3.py): `workspace/score-based-model/model/models/ncsnv3.py`
- [Image Datasets](https://github.com/katherlab/swarm-learning-hpe/blob/main/workspace/score-based-model/model/datasets/__init__.py): `workspace/score-based-model/model/datasets/__init__.py`
- [Denoising Loss](https://github.com/katherlab/swarm-learning-hpe/blob/main/workspace/score-based-model/model/losses/dsm.py): `workspace/score-based-model/model/losses/dsm.py`

### Latent Diffusion

- [Latent Diffusion](https://github.com/katherlab/swarm-learning-hpe/blob/main/workspace/swag-latent-diffusion/model/2d_ldm.py): `workspace/swag-latent-diffusion/model/2d_ldm.py`
- [Medical Image Datasets](https://github.com/katherlab/swarm-learning-hpe/blob/main/workspace/swag-latent-diffusion/model/dataset/fastmri_brain.py): `workspace/swag-latent-diffusion/model/dataset/fastmri_brain.py`
- [Diffusion Inference](https://github.com/katherlab/swarm-learning-hpe/blob/main/workspace/swag-latent-diffusion/model/generative/inferers/inferer.py): `workspace/swag-latent-diffusion/model/generative/inferers/inferer.py`
- [Perceptual Loss](https://github.com/katherlab/swarm-learning-hpe/blob/main/workspace/swag-latent-diffusion/model/generative/losses/perceptual.py): `workspace/swag-latent-diffusion/model/generative/losses/perceptual.py`
- [Adversarial Loss](https://github.com/katherlab/swarm-learning-hpe/blob/main/workspace/swag-latent-diffusion/model/generative/losses/adversarial_loss.py): `workspace/swag-latent-diffusion/model/generative/losses/adversarial_loss.py`
- [Diffusion U-Net](https://github.com/katherlab/swarm-learning-hpe/blob/main/workspace/swag-latent-diffusion/model/generative/networks/nets/diffusion_model_unet.py): `workspace/swag-latent-diffusion/model/generative/networks/nets/diffusion_model_unet.py`

### Other components

- **Researcher**

## Connections

- Researcher → GPU Experiment: configures experiment (evidence: `workspace/katherlab-gpu/model/main.py`)
- GPU Experiment → Slide Features: uses features (evidence: `workspace/katherlab-gpu/model/main.py`)
- GPU Experiment → Slide Training: uses training (evidence: `workspace/katherlab-gpu/model/main.py`)
- Researcher → Legacy Pipeline: starts experiment
- Legacy Pipeline → Slide Features: loads data (evidence: `workspace/katherlab-gpu/model_old/main.py`)
- Researcher → MRI MIL Workflow: starts workflow (evidence: `workspace/marugoto_mri/model/main.py`)
- MRI MIL Workflow → MIL Training Helpers: runs training (evidence: `workspace/marugoto_mri/model/main.py`)
- MRI MIL Workflow → Categorical Analysis: aggregates predictions (evidence: `workspace/marugoto_mri/model/main.py`)
- MRI MIL Workflow → ROC Evaluation: plots ROC (evidence: `workspace/marugoto_mri/model/main.py`)
- MIL Training Helpers → MIL Data: uses data (evidence: `workspace/marugoto_mri/model/mil/helpers.py`)
- MIL Training Helpers → MIL Models: uses MIL (evidence: `workspace/marugoto_mri/model/mil/helpers.py`)
- MIL Models → MIL Data: builds datasets (evidence: `workspace/marugoto_mri/model/mil/_mil.py`)
- Researcher → ODELIA Training: starts training (evidence: `workspace/odelia-breast-mri/model/main.py`)
- ODELIA Training → MRI Data Pipeline: uses datamodule (evidence: `workspace/odelia-breast-mri/model/main.py`)
- ODELIA Training → Model Configuration: uses configuration (evidence: `workspace/odelia-breast-mri/model/main.py`)
- Model Configuration → MRI Prediction: references prediction (evidence: `workspace/odelia-breast-mri/model/env_config.py`)
- Model Configuration → MRI Data Pipeline: references datasets (evidence: `workspace/odelia-breast-mri/model/env_config.py`)
- ODELIA Training → 3D Model Selection: selects model (evidence: `workspace/odelia-breast-mri/model/main.py`)
- Researcher → Score Model Runner: configures run (evidence: `workspace/score-based-model/model/main.py`)
- Score Model Runner → Conditional Training: dispatches runner (evidence: `workspace/score-based-model/model/main.py`)
- Conditional Training → NCSN Network: trains network (evidence: `workspace/score-based-model/model/runners/ncsn_runner_cond.py`)
- Conditional Training → Image Datasets: loads datasets (evidence: `workspace/score-based-model/model/runners/ncsn_runner_cond.py`)
- Conditional Training → Denoising Loss: computes loss (evidence: `workspace/score-based-model/model/runners/ncsn_runner_cond.py`)
- Researcher → Latent Diffusion: configures training
- Latent Diffusion → Medical Image Datasets: loads dataset (evidence: `workspace/swag-latent-diffusion/model/2d_ldm.py`)
- Latent Diffusion → Diffusion Inference: uses inferer (evidence: `workspace/swag-latent-diffusion/model/2d_ldm.py`)
- Latent Diffusion → Perceptual Loss: uses loss (evidence: `workspace/swag-latent-diffusion/model/2d_ldm.py`)
- Latent Diffusion → Adversarial Loss: uses loss (evidence: `workspace/swag-latent-diffusion/model/2d_ldm.py`)
- Latent Diffusion → Diffusion U-Net: uses network (evidence: `workspace/swag-latent-diffusion/model/2d_ldm.py`)
