A denoising model is a deep neural network that estimates or removes noise from a corrupted sample. In diffusion, it reverses a process that gradually transforms a clean image into random noise. section 1.3.1 section 5.1.1
The diffusion workflow proceeds through two contrasting directions:
- Forward diffusion adds controlled noise over T steps, changing a clean image x₀ into random noise xₜ. section 1.3.1 section 7.2.2
- Reverse diffusion starts with random noise and repeatedly applies the trained denoising model, producing progressively clearer images until step 0. section 1.3.1 section 5.1.1
- A reparameterized noise formula can sample a corrupted image at an arbitrary timestep instead of simulating every earlier step. section 5.1.1
Flower-image corruption
Take four clean training images and apply a DDIM noise scheduler at selected timesteps. Plot the results from clean images through increasing corruption to pure random noise, then use them as training data for a high-resolution denoising model. 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()
The listing makes the forward process concrete by adding scheduler-controlled noise at several timesteps and plotting the resulting images. section 7.2.2
