swookey-thinky/mindiffusion

Repository of lessons exploring image diffusion models, focused on understanding and education.

Python

64

228 commits

updated Jan 9, 2025

See the code

README

Zero-to-Hero - Diffusion Models

Zero to Hero

python pytorch

Repository of lessons exploring image diffusion models, focused on understanding and education.

Introduction

This series is heavily inspired by Andrej Karpathy's Zero to Hero series of videos. Well, actually, we are straight out copying that series, because they are so good. Seriously, if you haven't followed his videos, go do that now - lot's of great stuff in there!

Each lesson contains both an explanatory video which walks you through the lesson and the code, a colab notebook that corresponds to the video material, and a a pointer to the runnable code in github. All of the code is designed to run on a minimal GPU. We test everything on T4 instances, since that is what colab provides at the free tier, and they are cheap to run on AWS as stand alone instances. Theoretically each of the lessons should be runnable on any 8GB or greater GPU, as they are all designed to be trained in real time on minimal hardware, so that we can really dive into the code.

Each lesson is in its own subdirectory, and we have ordered the lessons in historical order (from oldest to latest) so that its easy to trace the development of the research and see the historical progress of this space.

Since every lesson is meant to be trained in real time with minimal cost, most of the lessons are restricted to training on the MNIST dataset, simply because it is quick to train and easy to visualize.

For even more diffusion models, including Audio and Video diffusion models, check out the xdiffusion respository, which is a unified modeling framework for image, audio, and video diffusion modeling.

Requirements for All Lessons

All lessons are built using PyTorch and written in Python 3. To setup an environment to run all of the lessons, we suggest using conda or venv:

> python3 -m venv mindiffusion_env
> source mindiffusion_env/bin/activate
> pip install --upgrade pip
> pip install -r requirements.txt

All lessons are designed to be run in the lesson directory, not the root of the repository.

Table of Lessons

LessonDateNameTitleVideoColabCode
1Introduction to Diffusion Modelscolab
2March 2015DPMDeep Unsupervised Learning using Nonequilibrium Thermodynamicscolabcode
3July 2019NCSNGenerative Modeling by Estimating Gradients of the Data Distributioncolabcode
4June 2020NCSNv2Improved Techniques for Training Score-Based Generative Modelscolabcode
5June 2020DDPMDenoising Diffusion Probabilistic Modelscode
5aDDPM with Dropoutcode
5bInterpolation in Latent Spacecode
5cAdding Control - Basic Class Conditioning with Cross-Attentioncode
5dAdding Control - Extended Class Conditioningcode
5eAdding Control - Text-to-Imagecode
6October 2020DDIMDenoising Diffusion Implicit Modelscode
7November 2020Score SDEScore-Based Generative Modeling through Stochastic Differential Equationscode
8February 2021DaLL-EZero-Shot Text-to-Image Generationcode
9February 2021IDDPMImproved Denoising Diffusion Probabilistic Modelscode
10April 2021SR3Image Super-Resolution via Iterative Refinementcode
11May 2021Guided Diffusion (ADM)Diffusion Models Beat GANs on Image Synthesiscode
12May 2021CDMCascaded Diffusion Models for High Fidelity Image Generationcode
13July 2021VDMVariational Diffusion Modelscode
14December 2021Latent DiffusionHigh-Resolution Image Synthesis with Latent Diffusion Modelscode
14aStable Diffusion v1
14bStable Diffusion v2
15December 2021CFGClassifier-Free Diffusion Guidancecode
16December 2021GLIDEGLIDE: Towards Photorealistic Image Generation and Editing with Text-Guided Diffusion Modelscode
17February 2022Progressive Distillation for Fast Sampling of Diffusion Modelscode
18April 2022DaLL-E 2Hierarchical Text-Conditional Image Generation with CLIP Latentscode
19May 2022ImagenPhotorealistic Text-to-Image Diffusion Models with Deep Language Understandingcode
20June 2022EDMElucidating the Design Space of Diffusion-Based Generative Modelscode
21September 2022Flow Straight and Fast: Learning to Generate and Transfer Data with Rectified Flowcode
22October 2022ERNIE-ViLG 2.0ERNIE-ViLG 2.0: Improving Text-to-Image Diffusion Model with Knowledge-Enhanced Mixture-of-Denoising-Experts
23December 2022DiTScalable Diffusion Models with Transformerscode
24January 2023Simple DiffusionSimple diffusion: End-to-end diffusion for high resolution images
25February 2023ControlNetAdding Conditional Control to Text-to-Image Diffusion Models
26March 2023Consistency ModelsConsistency Modelscode
27May 2023RAPHAELRAPHAEL: Text-to-Image Generation via Large Mixture of Diffusion Paths
28June 2023WuerstchenWuerstchen: An Efficient Architecture for Large-Scale Text-to-Image Diffusion Models
29July 2023SDXLSDXL: Improving Latent Diffusion Models for High-Resolution Image Synthesis
30September 2023PixArt-αPixArt-α: Fast Training of Diffusion Transformer for Photorealistic Text-to-Image Synthesiscode
31October 2023DaLL-E 3Improving Image Generation with Better Captions
32January 2024PIXART-δPIXART-δ: Fast and Controllable Image Generation with Latent Consistency Models
33March 2024Stable Diffusion 3Scaling Rectified Flow Transformers for High-Resolution Image Synthesiscode
34March 2024PixArt-ΣPixArt-Σ: Weak-to-Strong Training of Diffusion Transformer for 4K Text-to-Image Generation
35July 2024AuraFlowIntroducing AuraFlow v0.1, an Open Exploration of Large Rectified Flow Modelscode
36August 2024FluxFlux Announcementcode
37October 2024SanaSANA: Efficient High-Resolution Image Synthesis with Linear Diffusion Transformerscode
38October 2024Stable Diffusion 3.5Introducing Stable Diffusion 3.5code

