High-Quality Pluralistic Image Completion via Code Shared VQGAN

Chuanxia Zheng, Guoxian Song, Tat-Jen Cham, Jianfei Cai, Dinh Q. Phung, Linjie LuoarXiv 2022 · DOI

The Challenge of Pluralistic Inpainting

Image completion, or inpainting, is fundamentally an ambiguous task. When a portion of an image is missing, there is rarely a single "correct" way to fill it. For instance, masking a person's eyes could lead to various valid expressions or eye colors. Traditional methods often focus on finding a single deterministic solution, failing to capture the multi-modal nature of the real world.

Existing pluralistic methods—those designed to generate multiple diverse outputs—typically face a "trilemma" between quality, diversity, and speed:

  1. Variational methods (like PICNet) often struggle to balance diversity (KL loss) with reconstruction quality.
  2. Autoregressive Transformers (like ICT) produce high-quality results but are computationally expensive, often taking minutes to generate a single image because they predict tokens sequentially.
  3. Pixel-level discrete models often produce artifacts because they operate on a limited, pre-clustered color palette.

A Novel Three-Stage Framework

This research introduces a framework that achieves state-of-the-art visual quality and diversity while operating over 100x faster than previous transformer-based approaches. The system relies on three core innovations:

1. Code-Shared VQGAN

Standard Vector Quantized Generative Adversarial Networks (VQGANs) represent images as a grid of discrete codes. This paper proposes a "code-sharing" mechanism where spatial features are subdivided into multiple "chunks" along the channel dimension. Each chunk is quantized using a shared codebook. This allows a low-resolution grid (e.g., 16x16) to represent complex, high-frequency details by recomposing shared attributes across channels, effectively disentangling properties like color and texture.

2. Weighted Bidirectional Transformer

To fill the masked regions, the authors employ a bidirectional transformer. Unlike autoregressive models that only look at "past" tokens, this model uses bidirectional attention to consider all visible regions simultaneously. A unique weighting scheme is introduced based on the visible pixel ratio in each patch, guiding the transformer to prioritize reliable ground-truth information over its own intermediate predictions.

3. One-Time Sampling and Refinement

Because the bidirectional transformer captures global context in every layer, the model can sample all missing tokens simultaneously. This "one-time sampling" is the key to the massive speedup. Finally, a CNN-based refinement network merges the coarse transformer output with high-resolution visible pixels to ensure sharp edges and consistent lighting at resolutions up to 512x512.

Performance and Results

The model was evaluated on the FFHQ, ImageNet, and Places2 datasets using irregular "free-form" masks to simulate realistic holes.

Speed and Efficiency

The most striking result is the efficiency gain. The proposed model averages just 83ms per image on a single GPU, compared to over 120 seconds for the ICT baseline. This 100x speedup makes high-quality pluralistic inpainting viable for real-time interactive applications.

Visual Quality and Diversity

Quantitatively, the model outperforms competitors on metrics like FID (Fréchet Inception Distance) and LPIPS (Learned Perceptual Image Patch Similarity). On the Places2 dataset with a 40-50% mask ratio, the refined model achieved an FID of 15.65, a significant improvement over ICT's 28.18.

Pluralistic image completion results. The top three rows show diverse completions for waterfall, dog, and face categories. The bottom row provides a direct comparison with the ICT baseline, demonstrating superior consistency and detail.

Qualitatively, the model generates diverse variations in facial expressions, textures, and lighting while maintaining global coherence. As shown in the comparison above, the code-shared approach avoids the artifacts often seen in pixel-level discrete models or the slow convergence of autoregressive methods.

Limitations and Future Work

Despite its success, the model is currently domain-specific; a model trained on faces does not generalize to landscapes. Additionally, while the refinement network is effective, the core latent representation remains at a relatively low resolution. Future work aims to develop a more universal codebook and transformer architecture capable of handling ultra-high-resolution images across diverse domains.

Summary updated

BibTeX
@misc{zheng2022high,
  author = {Chuanxia Zheng and Guoxian Song and Tat-Jen Cham and Jianfei Cai and Dinh Q. Phung and Linjie Luo},
  title = {{High-Quality Pluralistic Image Completion via Code Shared VQGAN}},
  year = {2022},
  eprint = {2204.01931},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2204.01931},
}
Figure