Skip to content
AI360Xpert
Paper Breakdowns
Paper breakdown

Taming Transformers for High-Resolution Image Synthesis

Introduces VQGAN, combining the local efficiency of convolutional models with the global expressivity of Transformers through a learned discrete codebook.

Paper: Taming Transformers for High-Resolution Image Synthesis

Authors: Patrick Esser, Robin Rombach, Björn Ommer · 2020

Read the paper
VQGAN encodes images into discrete tokens, which a Transformer models autoregressively.
VQGAN encodes images into discrete tokens, which a Transformer models autoregressively.

The Problem

Transformers achieved unprecedented success in natural language processing by modeling discrete sequences (text tokens) autoregressively. However, applying them directly to high-resolution image synthesis was computationally intractable. Images contain millions of pixels, and the self-attention mechanism scales quadratically with sequence length. Previous approaches either modeled low-resolution images directly or relied purely on convolutional networks (like GANs), which excel at local details but struggle with global structural coherence. The field needed a way to bridge the gap: utilizing the global sequence modeling power of Transformers without the crushing computational cost of pixel-level autoregression.

The Idea

The authors proposed a two-stage approach. First, train a Vector Quantized Generative Adversarial Network (VQGAN) to compress high-resolution images into a drastically smaller, discrete spatial grid of "image tokens" via a learned codebook. Second, flatten this grid into a 1D sequence and train a standard autoregressive Transformer to predict the next token. By learning a discrete, perceptually rich vocabulary of image patches, the model offloads the heavy lifting of local pixel realism to a CNN, freeing the Transformer to focus entirely on global composition and long-range dependencies.

How It Works

1. The VQGAN Encoder and Codebook An input image is processed by a CNN encoder, producing a continuous spatial feature map. Each feature vector in this map is then replaced by its nearest neighbor in a learned, discrete codebook. This step creates a quantized feature map (a grid of discrete indices), effectively reducing the image to a sequence of "visual words".

2. The Decoder and Discriminator A CNN decoder takes the quantized feature map and reconstructs the original image. Crucially, this first stage is trained with an adversarial loss (a patch-based discriminator) and a perceptual loss, which forces the codebook and decoder to produce highly realistic, sharp local textures. This avoids the blurriness that plagued earlier VQ-VAE models.

3. The Autoregressive Transformer Once the VQGAN is trained, its encoder and codebook are frozen. A dataset of images is converted into sequences of discrete codebook indices. A Transformer is then trained on these sequences to predict the next index given the previous ones, exactly like training a language model on text.

4. High-Resolution Synthesis To generate a new image, the Transformer generates a sequence of indices autoregressively from scratch (or conditioned on a prompt). This sequence is reshaped back into a 2D spatial grid, and the frozen VQGAN decoder renders it into a final, high-resolution image.

Why It Mattered

VQGAN demonstrated that Transformers could master high-resolution visual generation by operating in a discrete, compressed latent space instead of pixel space. It proved that "language modeling" could work for images if the right vocabulary was established first. The adversarial training of the visual codebook was a breakthrough, showing that discrete tokens could perfectly capture high-frequency details.

What Came After

This exact paradigm—compressing images into discrete or continuous latents and modeling them with a separate architecture—directly paved the way for Latent Diffusion Models (LDMs). The VQGAN itself became a standard building block, heavily utilized in systems like DALL-E (first version concepts), VQGAN+CLIP generative art pipelines, and eventually evolving into the continuous autoencoders used in Stable Diffusion.