Pytorch implementation of 'Improved Denoising Diffusion Probabilistic Models', 'Denoising Diffusion Probabilistic Models' and 'Classifier-free Diffusion Guidance'
Project description
DDPMs Pytorch Implementation
Pytorch implementation of "Improved Denoising Diffusion Probabilistic Models", "Denoising Diffusion Probabilistic Models" and "Classifier-free Diffusion Guidance"
Install
pip install ddpm
Usage
Gaussian plain DDPM
from ddpm import GaussianDDPM, UNetTimeStep
from ddpm.variance_scheduler import LinearScheduler
T = 1_000
width = 32
height = 32
channels = 3
# Create a Gaussian DDPM with 1000 noise steps
scheduler = LinearScheduler(T=T, beta_start=1e-5, beta_end=1e-2)
denoiser = UNetTimeStep(channels=[3, 128, 256, 256, 384],
kernel_sizes=[3, 3, 3, 3],
strides=[1, 1, 1, 1],
paddings=[1, 1, 1, 1],
p_dropouts=[0.1, 0.1, 0.1, 0.1],
time_embed_size=100,
downsample=True)
model = GaussianDDPM(denoiser, T, scheduler, vlb=False, lambda_variational=1.0, width=width,
height=height, input_channels=channels, logging_freq=1_000) # pytorch lightning module
Gaussian "Improved" DDPM
from ddpm import GaussianDDPM, UNetTimeStep
from ddpm.variance_scheduler import CosineScheduler
T = 1_000
width = 32
height = 32
channels = 3
# Create a Gaussian DDPM with 1000 noise steps
scheduler = CosineScheduler(T=T)
denoiser = UNetTimeStep(channels=[3, 128, 256, 256, 384],
kernel_sizes=[3, 3, 3, 3],
strides=[1, 1, 1, 1],
paddings=[1, 1, 1, 1],
p_dropouts=[0.1, 0.1, 0.1, 0.1],
time_embed_size=100,
downsample=True)
model = GaussianDDPM(denoiser, T, scheduler, vlb=True, lambda_variational=0.0001, width=width,
height=height, input_channels=channels, logging_freq=1_000) # pytorch lightning module
Classifier-free Diffusion Guidance
from ddpm import GaussianDDPMClassifierFreeGuidance, UNetTimeStep
from ddpm.variance_scheduler import CosineScheduler
T = 1_000
width = 32
height = 32
channels = 3
num_classes = 10
# Create a Gaussian DDPM with 1000 noise steps
scheduler = CosineScheduler(T=T)
denoiser = UNetTimeStep(channels=[3, 128, 256, 256, 384],
kernel_sizes=[3, 3, 3, 3],
strides=[1, 1, 1, 1],
paddings=[1, 1, 1, 1],
p_dropouts=[0.1, 0.1, 0.1, 0.1],
time_embed_size=100,
downsample=True)
model = GaussianDDPMClassifierFreeGuidance(denoiser, T, w=0.3, v=0.2, variance_scheduler=scheduler, width=width,
height=height, input_channels=channels, logging_freq=1_000, p_uncond=0.2,
num_classes=num_classes) # pytorch lightning module
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
ddpm-1.0.0.tar.gz
(16.8 kB
view details)
Built Distribution
ddpm-1.0.0-py3-none-any.whl
(4.2 kB
view details)
File details
Details for the file ddpm-1.0.0.tar.gz
.
File metadata
- Download URL: ddpm-1.0.0.tar.gz
- Upload date:
- Size: 16.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.15
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2f9ae18dd4a54dc9a2f7decfca278d784293760900750c044c32ae63a9be4b6b |
|
MD5 | e4c02fb926e9128669ed61f6f9d40dcb |
|
BLAKE2b-256 | 1372c3a6b712c36536b6616ccb8dbf9167e316e8a1e0601eaf172bb5618c3282 |
File details
Details for the file ddpm-1.0.0-py3-none-any.whl
.
File metadata
- Download URL: ddpm-1.0.0-py3-none-any.whl
- Upload date:
- Size: 4.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.15
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 256a3680c6b2f96bf764fa40d2ea831449f4fb345e97cb91856350d0ddfeba5d |
|
MD5 | ec95037088db35427d89ea72c90d27bf |
|
BLAKE2b-256 | 88a36282701ceab7a8d80e9eada1d5a8e944a82706cf7e70b338b55552fe7161 |