# curlytheses/pwhfl architecture

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

- Interactive diagram: https://gitdiagram.com/curlytheses/pwhfl
- Repository: https://github.com/curlytheses/pwhfl

## Overview

PWHFL is a research pipeline for robust image classification with heterogeneous federated clients. The main workflow prepares private/public/test data, pretrains participant models, then runs public-data collaboration and local updates; baseline and ablation routines provide comparison paths. The graph preserves the README’s documented capabilities, including corruption handling, AugMix/JSD, contrastive learning, and performance-weighted transfer. Source excerpts are partial, so links between implementation modules are included only where documented; the README supports the broader workflow links.

Main entry points: [`Network/pretrain.py`](https://github.com/curlytheses/pwhfl/blob/main/Network/pretrain.py) (Client pretraining), [`HHF/pwhfl.py`](https://github.com/curlytheses/pwhfl/blob/main/HHF/pwhfl.py) (PWHFL collaboration), [`Dataset/init_dataset.py`](https://github.com/curlytheses/pwhfl/blob/main/Dataset/init_dataset.py) (FL datasets), [`Dataset/make_cifar_c.py`](https://github.com/curlytheses/pwhfl/blob/main/Dataset/make_cifar_c.py) (Corruption generation)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_data["Data preparation"]
  node_cifar_wrappers["CIFAR wrappers<br/>[cifar.py]"]
  node_dataset_init["FL datasets<br/>[init_dataset.py]"]
  node_sampling["Data partitioning<br/>[sampling.py]"]
  node_dataset_utils["Dataset utilities<br/>[utils.py]"]
  node_corruption_gen["Corruption generation<br/>[make_cifar_c.py]"]
  node_augmentations["Image augmentations<br/>[augmentations.py]"]
  node_dataaug["Data augmentation<br/>[dataaug.py]"]
end

subgraph group_models["Client models"]
  node_resnet["ResNet models<br/>[resnet.py]"]
  node_shufflenet["ShuffleNet model<br/>[shufflenet.py]"]
  node_mobilenet["MobileNetV2 model<br/>[mobilnet_v2.py]"]
end

subgraph group_training["Federated training"]
  node_pretrain["Client pretraining<br/>[pretrain.py]"]
  node_checkpoints["Model checkpoints"]
  node_pwhfl["PWHFL collaboration<br/>[pwhfl.py]"]
  node_contrastive_loss["Contrastive losses<br/>[loss.py]"]
end

subgraph group_evaluation["Comparison studies"]
  node_rahfl["RAHFL baseline<br/>[rahfl.py]"]
  node_ablation["Ablation studies<br/>[ablation.py]"]
end

node_dataset_sources[("CIFAR data")]
node_experimenter(("Experimenter"))

node_dataset_sources -->|"loads CIFAR"| node_cifar_wrappers
node_dataset_sources -->|"provides datasets"| node_dataset_init
node_dataset_sources -->|"generates corruptions"| node_corruption_gen
node_experimenter -->|"starts pretraining"| node_pretrain
node_pretrain -->|"stores checkpoints"| node_checkpoints
node_pretrain -->|"trains client models"| node_resnet
node_pretrain -->|"trains client models"| node_shufflenet
node_pretrain -->|"trains client models"| node_mobilenet
node_experimenter -->|"starts collaboration"| node_pwhfl
node_pwhfl -->|"loads pretrained"| node_checkpoints
node_pwhfl -->|"uses public data"| node_dataset_sources
node_pwhfl -->|"uses contrastive objectives"| node_contrastive_loss
node_experimenter -->|"runs baseline"| node_rahfl
node_experimenter -->|"runs ablations"| node_ablation
node_experimenter -->|"prepares corruptions"| node_corruption_gen
node_experimenter -->|"configures robustness training"| node_augmentations
node_experimenter -.->|"configures robustness training"| node_dataaug
node_dataset_init -.->|"partitions clients"| node_sampling
node_dataset_init -.->|"uses loader utilities"| node_dataset_utils

click node_cifar_wrappers "https://github.com/curlytheses/pwhfl/blob/main/Dataset/cifar.py"
click node_dataset_init "https://github.com/curlytheses/pwhfl/blob/main/Dataset/init_dataset.py"
click node_sampling "https://github.com/curlytheses/pwhfl/blob/main/Dataset/sampling.py"
click node_dataset_utils "https://github.com/curlytheses/pwhfl/blob/main/Dataset/utils.py"
click node_corruption_gen "https://github.com/curlytheses/pwhfl/blob/main/Dataset/make_cifar_c.py"
click node_augmentations "https://github.com/curlytheses/pwhfl/blob/main/Dataset/augmentations.py"
click node_dataaug "https://github.com/curlytheses/pwhfl/blob/main/Dataset/dataaug.py"
click node_resnet "https://github.com/curlytheses/pwhfl/blob/main/Network/Models_Def/resnet.py"
click node_shufflenet "https://github.com/curlytheses/pwhfl/blob/main/Network/Models_Def/shufflenet.py"
click node_mobilenet "https://github.com/curlytheses/pwhfl/blob/main/Network/Models_Def/mobilnet_v2.py"
click node_pretrain "https://github.com/curlytheses/pwhfl/blob/main/Network/pretrain.py"
click node_pwhfl "https://github.com/curlytheses/pwhfl/blob/main/HHF/pwhfl.py"
click node_contrastive_loss "https://github.com/curlytheses/pwhfl/blob/main/HHF/loss.py"
click node_rahfl "https://github.com/curlytheses/pwhfl/blob/main/HHF/rahfl.py"
click node_ablation "https://github.com/curlytheses/pwhfl/blob/main/HHF/ablation.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_cifar_wrappers,node_dataset_init,node_sampling,node_dataset_utils,node_corruption_gen,node_augmentations,node_dataaug toneBlue
class node_resnet,node_shufflenet,node_mobilenet,node_dataset_sources toneAmber
class node_pretrain,node_checkpoints,node_pwhfl,node_contrastive_loss toneMint
class node_rahfl,node_ablation toneRose
class node_experimenter toneIndigo
```

## Components

### Data preparation

- [CIFAR wrappers](https://github.com/curlytheses/pwhfl/blob/main/Dataset/cifar.py): `Dataset/cifar.py`
- [FL datasets](https://github.com/curlytheses/pwhfl/blob/main/Dataset/init_dataset.py): `Dataset/init_dataset.py`
- [Data partitioning](https://github.com/curlytheses/pwhfl/blob/main/Dataset/sampling.py): `Dataset/sampling.py`
- [Dataset utilities](https://github.com/curlytheses/pwhfl/blob/main/Dataset/utils.py): `Dataset/utils.py`
- [Corruption generation](https://github.com/curlytheses/pwhfl/blob/main/Dataset/make_cifar_c.py): `Dataset/make_cifar_c.py`
- [Image augmentations](https://github.com/curlytheses/pwhfl/blob/main/Dataset/augmentations.py): `Dataset/augmentations.py`
- [Data augmentation](https://github.com/curlytheses/pwhfl/blob/main/Dataset/dataaug.py): `Dataset/dataaug.py`

### Client models

- [ResNet models](https://github.com/curlytheses/pwhfl/blob/main/Network/Models_Def/resnet.py): `Network/Models_Def/resnet.py`
- [ShuffleNet model](https://github.com/curlytheses/pwhfl/blob/main/Network/Models_Def/shufflenet.py): `Network/Models_Def/shufflenet.py`
- [MobileNetV2 model](https://github.com/curlytheses/pwhfl/blob/main/Network/Models_Def/mobilnet_v2.py): `Network/Models_Def/mobilnet_v2.py`

### Federated training

- [Client pretraining](https://github.com/curlytheses/pwhfl/blob/main/Network/pretrain.py): `Network/pretrain.py`
- **Model checkpoints**
- [PWHFL collaboration](https://github.com/curlytheses/pwhfl/blob/main/HHF/pwhfl.py): `HHF/pwhfl.py`
- [Contrastive losses](https://github.com/curlytheses/pwhfl/blob/main/HHF/loss.py): `HHF/loss.py`

### Comparison studies

- [RAHFL baseline](https://github.com/curlytheses/pwhfl/blob/main/HHF/rahfl.py): `HHF/rahfl.py`
- [Ablation studies](https://github.com/curlytheses/pwhfl/blob/main/HHF/ablation.py): `HHF/ablation.py`

### Other components

- **CIFAR data**
- **Experimenter**

## Connections

- CIFAR data → CIFAR wrappers: loads CIFAR (evidence: `README.md`)
- CIFAR data → FL datasets: provides datasets (evidence: `README.md`)
- CIFAR data → Corruption generation: generates corruptions (evidence: `README.md`)
- Experimenter → Client pretraining: starts pretraining (evidence: `README.md`)
- Client pretraining → Model checkpoints: stores checkpoints (evidence: `README.md`)
- Client pretraining → ResNet models: trains client models (evidence: `README.md`)
- Client pretraining → ShuffleNet model: trains client models (evidence: `README.md`)
- Client pretraining → MobileNetV2 model: trains client models (evidence: `README.md`)
- Experimenter → PWHFL collaboration: starts collaboration (evidence: `README.md`)
- PWHFL collaboration → Model checkpoints: loads pretrained (evidence: `README.md`)
- PWHFL collaboration → CIFAR data: uses public data (evidence: `README.md`)
- PWHFL collaboration → Contrastive losses: uses contrastive objectives (evidence: `README.md`)
- Experimenter → RAHFL baseline: runs baseline (evidence: `README.md`)
- Experimenter → Ablation studies: runs ablations (evidence: `README.md`)
- Experimenter → Corruption generation: prepares corruptions (evidence: `README.md`)
- Experimenter → Image augmentations: configures robustness training (evidence: `README.md`)
- Experimenter → Data augmentation: configures robustness training
- FL datasets → Data partitioning: partitions clients
- FL datasets → Dataset utilities: uses loader utilities
