= DDG_Context()
ddg = torch.randn(8, 4, 16, 16)
x0 = torch.randint(0, 4, (8,), dtype=torch.long)
t = ddg.q_xt_x0(x0, t)
x_t, n_t x_t.shape, n_t.shape
(torch.Size([8, 4, 16, 16]), torch.Size([8, 4, 16, 16]))
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:
DDG_Context.q_xt_xtminus1 (xtm1, t)
A single noising step.
DDG_Context.q_xt_x0 (x0, t)
Jump to a given step.
DDG_Context.p_xt (xt, noise, t)
The reverse step, not used in DDG but included for vanilla diffusion tests.
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: