Denoising Diffusion GAN Context

Managing admin around the DDG training and sampling process.

source

DDG_Context

 DDG_Context (n_steps=5, beta_min=0.3, beta_max=0.9, device='cpu')

Keep track of the numbre of steps, variance schedule etc. And provide a few utility functions.

Included functions:


source

DDG_Context.q_xt_xtminus1

 DDG_Context.q_xt_xtminus1 (xtm1, t)

A single noising step.


source

DDG_Context.q_xt_x0

 DDG_Context.q_xt_x0 (x0, t)

Jump to a given step.


source

DDG_Context.p_xt

 DDG_Context.p_xt (xt, noise, t)

The reverse step, not used in DDG but included for vanilla diffusion tests.


source

DDG_Context.examples

 DDG_Context.examples (ae_model, unet, cloob, n_examples=12,
                       cfg_scale_min=0, cfg_scale_max=4, prompts=['A
                       photograph portrait of a man with a beard, a human
                       face', 'Green hills and grass beneath a blue sky',
                       'A watercolor painting of an underwater submarine',
                       'A car, a photo of a red car', 'An armchair in the
                       shape of an avocado', 'blue ocean waves', 'A red
                       stop sign'], img_size=128, z_dim=8)

Given ae_model, a u_net and cloob, produce some example images with CFG.

In action:

ddg = DDG_Context()
x0 = torch.randn(8, 4, 16, 16)
t = torch.randint(0, 4, (8,), dtype=torch.long)
x_t, n_t = ddg.q_xt_x0(x0, t)
x_t.shape, n_t.shape
(torch.Size([8, 4, 16, 16]), torch.Size([8, 4, 16, 16]))
# TODO: return noise optional
# TODO: explain what this is :)
# TODO random t convenience function
# TODO p_xt_xtm1 for non-DDG diffusion