Generating Diverse High-Fidelity Images with VQ-VAE-2

Ali Razavi, Aaron van den Oord, Oriol Vinyals

TL;DR

VQ-VAE-2 scales discrete latent variable models to generate high-resolution, diverse images that rival state-of-the-art GANs in quality. By combining a multi-scale hierarchical encoder with powerful autoregressive priors (PixelSNAIL), the model achieves high fidelity and global coherence without the typical GAN pitfalls of mode collapse or lack of diversity.

What Problem Does This Paper Address?

Generative modeling has long been a tug-of-war between two paradigms. Generative Adversarial Networks (GANs) produce incredibly sharp, high-fidelity images but are notoriously difficult to train and often suffer from "mode collapse," where the model ignores large parts of the data distribution to focus on a few "safe" types of images.

On the other side, likelihood-based models (like VAEs and autoregressive models) are mathematically principled and capture the full diversity of the data. However, they have historically struggled to produce sharp, high-resolution images. Autoregressive models, which generate images pixel-by-pixel, are also painfully slow to sample for large images. VQ-VAE-2 aims to bridge this gap, providing GAN-level quality with the stability and diversity of likelihood-based approaches.

Methods

The authors propose a two-stage approach that leverages the idea of lossy compression to make image generation more manageable.

Stage 1: The Hierarchical VQ-VAE

Instead of modeling pixels directly, the model first learns to compress images into a discrete latent space. The key innovation here is a multi-scale hierarchy.

  • Top Level: Captures global structure (e.g., the shape of an object) in a very small latent map (e.g., 32x32).
  • Bottom Level: Captures local details and textures (e.g., fur, leaves) in a larger latent map (e.g., 64x64), conditioned on the top level.
Overview of the hierarchical VQ-VAE architecture.

This separation allows the model to focus on different levels of abstraction independently. As shown in Figure 3, each level of the hierarchy adds a specific layer of detail to the final reconstruction.

Reconstructions showing how each latent map adds detail.

Stage 2: Learning the Priors

Once the VQ-VAE is trained, the authors fit powerful autoregressive models—specifically PixelSNAIL, which combines causal convolutions with self-attention—to the latent codes. Because these models operate in the compressed latent space rather than the pixel space, they are roughly 30x faster to sample and can capture long-range dependencies more effectively.

Datasets

The model was evaluated on two primary benchmarks:

  • ImageNet (256x256): A massive, multifaceted dataset of 1,000 object classes.
  • FFHQ (1024x1024): A dataset of 70,000 high-quality human portraits, used to test the model's ability to generate extremely high-resolution images with long-range symmetries (like matching eye colors).

Key Insights and Ideas

  • Lossy Compression as a Feature: By removing ~80% of negligible pixel information through vector quantization, the generative model is "relieved" from modeling noise and can focus on meaningful semantic structure.
  • Hierarchy Simplifies the Prior: Modeling a single complex distribution is hard. Modeling a global distribution and then a local distribution conditioned on the global one is much more tractable for autoregressive models.
  • Trading Diversity for Quality: The authors introduce a "critic"—a pre-trained classifier—to perform rejection sampling. By keeping only the samples the classifier is confident about, they can trade off some of the model's inherent diversity for even higher visual fidelity, similar to the "truncation trick" used in GANs.

Key Results

VQ-VAE-2 produces stunningly realistic samples across a wide variety of classes.

  • Fidelity vs. Diversity: In side-by-side comparisons with BigGAN-deep (the state-of-the-art GAN at the time), VQ-VAE-2 demonstrated comparable image quality while maintaining significantly higher diversity in poses and compositions.
  • Quantitative Superiority: The model achieved a Classification Accuracy Score (CAS) of 54.83 on ImageNet, significantly outperforming BigGAN-deep's 42.65. This metric suggests that the samples generated by VQ-VAE-2 are more useful for training downstream classifiers.
  • High-Resolution Scaling: The model successfully generated 1024x1024 faces that maintain global coherence, such as consistent lighting and symmetric facial features.
Comparison of sample diversity between VQ-VAE-2 and BigGAN.

Limitations and Future Work

While VQ-VAE-2 is much faster than pixel-space models, sampling is still autoregressive, meaning it happens sequence-by-sequence in the latent space. This is still slower than the single-pass forward generation of a GAN.

Additionally, the authors noted that standard metrics like FID can be overly sensitive to the slight blurriness inherent in VQ-VAE reconstructions. They proposed "FID*" (comparing samples to reconstructions rather than original images) to better capture the model's performance. Future work could involve further optimizing sampling speed or refining the quantization process to reduce reconstruction artifacts.

Summary updated

Abstract

We explore the use of Vector Quantized Variational AutoEncoder (VQ-VAE) models for large scale image generation. To this end, we scale and enhance the autoregressive priors used in VQ-VAE to generate synthetic samples of much higher coherence and fidelity than possible before. We use simple feed-forward encoder and decoder networks, making our model an attractive candidate for applications where the encoding and/or decoding speed is critical. Additionally, VQ-VAE requires sampling an autoregressive model only in the compressed latent space, which is an order of magnitude faster than sampling in the pixel space, especially for large images. We demonstrate that a multi-scale hierarchical organization of VQ-VAE, augmented with powerful priors over the latent codes, is able to generate samples with quality that rivals that of state of the art Generative Adversarial Networks on multifaceted datasets such as ImageNet, while not suffering from GAN's known shortcomings such as mode collapse and lack of diversity.
BibTeX
@inproceedings{razavi2019generating,
  author = {Ali Razavi and Aaron van den Oord and Oriol Vinyals},
  title = {{Generating Diverse High-Fidelity Images with VQ-VAE-2}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2019},
}
Figure