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
Release files for ddpm 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| ddpm-1.0.0.tar.gz | 16.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| ddpm-1.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 21.0 kB
Release files / ddpm-1.0.0.tar.gz
| Download URL | ddpm-1.0.0.tar.gz |
|---|---|
| Size | 16.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2f9ae18dd4a54dc9a2f7decfca278d784293760900750c044c32ae63a9be4b6b
|
|
BLAKE2b-256 checksum How to use checksums |
1372c3a6b712c36536b6616ccb8dbf9167e316e8a1e0601eaf172bb5618c3282
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.9.15
|
Release files / ddpm-1.0.0-py3-none-any.whl
| Download URL | ddpm-1.0.0-py3-none-any.whl |
|---|---|
| Size | 4.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
256a3680c6b2f96bf764fa40d2ea831449f4fb345e97cb91856350d0ddfeba5d
|
|
BLAKE2b-256 checksum How to use checksums |
88a36282701ceab7a8d80e9eada1d5a8e944a82706cf7e70b338b55552fe7161
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.9.15
|