# vuongnguyen16/minidiffusion architecture

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

- Interactive diagram: https://gitdiagram.com/vuongnguyen16/minidiffusion
- Repository: https://github.com/vuongnguyen16/minidiffusion

## Overview

MiniDiffusion is an unconditional CIFAR-10 DDPM training and image-generation baseline, with EMA sampling and FID/Inception Score evaluation. The main workflow is configured training on CIFAR-10, checkpointing the model and EMA weights, then loading the EMA weights to sample images or evaluate generated images against reference statistics. The graph also preserves the UNet, diffusion, and scoring layers. Some links reflect README-documented behavior because the relevant parts of main.py were not excerpted.

Main entry points: [`main.py`](https://github.com/vuongnguyen16/minidiffusion/blob/main/main.py) (Mode orchestration), [`score/both.py`](https://github.com/vuongnguyen16/minidiffusion/blob/main/score/both.py) (Joint FID and IS), [`score/inception.py`](https://github.com/vuongnguyen16/minidiffusion/blob/main/score/inception.py) (Inception network), [`diffusion.py`](https://github.com/vuongnguyen16/minidiffusion/blob/main/diffusion.py) (Diffusion trainer)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_workflow["Experiment workflow"]
  node_main["Mode orchestration<br/>[main.py]"]
  node_config["CIFAR-10 config<br/>[CIFAR10.txt]"]
  node_dataset[("CIFAR-10 dataset")]
  node_checkpoint["Model checkpoint<br/>[main.py]"]
end

subgraph group_generation["Diffusion generation"]
  node_unet["UNet<br/>[model.py]"]
  node_trainer["Diffusion trainer<br/>[diffusion.py]"]
  node_sampler["DDPM sampler<br/>[diffusion.py]"]
end

subgraph group_evaluation["Image evaluation"]
  node_score_both["Joint FID and IS<br/>[both.py]"]
  node_fid["FID calculation<br/>[fid.py]"]
  node_inception["Inception network<br/>[inception.py]"]
  node_is_only["Inception Score<br/>[inception_score.py]"]
  node_stats[("Reference statistics")]
  node_weights["Pretrained weights"]
end

node_user(("Experimenter"))

node_user -->|"selects mode"| node_main
node_config -->|"configures"| node_main
node_main -->|"loads training data"| node_dataset
node_main -->|"trains with"| node_trainer
node_trainer -->|"predicts noise"| node_unet
node_main -->|"saves weights"| node_checkpoint
node_main -->|"generates samples"| node_sampler
node_sampler -->|"denoises with"| node_unet
node_checkpoint -->|"loads EMA weights"| node_main
node_main -->|"evaluates images"| node_score_both
node_score_both -->|"extracts features"| node_inception
node_score_both -->|"calculates FID"| node_fid
node_fid -->|"extracts features"| node_inception
node_score_both -->|"reads reference stats"| node_stats
node_main -->|"checks before evaluation"| node_stats
node_main -.->|"can compute IS"| node_is_only
node_is_only -->|"extracts predictions"| node_inception
node_inception -.->|"downloads pretrained weights"| node_weights

click node_main "https://github.com/vuongnguyen16/minidiffusion/blob/main/main.py"
click node_config "https://github.com/vuongnguyen16/minidiffusion/blob/main/config/CIFAR10.txt"
click node_checkpoint "https://github.com/vuongnguyen16/minidiffusion/blob/main/main.py"
click node_unet "https://github.com/vuongnguyen16/minidiffusion/blob/main/model.py"
click node_trainer "https://github.com/vuongnguyen16/minidiffusion/blob/main/diffusion.py"
click node_sampler "https://github.com/vuongnguyen16/minidiffusion/blob/main/diffusion.py"
click node_score_both "https://github.com/vuongnguyen16/minidiffusion/blob/main/score/both.py"
click node_fid "https://github.com/vuongnguyen16/minidiffusion/blob/main/score/fid.py"
click node_inception "https://github.com/vuongnguyen16/minidiffusion/blob/main/score/inception.py"
click node_is_only "https://github.com/vuongnguyen16/minidiffusion/blob/main/score/inception_score.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_main,node_config,node_dataset,node_checkpoint toneBlue
class node_unet,node_trainer,node_sampler toneAmber
class node_score_both,node_fid,node_inception,node_is_only,node_stats,node_weights toneMint
class node_user toneIndigo
```

## Components

### Experiment workflow

- [Mode orchestration](https://github.com/vuongnguyen16/minidiffusion/blob/main/main.py): `main.py`
- [CIFAR-10 config](https://github.com/vuongnguyen16/minidiffusion/blob/main/config/CIFAR10.txt): `config/CIFAR10.txt`
- **CIFAR-10 dataset**
- [Model checkpoint](https://github.com/vuongnguyen16/minidiffusion/blob/main/main.py): `main.py`

### Diffusion generation

- [UNet](https://github.com/vuongnguyen16/minidiffusion/blob/main/model.py): `model.py`
- [Diffusion trainer](https://github.com/vuongnguyen16/minidiffusion/blob/main/diffusion.py): `diffusion.py`
- [DDPM sampler](https://github.com/vuongnguyen16/minidiffusion/blob/main/diffusion.py): `diffusion.py`

### Image evaluation

- [Joint FID and IS](https://github.com/vuongnguyen16/minidiffusion/blob/main/score/both.py): `score/both.py`
- [FID calculation](https://github.com/vuongnguyen16/minidiffusion/blob/main/score/fid.py): `score/fid.py`
- [Inception network](https://github.com/vuongnguyen16/minidiffusion/blob/main/score/inception.py): `score/inception.py`
- [Inception Score](https://github.com/vuongnguyen16/minidiffusion/blob/main/score/inception_score.py): `score/inception_score.py`
- **Reference statistics**
- **Pretrained weights**

### Other components

- **Experimenter**

## Connections

- Experimenter → Mode orchestration: selects mode (evidence: `Readme.md`)
- CIFAR-10 config → Mode orchestration: configures (evidence: `Readme.md`)
- Mode orchestration → CIFAR-10 dataset: loads training data (evidence: `main.py`)
- Mode orchestration → Diffusion trainer: trains with (evidence: `main.py`)
- Diffusion trainer → UNet: predicts noise (evidence: `diffusion.py`)
- Mode orchestration → Model checkpoint: saves weights (evidence: `Readme.md`)
- Mode orchestration → DDPM sampler: generates samples (evidence: `main.py`)
- DDPM sampler → UNet: denoises with (evidence: `diffusion.py`)
- Model checkpoint → Mode orchestration: loads EMA weights (evidence: `main.py`)
- Mode orchestration → Joint FID and IS: evaluates images (evidence: `main.py`)
- Joint FID and IS → Inception network: extracts features (evidence: `score/both.py`)
- Joint FID and IS → FID calculation: calculates FID (evidence: `score/both.py`)
- FID calculation → Inception network: extracts features (evidence: `score/fid.py`)
- Joint FID and IS → Reference statistics: reads reference stats (evidence: `score/both.py`)
- Mode orchestration → Reference statistics: checks before evaluation (evidence: `Readme.md`)
- Mode orchestration → Inception Score: can compute IS
- Inception Score → Inception network: extracts predictions (evidence: `score/inception_score.py`)
- Inception network → Pretrained weights: downloads pretrained weights (evidence: `Readme.md`)
