All models

vqgan_vqmodel_autoencoder

A convolutional autoencoder that turns an image into discrete codebook entries and reconstructs it.

Diffusion and generative · 464 operations Checked

100%

Showing the top corner; full diagram not loaded yetShowing a small copy; full diagram not loaded yetLarge diagram, not loaded yet

Open SVG

Loading diagram (10 KB)

Open in a new tab

Click or tap a spot to read it up close. Scroll or drag inside the diagram to move through it. Zoom with + and − or Ctrl and scroll. Press 0 for the whole graph. Swipe inside the diagram to move through it. Use + and − to zoom.

At a glance

Family
VQGAN
Parameters
72.1M
Operations
464
Framework
PyTorch
Recurrent
No
Published
CVPR 2021
Cited by
2,505 (as of 22 October 2026)
Authors
Patrick Esser, Robin Rombach, Björn Ommer
License
MIT
Checked
Passed: the trace was replayed operation by operation and matched the model's own output for this input.

Files

The diagram is a drawing of a TorchLens trace of the source code. It contains no code or weights.

Details
Stable ID
m11203
Graph hash
d35076863aa0d243e3f9bd63e120834e14d5eba7d5fd23713a6cc306a109ef1c
Skeleton hash
c79ad88a4e3fa74776d15f6192c7909b6a6c30bfafdf8d7550a70b71b8bcacc3
Architecture hash
ada685a88976d35dd999e055c3ec5ecd77d3810522de8337950fd1ef80f9d6a8
Diagram SHA-256
912697bc4b730c1f45a35e64fbff9e65702dae88e777326d821afd80ba988819
TorchLens version
2.36.0
Renderer
graphviz 2.43.0+pyvips 3.2.0+libvips 8.18.7+render-opts@06c1f0d3
Check
Forward pass replayed in PyTorch

What it is

About this model's family

VQGAN is a convolutional model that learns a codebook of visual parts, so that a transformer can then model how those parts compose into an image. The paper describes it as a variant of VQVAE that adds a discriminator and a perceptual loss to keep good perceptual quality at a higher compression rate.

It consists of a convolutional encoder and decoder that together represent an image with codes from a learned, discrete codebook. The quantization step is not differentiable, so a straight-through gradient estimator copies the gradients from the decoder to the encoder. A single attention layer at the lowest resolution aggregates context from the whole image. In training, the L2 reconstruction loss is replaced by a perceptual loss, and a patch-based discriminator learns to tell real images from reconstructed ones.

In the paper, a transformer is then trained on top of this autoencoder to predict the sequence of codebook indices one index at a time, which is how images are generated. The paper presents what it calls the first results on semantically-guided synthesis of megapixel images with transformers. For its class-conditional ImageNet model on 256 × 256 images, the paper uses a VQGAN with dim Z = 16384 and f = 16.

Key idea. The paper built VQGAN, a convolutional VQVAE variant trained with a discriminator and perceptual loss, whose learned codebook lets a transformer model high-resolution images.

  • vqgan
  • taming transformers
  • vqmodel
  • vector quantized gan
  • image tokenizer
  • discrete codebook
  • vq autoencoder
  • high-resolution image synthesis
  • image synthesis

AI-written summary, based on the paper and checked automatically against it; not reviewed by a person. Corrections welcome.

Cite the paper

@misc{esser2021tamingtransformershighresolutionimage,
      title={Taming Transformers for High-Resolution Image Synthesis}, 
      author={Patrick Esser and Robin Rombach and Björn Ommer},
      year={2021},
      eprint={2012.09841},
      archivePrefix={arXiv},
      primaryClass={cs.CV},
      url={https://arxiv.org/abs/2012.09841}, 
}