← Open Source
dome272

Diffusion-Models-pytorch

Pytorch implementation of Diffusion Models (https://arxiv.org/pdf/2006.11239.pdf).

TutorialsML/AI fundamentalsPython
Open on GitHub
Momentum
+0stars in 24 hours0.0%
1.46k
Stars
304
Forks
+-1
This week
1
Contributors
Created 2022-06-07 · Updated 2026-10-15 · #10254 today
Top developers

dome272/Diffusion-Models-pytorch is ranked 10,254 with 1,464 stars.

Same-category comparison

dome272/Diffusion-Models-pytorch is ranked 10,254 among these 8 peers; twostraws/SwiftAgents is ranked 10,246.

Same-category comparison
NameRankMetrics
elicit/machine-learning-list10,230
Stars:
1,473
Forks:
125
Description:
A curriculum for learning about foundation models, from scratch to the frontier.
m2dsupsdlclass/lectures-labs10,231
Language:
Jupyter Notebook
Stars:
1,473
Forks:
662
Description:
Slides and Jupyter notebooks for the Deep Learning lectures at Master Year 2 Data Science from Institut Polytechnique de Paris.
alchaincyf/obsidian-ai-orange-book10,243
Stars:
1,468
Forks:
134
twostraws/SwiftAgents10,246
Stars:
1,467
Forks:
91
Description:
An AGENTS.md file for Swift and SwiftUI projects.
ikatsov/tensor-house10,262
Language:
Jupyter Notebook
Stars:
1,462
Forks:
509
Description:
A collection of reference Jupyter notebooks and demo AI/ML applications for enterprise use cases: marketing, pricing, supply chain, smart manufacturing, and more.
Ramakm/AI-Engineering10,268
Language:
Jupyter Notebook
Stars:
1,459
Forks:
309
Description:
A group of notebooks and other files which can help you learn AI from scratch.
goodfeli/dlbook_exercises10,273
Language:
TeX
Stars:
1,458
Forks:
341
Description:
Exercises for the Deep Learning textbook at www.deeplearningbook.org.
amitkaps/hackermath10,287
Language:
Jupyter Notebook
Stars:
1,452
Forks:
279
Description:
Introduction to Statistics and Basics of Mathematics for Data Science - The Hacker's Way.
Key parameters and specifications
Key parameters and specifications
ParameterValue
LanguagePython
CategoryTutorials
SubcategoryML/AI fundamentals
KeywordsImage production
Stars1,464
Forks304
Contributors1
Created date2022-06-07
Updated date2026-10-15
Stars in 1 day0
Stars in 7 days-1
Rank10,254
Previous rank10,262
Rank change8
7-day stars rank17,141
Previous 7-day stars rank12,602
7-day stars rank change-4,539
Total stars rank8,244
Previous total stars rank8,235
Total stars rank change-9
CountryGermany
README summary

Diffusion Models This is an easy-to-understand implementation of diffusion models within 100 lines of code. Different from other implementations, this code doesn't use the lower-bound formulation for sampling and strictly follows Algorithm 1 from the DDPM paper, which makes it extremely short and easy to follow. Furthermore, the conditional code also implements Classifier-Free-Guidance (CFG) and Exponential-Moving-Average (EMA). Below you can find two explanation videos for the theory behind diffusion models and the implementation

. Train a Diffusion Model on your own data: Unconditional Training 1. (optional) Configure Hyperparameters in 2. (optional) Configure Hyperparameters in 2. Sampling The following examples show how to sample images using the models trained in the video on the Landscape Dataset. You can download the checkpoints for the models here. Unconditional Model Conditional Model This model was trained on CIFAR-10 64x64 with 10 classes A more advanced version of this code can be found here by @tcapelle. It introduces

better logging, faster & more efficient training and other nice features and is also being followed by a nice write-up.

Frequently asked questions

How many stars and forks are recorded?

dome272/Diffusion-Models-pytorch has 1,464 stars and 304 forks.

What is the repository rank?

dome272/Diffusion-Models-pytorch is ranked 10,254.

What language and category are recorded?

dome272/Diffusion-Models-pytorch has 1,464 stars, uses Python and belongs to Tutorials.

Which repository is closest in rank?

dome272/Diffusion-Models-pytorch is compared with twostraws/SwiftAgents, ranked 10,246 with 1,467 stars.

README

Diffusion Models

This is an easy-to-understand implementation of diffusion models within 100 lines of code. Different from other implementations, this code doesn't use the lower-bound formulation for sampling and strictly follows Algorithm 1 from the DDPM paper, which makes it extremely short and easy to follow. There are two implementations: conditional and unconditional. Furthermore, the conditional code also implements Classifier-Free-Guidance (CFG) and Exponential-Moving-Average (EMA). Below you can find two explanation videos for the theory behind diffusion models and the implementation.

Train a Diffusion Model on your own data:

Unconditional Training

  1. (optional) Configure Hyperparameters in ddpm.py
  2. Set path to dataset in ddpm.py
  3. python ddpm.py

Conditional Training

  1. (optional) Configure Hyperparameters in ddpm_conditional.py
  2. Set path to dataset in ddpm_conditional.py
  3. python ddpm_conditional.py

Sampling

The following examples show how to sample images using the models trained in the video on the Landscape Dataset. You can download the checkpoints for the models here.

Unconditional Model

    device = "cuda"
    model = UNet().to(device)
    ckpt = torch.load("unconditional_ckpt.pt")
    model.load_state_dict(ckpt)
    diffusion = Diffusion(img_size=64, device=device)
    x = diffusion.sample(model, n=16)
    plot_images(x)

Conditional Model

This model was trained on CIFAR-10 64x64 with 10 classes airplane:0, auto:1, bird:2, cat:3, deer:4, dog:5, frog:6, horse:7, ship:8, truck:9

    n = 10
    device = "cuda"
    model = UNet_conditional(num_classes=10).to(device)
    ckpt = torch.load("conditional_ema_ckpt.pt")
    model.load_state_dict(ckpt)
    diffusion = Diffusion(img_size=64, device=device)
    y = torch.Tensor([6] * n).long().to(device)
    x = diffusion.sample(model, n, y, cfg_scale=3)
    plot_images(x)

A more advanced version of this code can be found here by @tcapelle. It introduces better logging, faster & more efficient training and other nice features and is also being followed by a nice write-up.

Nearby in the ranking
Similar items