Lessons to Add

  • Emu (abstract)
  • CogView (abstract)
  • CogView 2 (abstract)
  • CogView 3 (abstract)
  • Consistency Models (abstract)
  • Latent Consistency Models (abstract)
  • Scalable Diffusion Models with State Space Backbone (abstract)
  • Palette: Image-to-Image Diffusion Models (abstract)
  • MultiDiffusion: Fusing Diffusion Paths for Controlled Image Generation (abstract)
  • Matryoshka Diffusion Models (abstract)
  • On the Importance of Noise Scheduling for Diffusion Models (abstract)
  • Analyzing and Improving the Training Dynamics of Diffusion Models (abstract)
  • Elucidating the Design Space of Diffusion-Based Generative Models (abstract)
  • Flow Matching for Generative Modeling (abstract)
  • U-ViT: All are Worth Words: A ViT Backbone for Diffusion Models (abstract)
  • MDTv2: Masked Diffusion Transformer is a Strong Image Synthesizer (abstract)
  • DiffiT: Diffusion Vision Transformers for Image Generation (abstract)
  • Scaling Vision Transformers to 22 Billion Parameters (abstract)
  • DiG: Scalable and Efficient Diffusion Models with Gated Linear Attention (abstract)
  • DiM: Diffusion Mamba for Efficient High-Resolution Image Synthesis (abstract)
  • IP-Adapter: Text Compatible Image Prompt Adapter for Text-to-Image Diffusion Models (abstract)
  • JeDi: Joint-Image Diffusion Models for Finetuning-Free Personalized Text-to-Image Generation (abstract)
  • Adversarial Diffusion Distillation (abstract)
  • Discrete Predictor-Corrector Diffusion Models for Image Synthesis (abstract)
  • One-step Diffusion with Distribution Matching Distillation (abstract)
  • Salient Object-Aware Background Generation using Text-Guided Diffusion Models (abstract)
  • Versatile Diffusion (abstract)
  • D3PM: Structured Denoising Diffusion Models in Discrete State-Spaces (abstract)

Resources

Most of the implementations have been consolidated into a single image and video diffusion repository, which is configurable through YAML files.

If you are interested Video Diffusion Models, take a look through video diffusion models where we are adding all of the latest video diffusion model paper implementations, on an equivalent MNIST dataset for video.

diffusion
diffusion-models
latent-diffusion
pytorch

Contributors

