A Denoising Diffusion Implicit Model (DDIM) is a noise scheduler for diffusion sampling. Unlike DDPM, it uses a non-Markovian process and can follow a deterministic denoising trajectory, producing images in fewer steps. section 7.1 section 7.1.2
DDIM connects its schedule to the diffusion pipeline in several stages:
- Forward diffusion gradually adds noise to clean images until the final timestep becomes pure random noise. section 7.2.2
- Reverse diffusion uses the denoising model to move from noisy inputs toward clean images. section 7.1.2
- The parameter σt controls random noise in each reverse step; setting σt to zero produces deterministic DDIM sampling. section 7.1.2
- Fewer sampling steps improve efficiency, with reported speedups of 10 to 50 times over DDPM while retaining high-quality samples. section 7.1.2
Scheduling noise for flower images
Create a DDIMScheduler with 1,000 training timesteps, select training images, and call add_noise at successive steps. Visualizing timesteps 0, 200, 400, 600, 800, and 1,000 shows the progression from clean flowers to pure noise. section 7.2.2
Listing 7.2 Applying forward diffusion to flower images
from utils.ddim_util import DDIMScheduler noise_scheduler=DDIMScheduler(num_train_timesteps=1000) imgs=next(iter(train_dataloader))["input"] imgs=imgs.permute(0,2,3,1).reshape(-1,64,3) #1 allimgs=[imgs] for step in [200,400,600,800,1000]: #2 timesteps=torch.tensor([step-1]).long() noisy_image=noise_scheduler.add_noise(imgs, torch.randn(imgs.shape), timesteps) allimgs.append(noisy_image) plt.figure(figsize=(10,8),dpi=80) for i in range(6): #3 plt.subplot(1,6,i+1) plt.imshow(torch.clip(allimgs[i],0,1)) plt.axis('off') plt.title(f"t={200*i}",fontsize=16) plt.tight_layout(w_pad=-0.1) plt.show()
Inspect the PyTorch implementation that constructs DDIMScheduler, adds noise at selected timesteps, and plots the resulting image sequence. section 7.2.2
