Skip to main content
Botmartz AI Solutions Private Limited
MODELS

Diffusion Models: Denoising Diffusion Probabilistic Models (DDPM) and Image Generation

Diffusion models generate images by learning to reverse noise. Add noise to images, learn to denoise, then sample by denoising random noise. Enables stable, high-quality image generation.

Soham Sharma
Soham Sharma
AI Engineer, Botmartz · Dec 4, 2026
Depth
Full Spec
Failure Modes
5
Code Snippets
6
Runnable Notebook
0
Diffusion Models: Denoising Diffusion Probabilistic Models (DDPM) and Image Generation

Diffusion models generate images through an iterative denoising process. Add Gaussian noise to images gradually (forward process), then train a model to reverse this process (reverse process). Sampling starts with pure noise and denoises iteratively to generate new images.

Forward Process

Code Snippet
x_0 (real image)
  ↓ (add noise)
x_1 (slightly noisy)
  ↓ (add more noise)
x_2 (more noisy)
  ↓ ...
x_T (pure noise)

Reverse Process (Denoising)

Train a neural network to predict and remove noise:

Code Snippet
import torch
import torch.nn as nn

class DiffusionModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.encoder = nn.Sequential(...)  # Image encoder
        self.decoder = nn.Sequential(...)  # Noise predictor
    
    def forward(self, x_t, t):
        # x_t: noisy image at step t
        # Predict and subtract noise
        noise_pred = self.decoder(self.encoder(x_t))
        x_{t-1} = (x_t - noise_pred) / sqrt(alpha_t)
        return x_{t-1}

Sampling

Code Snippet
Start with x_T ~ N(0, I) (pure noise)
For t = T, T-1, ..., 1:
    x_{t-1} = denoise_model(x_t, t)
Return x_0 (generated image)

Conclusion

Diffusion models are the foundation of modern image generation (DALL-E, Stable Diffusion). Understanding the forward/reverse processes explains how denoising generates realistic images. Next: video generation models that extend diffusion to temporal sequences.

#Generative Models#Diffusion#Image Generation#Deep Learning
1 views
Soham Sharma
Soham Sharma
Leading AI systems research, enterprise RAG, and multi-agent workflow architecture at Botmartz AI Solutions.