uoft-cs/cifar10
Viewer • Updated • 60k • 480k • 116
A small denoising diffusion probabilistic model (DDPM, Ho et al. 2020) trained on CIFAR-10, written from scratch in ~250 lines of plain PyTorch.
Try it in your browser — the ONNX export runs client-side on WebGPU, generating an image in ~2 seconds on your own GPU.
Uncurated 8×8 grid after 300 epochs.
| File | Description |
|---|---|
checkpoint.pt |
Full PyTorch checkpoint: raw weights, EMA weights, optimizer state (resumable) |
unet.onnx |
EMA weights exported to ONNX (fp32), verified to 4e-6 against PyTorch |
train_diffusion.py |
Complete training script |
sample.py |
Generate image grids from the checkpoint |
export_onnx.py |
Reproduce the ONNX export |
pip install torch torchvision
python sample.py --n 64 --seed 42 # sample a grid from checkpoint.pt
python train_diffusion.py --base 128 --epochs 300 --out out_big --sample-every 10 --ema-decay 0.9995 # retrain
Source and local web app: github.com/dannysheesh/cifar10-ddpm