Image Processing Using Multi-Code GAN Prior

Jinjin Gu, Yujun Shen, Bolei Zhou

Abstract

Generative Adversarial Networks (GANs) have set benchmarks in image synthesis, yet their application to real-world image editing is hindered by the "inversion" problem. Standard methods struggle to find a single latent code that accurately reconstructs high-resolution images. This paper introduces mGANprior, a framework that employs multiple latent codes and adaptive channel mixing to significantly enhance the expressiveness of pre-trained GANs. By treating a fixed GAN as a versatile prior, we demonstrate superior performance in image reconstruction, super-resolution, and semantic editing across diverse datasets.

Introduction

The ability to manipulate real-world images using the generative power of GANs is a long-standing goal in computer vision. To edit an image, one must first "invert" it—mapping the pixel-space image back to the GAN's latent space. However, a single 512-dimensional latent vector often lacks the capacity to capture the intricate details of real-world photos, such as specific textures or individual identities. This limitation typically results in blurry reconstructions that fail to preserve the essence of the original subject.

Methodology: The Multi-Code Approach

The authors propose mGANprior (Multi-Code GAN Prior) to overcome the expressiveness bottleneck. Instead of optimizing for a single latent code, the method utilizes $N$ independent codes ($z_1, z_2, ..., z_n$).

Feature Composition and Adaptive Mixing

The core innovation lies in how these multiple codes are integrated. Each code is passed through the initial layers of a pre-trained, fixed generator to produce intermediate feature maps. Rather than simple averaging, the model learns adaptive channel importance weights ($\alpha$). These weights allow the system to selectively combine the most relevant features from different latent codes for different parts of the image. For instance, one code might specialize in facial features while another captures the background.

Joint Optimization

The reconstruction is achieved by simultaneously optimizing the latent codes and the channel weights via gradient descent. The loss function combines pixel-wise Mean Squared Error (MSE) with perceptual loss, ensuring both structural accuracy and visual realism. Crucially, the underlying GAN model remains unchanged, making mGANprior a "plug-and-play" solution for any pre-trained generator.

High-fidelity face reconstruction using mGANprior, demonstrating the ability to capture fine details and identity.

Experiments and Results

The researchers evaluated mGANprior using state-of-the-art models like PGGAN and StyleGAN on datasets including CelebA-HQ, FFHQ, and LSUN.

Reconstruction Quality

mGANprior significantly outperforms traditional inversion techniques. On the LSUN Bedroom dataset, the method achieved a PSNR of 25.13, a substantial leap from the 17.19 achieved by standard single-code optimization. This improvement allows for the reconstruction of complex scenes that were previously considered "out-of-distribution" for GAN inversion.

Reconstruction of a complex indoor scene from the LSUN Bedroom dataset, where mGANprior shows significant quantitative improvements.

Downstream Applications

The high-fidelity inversion enables several powerful image processing tasks:

  • Extreme Super-Resolution: The method can perform 16x super-resolution on faces by leveraging the GAN's internal knowledge of facial structures to synthesize missing details.
  • Semantic Editing: Once an image is inverted into the latent space, users can perform semantic manipulations—such as changing a person's age or expression—by shifting the optimized codes along known attribute directions.
  • Image Restoration: The GAN prior effectively handles inpainting and colorization, filling in missing or corrupted data with contextually appropriate content.

Discussion and Limitations

While mGANprior offers a robust solution for image inversion, it is not without limitations. The method's effectiveness is inherently tied to the domain of the pre-trained GAN; a model trained on faces cannot reconstruct a church. Additionally, the optimization-based nature of the approach is more computationally intensive than feed-forward encoder methods. Future work may focus on automating the selection of intermediate layers for feature composition to further optimize performance across different tasks.

Conclusion

By expanding the latent representation through multiple codes and adaptive mixing, mGANprior unlocks the potential of pre-trained GANs for real-world image processing. It provides a flexible, high-fidelity bridge between the pixel domain and the rich semantic space of generative models.

Summary updated

BibTeX
@inproceedings{gu2020image,
  author = {Jinjin Gu and Yujun Shen and Bolei Zhou},
  title = {{Image Processing Using Multi-Code GAN Prior}},
  booktitle = {IEEE/CVF Conference on Computer Vision and Pattern Recognition},
  year = {2020},
  doi = {10.1109/cvpr42600.2020.00308},
}
Figure