https://github.com/saadsalmanakram/diffusion-ss
Learn everything you need to know about diffusion...
https://github.com/saadsalmanakram/diffusion-ss
diffusion diffusion-model diffusion-models stable-diffusion
Last synced: about 1 month ago
JSON representation
Learn everything you need to know about diffusion...
- Host: GitHub
- URL: https://github.com/saadsalmanakram/diffusion-ss
- Owner: saadsalmanakram
- Created: 2024-08-29T10:29:23.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-01-28T05:33:35.000Z (8 months ago)
- Last Synced: 2025-01-28T06:25:55.223Z (8 months ago)
- Topics: diffusion, diffusion-model, diffusion-models, stable-diffusion
- Homepage:
- Size: 62.5 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
---
# π«οΈ Diffusion Masterclass β Understanding & Implementing Diffusion Models

## π Introduction
**Diffusion models** are a class of generative models that have recently gained prominence in deep learning, particularly in **image synthesis, denoising, and probabilistic modeling**. These models iteratively **add noise to data** and then learn to reverse the process to generate realistic samples.
This repository serves as a **comprehensive guide** to mastering **Diffusion Models**, covering theoretical foundations, practical implementations, and applications in AI.
π **Understand the mathematics behind diffusion models**
π **Implement diffusion models from scratch using PyTorch**
π **Explore applications in image generation, denoising, and more**
π **Use Stable Diffusion, DDPM, and advanced diffusion techniques**---
## π Features
- π **Theory & Fundamentals** of Diffusion Models
- πΌοΈ **Image Generation with Denoising Diffusion Probabilistic Models (DDPM)**
- β‘ **Implementation in PyTorch**
- π **Stable Diffusion & Latent Diffusion Models (LDMs)**
- π **Exploration of Variational Diffusion Models & Score-Based Methods**
- π **Jupyter notebooks with step-by-step explanations**---
## π Repository Structure
```
Diffusion-ss/
βββ theory/ # Theory & mathematical foundations
βββ notebooks/ # Jupyter notebooks with implementations
βββ models/ # PyTorch implementations of diffusion models
βββ applications/ # Real-world applications (image generation, denoising, etc.)
βββ experiments/ # Custom diffusion experiments & modifications
βββ README.md # Documentation
βββ requirements.txt # Python dependencies
```---
## π Getting Started
### 1οΈβ£ Clone the Repository
```bash
git clone https://github.com/saadsalmanakram/Diffusion-ss.git
cd Diffusion-ss
```### 2οΈβ£ Install Dependencies
```bash
pip install -r requirements.txt
```### 3οΈβ£ Run a Simple Diffusion Model
```bash
python models/ddpm.py
```---
## π Topics Covered
### π **Theory & Fundamentals**
- What are **Diffusion Models**?
- Forward & Reverse Diffusion Process
- **Mathematical Formulation** (Stochastic Differential Equations)
- **DDPM vs. Score-Based Generative Models**### πΌοΈ **Image Generation with Diffusion Models**
- Implementing **Denoising Diffusion Probabilistic Models (DDPM)**
- Training diffusion models on **CIFAR-10, CelebA, and ImageNet**
- **Latent Diffusion Models (LDMs) & Stable Diffusion**### β‘ **Diffusion Models in PyTorch**
- Building a simple **DDPM from scratch**
- Training a model to **generate high-resolution images**
- Implementing **U-Net-based diffusion architectures**### π **Advanced Diffusion Techniques**
- **Classifier-free guidance** for improved generation
- **Conditional diffusion models** (text-to-image)
- **Speeding up inference using fast sampling methods (DDIM, PNDM)**### π **Real-World Applications**
- **Image Denoising & Super-Resolution**
- **Text-to-Image Generation (Stable Diffusion, Imagen, DALLΒ·E 2)**
- **Video & 3D Diffusion Models**---
## π Example Code
### πΌοΈ **Simple Forward Diffusion Process**
```python
import torch
import torch.nn.functional as Fdef forward_diffusion(x, noise, t, betas):
sqrt_alpha = (1 - betas).cumprod(dim=0).sqrt()
return sqrt_alpha[t] * x + torch.sqrt(1 - sqrt_alpha[t]) * noisex = torch.randn(1, 3, 64, 64) # Random image
noise = torch.randn_like(x)
betas = torch.linspace(0.0001, 0.02, 1000) # Noise schedule
diffused_x = forward_diffusion(x, noise, 100, betas)
```### π **Reverse Process with Learned Model**
```python
import torch.nn as nnclass SimpleUNet(nn.Module):
def __init__(self):
super().__init__()
self.conv1 = nn.Conv2d(3, 64, kernel_size=3, padding=1)
self.conv2 = nn.Conv2d(64, 3, kernel_size=3, padding=1)def forward(self, x, t):
x = F.relu(self.conv1(x))
return self.conv2(x)model = SimpleUNet()
prediction = model(diffused_x, 100) # Reverse step prediction
```---
## π₯ Cutting-Edge Diffusion Models
π **Stable Diffusion** β Latent space diffusion for **high-resolution text-to-image generation**
π **DALLΒ·E 2 & Imagen** β **Transformer-based conditional diffusion models**
π **Score-Based Generative Models** β SDE-based methods for **high-fidelity image synthesis**
π **Variational Diffusion Models (VDM)** β **Improving likelihood-based training**---
## π Contributing
Contributions are welcome! π
πΉ **Fork** the repository
πΉ Create a new branch (`git checkout -b feature-name`)
πΉ Commit changes (`git commit -m "Added DDIM sampling"`)
πΉ Push to your branch (`git push origin feature-name`)
πΉ Open a pull request---
## π License
This project is licensed under the **MIT License** β feel free to use, modify, and share the code.
---
## π¬ Contact
π§ **Email:** saadsalmanakram1@gmail.com
π **GitHub:** [SaadSalmanAkram](https://github.com/saadsalmanakram)
πΌ **LinkedIn:** [Saad Salman Akram](https://www.linkedin.com/in/saadsalmanakram/)---
β‘ **Master Diffusion Models & Unlock the Future of Generative AI!** β‘
---