Top AI Repos — open-source AI, indexed and scored
Top AI Repos tracks AI repositories on GitHub and answers two different questions about each one: is it moving right now, and would you bet a product on it.
Top AI Repos tracks AI repositories on GitHub and answers two different questions about each one: is it moving right now, and would you bet a product on it.
A minimal yet resourceful implementation of diffusion models (along with pretrained models + synthetic images for nine datasets)
| Date | Stars |
|---|---|
| 2026-07-31 | 311 |
| 2026-08-06 | 312 |
Today
+1 stars today
This week
— stars this week
This month
— stars this month
Momentum
0.0
growth rate 0.00%/day
# Minimal implementation of diffusion models ⚛
A minimal implementation of diffusion models with the goal to democratize the use of synthetic data from these models.
Check out the [experimental results](#how-useful-is-synthetic-data-from-diffusion-models-) section for quantitative numbers on quality of synthetic data and [FAQs](#faqs) for a broader discussion. We experiments with nine commonly used datasets, and released all [assets](https://drive.google.com/drive/folders/1CfgFQSsIIfxcpVjIbEWLi2csGTeAo4O2?usp=sharing), including models and synthetic data for each of them.
**Requirements:** `pip install scipy opencv-python`. We assume torch and torchvision are already installed.
### Structure
```
main.py - Train or sample from a diffusion model.
unets.py - UNet based network architecture for diffusion model.
data.py - Common datasets and their metadata.
── scripts
└── train.sh - Training scripts for all datasets.
└── sample.sh - Sampling scripts for all datasets.
```
### Training
Use the following command to train the diffusion model on four gpus.
```
CUDA_VISIBLE_DEVICES=0,1,2,3 python -m torch.distributed.launch --nproc_per_node=4 main.py \
--arch UNet --dataset cifar10 --class-cond --epochs 500
```
We provide the exact script used for training in `./scripts/train.sh`.
### Sampling
We reuse `main.py` for sampling but with the `--sampling-only` only flag. Use the following command to sample 50K images from a pretrained diffusion model.
```
CUDA_VISIBLE_DEVICES=0,1,2,3 python -m torch.distributed.launch --nproc_per_node=4 main.py \
--arch UNet --dataset cifar10 --class-cond --sampling-only --sampling-steps 250 \
--num-sampled-images 50000 --pretrained-ckpt path_to_pretrained_model
```
We provide the exact script used for sampling in `./scripts/sample.sh`.
## How useful is synthetic data from diffusion models? 🤔
>**Takeaway:** Across all datasets, training only on synthetic data suffice to achieve a competitive classification score on real data.
**Goal:** Our goal is to not only measure photo-realism of synthetic images but also measure how well synthetic images cover the data distribution, i.e., how diverse is synthetic data. Note that a generative model, commonly GANs, can generate high-quality images, but still fail to generate diverse images.
**Choice of datasets:** We use nine commonly used datasets in image recognition. The goal was to multiple datasets was to capture enough diversity in terms of the number of samples, the number of classes, and coarse vs fine-grained classification. In addition, by using a common setup across datasets, we can test the success of diffusion models without any assumptions about the dataset.
**Diffusion model:** For each dataset, we train a class-conditional diffusion model. We choose a modest size network and train it for a limited number of hours on a 4xA4000 cluster, as highlighted by the training time in the table below. Next, we sample 50,000 synthetic images from the diffusion model.
**Metric to measure synthetic data quality:** We train a ResNet50 classifier on only *real* images and another one on only *synthetic* images and measure their accuracy on the validation set of *real* images. This metric is also referred to as [classification accuracy score](https://arxiv.org/abs/1905.10887) and it provides us a way to measure both quality and diversity of synthetic data in a unified manner across datasets.
>**Released assets for each dataset**: [Pre-trained Diffusion models](https://drive.google.com/drive/folders/1BMTpNF-FSsGrWGZomcM4OS36CootbLRj?usp=sharing), [50,000 synthetic images](https://drive.google.com/drive/folders/1KRWie7honV_mwPlmTgH8vrU0izQXm4UT?usp=sharing) for each dataset, and [downstream clasifiers](https://drive.google.com/drive/folders/1nnHSskOWzDj-JUcSODxmZiuOSFRmV25u?usp=sharing) trained with real-only or synthetic-only dataset.
*Table 1*: Training images and classes refer to the number of training images and the number of Excerpt of 12,248 characters
Read on GitHubWould you bet a product on this? Bounded 0–100 and slow moving.
matched fp:8301b3270f16688a, desc:datasets