swookey-thinky/mindiffusion

Repository of lessons exploring image diffusion models, focused on understanding and education.

Python

64

228 commits

updated Jan 9, 2025

See the code

README

Zero-to-Hero - Diffusion Models

Zero to Hero

python pytorch

Repository of lessons exploring image diffusion models, focused on understanding and education.

Introduction

This series is heavily inspired by Andrej Karpathy's Zero to Hero series of videos. Well, actually, we are straight out copying that series, because they are so good. Seriously, if you haven't followed his videos, go do that now - lot's of great stuff in there!

Each lesson contains both an explanatory video which walks you through the lesson and the code, a colab notebook that corresponds to the video material, and a a pointer to the runnable code in github. All of the code is designed to run on a minimal GPU. We test everything on T4 instances, since that is what colab provides at the free tier, and they are cheap to run on AWS as stand alone instances. Theoretically each of the lessons should be runnable on any 8GB or greater GPU, as they are all designed to be trained in real time on minimal hardware, so that we can really dive into the code.

Each lesson is in its own subdirectory, and we have ordered the lessons in historical order (from oldest to latest) so that its easy to trace the development of the research and see the historical progress of this space.

Since every lesson is meant to be trained in real time with minimal cost, most of the lessons are restricted to training on the MNIST dataset, simply because it is quick to train and easy to visualize.

For even more diffusion models, including Audio and Video diffusion models, check out the xdiffusion respository, which is a unified modeling framework for image, audio, and video diffusion modeling.

Requirements for All Lessons

All lessons are built using PyTorch and written in Python 3. To setup an environment to run all of the lessons, we suggest using conda or venv:

> python3 -m venv mindiffusion_env
> source mindiffusion_env/bin/activate
> pip install --upgrade pip
> pip install -r requirements.txt

All lessons are designed to be run in the lesson directory, not the root of the repository.

Table of Lessons

LessonDateNameTitleVideoColabCode
1Introduction to Diffusion Modelscolab
2March 2015DPMDeep Unsupervised Learning using Nonequilibrium Thermodynamicscolabcode
3July 2019NCSNGenerative Modeling by Estimating Gradients of the Data Distributioncolabcode
4June 2020NCSNv2Improved Techniques for Training Score-Based Generative Modelscolabcode
5June 2020DDPMDenoising Diffusion Probabilistic Modelscode
5aDDPM with Dropoutcode
5bInterpolation in Latent Spacecode
5cAdding Control - Basic Class Conditioning with Cross-Attentioncode
5dAdding Control - Extended Class Conditioningcode
5eAdding Control - Text-to-Imagecode
6October 2020DDIMDenoising Diffusion Implicit Modelscode
7November 2020Score SDEScore-Based Generative Modeling through Stochastic Differential Equationscode
8February 2021DaLL-EZero-Shot Text-to-Image Generationcode
9February 2021IDDPMImproved Denoising Diffusion Probabilistic Modelscode
10April 2021SR3Image Super-Resolution via Iterative Refinementcode
11May 2021Guided Diffusion (ADM)Diffusion Models Beat GANs on Image Synthesiscode
12May 2021CDMCascaded Diffusion Models for High Fidelity Image Generationcode
13July 2021VDMVariational Diffusion Modelscode
14December 2021Latent DiffusionHigh-Resolution Image Synthesis with Latent Diffusion Modelscode
14aStable Diffusion v1
14bStable Diffusion v2
15December 2021CFGClassifier-Free Diffusion Guidancecode
16December 2021GLIDEGLIDE: Towards Photorealistic Image Generation and Editing with Text-Guided Diffusion Modelscode
17February 2022Progressive Distillation for Fast Sampling of Diffusion Modelscode
18April 2022DaLL-E 2Hierarchical Text-Conditional Image Generation with CLIP Latentscode
19May 2022ImagenPhotorealistic Text-to-Image Diffusion Models with Deep Language Understandingcode
20June 2022EDMElucidating the Design Space of Diffusion-Based Generative Modelscode
21September 2022Flow Straight and Fast: Learning to Generate and Transfer Data with Rectified Flowcode
22October 2022ERNIE-ViLG 2.0ERNIE-ViLG 2.0: Improving Text-to-Image Diffusion Model with Knowledge-Enhanced Mixture-of-Denoising-Experts
23December 2022DiTScalable Diffusion Models with Transformerscode
24January 2023Simple DiffusionSimple diffusion: End-to-end diffusion for high resolution images
25February 2023ControlNetAdding Conditional Control to Text-to-Image Diffusion Models
26March 2023Consistency ModelsConsistency Modelscode
27May 2023RAPHAELRAPHAEL: Text-to-Image Generation via Large Mixture of Diffusion Paths
28June 2023WuerstchenWuerstchen: An Efficient Architecture for Large-Scale Text-to-Image Diffusion Models
29July 2023SDXLSDXL: Improving Latent Diffusion Models for High-Resolution Image Synthesis
30September 2023PixArt-αPixArt-α: Fast Training of Diffusion Transformer for Photorealistic Text-to-Image Synthesiscode
31October 2023DaLL-E 3Improving Image Generation with Better Captions
32January 2024PIXART-δPIXART-δ: Fast and Controllable Image Generation with Latent Consistency Models
33March 2024Stable Diffusion 3Scaling Rectified Flow Transformers for High-Resolution Image Synthesiscode
34March 2024PixArt-ΣPixArt-Σ: Weak-to-Strong Training of Diffusion Transformer for 4K Text-to-Image Generation
35July 2024AuraFlowIntroducing AuraFlow v0.1, an Open Exploration of Large Rectified Flow Modelscode
36August 2024FluxFlux Announcementcode
37October 2024SanaSANA: Efficient High-Resolution Image Synthesis with Linear Diffusion Transformerscode
38October 2024Stable Diffusion 3.5Introducing Stable Diffusion 3.5code

Lessons to Add

  • Emu (abstract)
  • CogView (abstract)
  • CogView 2 (abstract)
  • CogView 3 (abstract)
  • Consistency Models (abstract)
  • Latent Consistency Models (abstract)
  • Scalable Diffusion Models with State Space Backbone (abstract)
  • Palette: Image-to-Image Diffusion Models (abstract)
  • MultiDiffusion: Fusing Diffusion Paths for Controlled Image Generation (abstract)
  • Matryoshka Diffusion Models (abstract)
  • On the Importance of Noise Scheduling for Diffusion Models (abstract)
  • Analyzing and Improving the Training Dynamics of Diffusion Models (abstract)
  • Elucidating the Design Space of Diffusion-Based Generative Models (abstract)
  • Flow Matching for Generative Modeling (abstract)
  • U-ViT: All are Worth Words: A ViT Backbone for Diffusion Models (abstract)
  • MDTv2: Masked Diffusion Transformer is a Strong Image Synthesizer (abstract)
  • DiffiT: Diffusion Vision Transformers for Image Generation (abstract)
  • Scaling Vision Transformers to 22 Billion Parameters (abstract)
  • DiG: Scalable and Efficient Diffusion Models with Gated Linear Attention (abstract)
  • DiM: Diffusion Mamba for Efficient High-Resolution Image Synthesis (abstract)
  • IP-Adapter: Text Compatible Image Prompt Adapter for Text-to-Image Diffusion Models (abstract)
  • JeDi: Joint-Image Diffusion Models for Finetuning-Free Personalized Text-to-Image Generation (abstract)
  • Adversarial Diffusion Distillation (abstract)
  • Discrete Predictor-Corrector Diffusion Models for Image Synthesis (abstract)
  • One-step Diffusion with Distribution Matching Distillation (abstract)
  • Salient Object-Aware Background Generation using Text-Guided Diffusion Models (abstract)
  • Versatile Diffusion (abstract)
  • D3PM: Structured Denoising Diffusion Models in Discrete State-Spaces (abstract)

Resources

Most of the implementations have been consolidated into a single image and video diffusion repository, which is configurable through YAML files.

If you are interested Video Diffusion Models, take a look through video diffusion models where we are adding all of the latest video diffusion model paper implementations, on an equivalent MNIST dataset for video.

diffusion
diffusion-models
latent-diffusion
pytorch

Contributors

Languages

Python

99.8%