DiffGANPaint: Fast Inpainting Using Denoising Diffusion GANs

✨ ICLR 2023 Tiny Papers ✨

Moein Heidari, Alireza Morsali, Tohid Abedini, Samin Heydarian
Figure 3. Visual examples of DiffGANPaint results on generic images. From left to right, shows the original image, input masked image and result image.

Abstract

Free-form image inpainting is the task of reconstructing parts of an image specified by an arbitrary binary mask. In this task, it is typically desired to generalize model capabilities to unseen mask types, rather than learning certain mask distributions. Capitalizing on the advances in diffusion models, in this paper, we propose a Denoising Diffusion Probabilistic Model (DDPM) based model capable of filling missing pixels fast as it models the backward diffusion process using the generator of a generative adversarial network (GAN) network to reduce sampling cost in diffusion models. Experiments on general-purpose image inpainting datasets verify that our approach performs superior or on par with most contemporary works.

Methodology

def denoise_diffusion(x, model):
    noise = torch.randn_like(x)
    for i in range(timesteps):
        eps = torch.randn_like(x)
        x = x + torch.sqrt(torch.tensor(2.0)) *
        eps
        model_input = torch.cat([x, noise])
        out = model(model_input)
        x = x + out * np.sqrt(1/timesteps)
    return x

def test_inpainting(img, gan,mask):
    denoised_img = denoise_diffusion(img,gan)
    model_input = torch.cat([denoised_img, mask])
    output = gan(model_input)
    output = output * mask + masked_image * (1 - mask)
Figure 1. DiffGANPaint Inpainting Procedure in Pytorch Style: Pseudo code to generate the inpainted image using the corresponding mask, trained diffusion model and generator.

BibTeX

@article{heidari2023diffganpaint,
  title   = {DiffGANPaint: Fast Inpainting Using Denoising Diffusion GANs},
  author  = {Heidari, Moein and Morsali, Alireza and Abedini, Tohid and Heydarian, Samin},
  journal = {arXiv preprint arXiv:2311.11469},
  year    = {2023}
}