Views
No views yet
1from diffusers import UNetModel, GaussianDiffusion
2import torch
3
4# 1. Load model
5unet = UNetModel.from_pretrained("fusing/ddpm_dummy")
6
7# 2. Do one denoising step with model
8batch_size, num_channels, height, width = 1, 3, 32, 32
9dummy_noise = torch.ones((batch_size, num_channels, height, width))
10time_step = torch.tensor([10])
11image = unet(dummy_noise, time_step)
12
13# 3. Load sampler
14sampler = GaussianDiffusion.from_config("fusing/ddpm_dummy")
15
16# 4. Sample image from sampler passing the model
17image = sampler.sample(model, batch_size=1)
18
19print(image)