This repository contains some example applications in which diffusion-based image generation models are used.
Each example/subproject is independent; specific (re-)sources & Co. are explained inside each subproject folder.
ddpm/: Training a Denoising Diffusion Probabilistic Model from Scratchdiffusers/: Practical Image Generation Examples with HuggingFace Diffusersinpainting_app/: Segementation-Aware In-Painting Application
See the related blog posts for more context:
- An Introduction to Image Generation with Diffusion Models (1/2): A Conceptual Guide for Developers & ML Practitioners
- An Introduction to Image Generation with Diffusion Models (2/2): Hands-On Examples with HuggingFace
In the following, I provide a recipe to set up a conda environment with the necessary packages. Note that a GPU (with at least 12 GB or memory) is required to train and/or using the models.
# Create the necessary Python environment
# NOTE: specific folders might require their own environment
# and have their own requirements.txt
conda env create -f conda.yaml
conda activate genai
# If you have CUDA, install CUDA support with the propper CUDA version, e.g. v12.1 (doesn't need to match 13.0)
pip install torch torchvision torchaudio torchtext --index-url https://download.pytorch.org/whl/cu121
# OTHERWISE, install CPU version -- BUT many examples won't work!
pip install torch torchvision torchaudio torchtext
# Compile rest of dependencies and install them
pip-compile requirements.in
pip install -r requirements.txt
# If we need a new dependency,
# add it to requirements.in
# (WATCH OUT: try to follow alphabetical order)
# And then:
pip-compile requirements.in
pip install -r requirements.txtFor these examples, I used
- a Lenovo ThinkPad P14s Gen 2i running Ubuntu 25.04
- and a GeForce NVIDIA RTX 3060 (12 GB) with CUDA driver version 580 and toolkit version 13.0.
Other related repositories of mine:
- My personal notes on the O'Reilly book Generative Deep Learning, 2nd Edition, by David Foster
- My personal notes on the Udacity Nanodegree Generative AI
- HuggingFace Guide:
mxagar/tool_guides/hugging_face - Deep Learning Methods for CV and NLP:
mxagar/computer_vision_udacity/CVND_Advanced_CV_and_DL.md - Notes on Generative Adversarial Networks (GANs):
mxagar/deep_learning_udacity/05_GAN/DLND_GANs.md
Mikel Sagardia, 2025
No guaranties.