A Wasserstein GAN for Joint Learning of Inpainting and Spatial Optimisation

Pascal Peter

Abstract

Image inpainting is typically treated as a restoration task given a fixed mask. However, the inverse problem—spatial optimization—asks which pixels should be preserved to maximize reconstruction quality. This paper introduces a Wasserstein Generative Adversarial Network (WGAN) that jointly learns both the optimal mask and the inpainting function. By employing a novel differentiable binarization layer, the framework enables end-to-end training. Experimental results on ImageNet and BSDS500 demonstrate that this joint approach significantly outperforms existing deep learning and classical methods in both visual quality and computational efficiency, achieving speedups of over four orders of magnitude.

Introduction

The task of image inpainting involves reconstructing missing regions of an image. While often used for restoration, it is central to sparse image representation and compression. In these contexts, the challenge is spatial optimization: selecting a minimal set of pixels (e.g., 5%) that allows for the most accurate reconstruction of the original signal.

Historically, inpainting and mask optimization were treated as separate problems or solved using slow, iterative mathematical models. Training an inpainter on random masks often leads to sub-optimal performance when applied to optimized masks. Conversely, optimizing a mask requires a fixed, reliable inpainter. This "chicken and egg" problem motivated the development of a joint learning framework where both components evolve together.

Proposed Methodology

The authors propose a unified architecture comprising three distinct sub-networks: a mask generator, an inpainting generator, and a discriminator.

Network Architecture

  1. Mask Generator ($m$): This network analyzes the input image to produce a binary mask $b$. It identifies structural features and textures that are critical for reconstruction.
  2. Inpainting Generator ($g$): An hourglass-shaped network that receives the sparse pixels defined by the mask and reconstructs the full image $u$.
  3. Discriminator ($d$): A critic network that distinguishes between real images and those reconstructed by the generator, driving the system toward producing natural-looking textures.
The joint architecture of the proposed Mask GAN, featuring the mask network, generator, and discriminator.

Differentiable Binarization

A significant hurdle in joint training is the non-differentiable nature of the binarization process (converting continuous probabilities to 0 or 1). To overcome this, the authors evaluate several rounding strategies, ultimately utilizing a "hard rounding" approach with a straight-through estimator to allow gradient flow during backpropagation.

Comparison of rounding methods used to handle non-differentiability in the mask generation process.

Loss Functions

The system is optimized using a combination of losses:

  • Wasserstein Loss: Encourages the generator to match the distribution of natural images, avoiding the blurriness associated with standard Mean Squared Error (MSE).
  • Density Loss: A penalty term that ensures the mask generator selects a specific percentage of pixels, maintaining the desired sparsity level.
  • Image Loss: A reconstruction loss (e.g., MAE) to ensure pixel-wise fidelity to the original image.

Experimental Results

The model was trained on a subset of 100,000 ImageNet images and evaluated on the BSDS500 dataset to test generalization.

Performance and Speed

The proposed "Mask GAN" (MG) demonstrated a clear advantage over previous state-of-the-art deep learning methods like NetM, showing an improvement of up to 1.7 dB in Peak Signal-to-Noise Ratio (PSNR) on ImageNet.

The most dramatic improvement, however, is in computational speed. Traditional stochastic optimization methods, such as Probabilistic Sparsification, are computationally expensive. The GAN-based approach is approximately 63 times faster on a CPU and over 12,000 times faster when utilizing a GPU, enabling real-time spatial optimization for the first time.

Visual Quality

At extreme sparsity (e.g., 5% pixel density), the joint learning approach excels at preserving complex structures. While classical diffusion-based methods often struggle with "color bleeding" or loss of fine detail in textures like zebra stripes or architectural elements, the WGAN framework produces sharp, semantically plausible reconstructions.

Conclusion

This work demonstrates that joint learning of inpainting and spatial optimization is not only feasible but superior to decoupled approaches. By integrating a discriminator and a differentiable binarization layer, the model learns to prioritize pixels that are most informative for its specific reconstruction capabilities. Future research will focus on scaling the architecture to high-resolution images and conducting deeper ablation studies to isolate the contributions of the various loss components.

Summary updated

BibTeX
@inproceedings{peter2022wasserstein,
  author = {Pascal Peter},
  title = {{A Wasserstein GAN for Joint Learning of Inpainting and Spatial Optimisation}},
  booktitle = {PSIVT},
  year = {2022},
  url = {https://openreview.net/forum?id=TKG2fn5jBm},
}
Figure