Taming Transformers for High-Resolution Image Synthesis
Patrick Esser, Robin Rombach, Björn Ommer
Introduction
Transformers are on the rise—they are now the de-facto standard architecture for language tasks and are increasingly adapted in other areas such as audio and vision . In contrast to the predominant vision architecture, convolutional neural networks (CNNs), the transformer architecture contains no built-in inductive prior on the locality of interactions and is therefore free to learn complex relationships among its inputs. However, this generality also implies that it has to learn all relationships, whereas CNNs have been designed to exploit prior knowledge about strong local correlations within images. Thus, the increased expressivity of transformers comes with quadratically increasing computational costs, because all pairwise interactions are taken into account. The resulting energy and time requirements of state-of-the-art transformer models thus pose fundamental problems for scaling them to high-resolution images with millions of pixels.
Observations that transformers tend to learn convolutional structures thus beg the question: Do we have to re-learn everything we know about the local structure and regularity of images from scratch each time we train a vision model, or can we efficiently encode inductive image biases while still retaining the flexibility of transformers? We hypothesize that low-level image structure is well described by a local connectivity, i.e. a convolutional architecture, whereas this structural assumption ceases to be effective on higher semantic levels. Moreover, CNNs not only exhibit a strong locality bias, but also a bias towards spatial invariance through the use of shared weights across all positions. This makes them ineffective if a more holistic understanding of the input is required.
Our key insight to obtain an effective and expressive model is that, taken together, convolutional and transformer architectures can model the compositional nature of our visual world : We use a convolutional approach to efficiently learn a codebook of context-rich visual parts and, subsequently, learn a model of their global compositions. The long-range interactions within these compositions require an expressive transformer architecture to model distributions over their consituent visual parts. Furthermore, we utilize an adversarial approach to ensure that the dictionary of local parts captures perceptually important local structure to alleviate the need for modeling low-level statistics with the transformer architecture. Allowing transformers to concentrate on their unique strength—modeling long-range relations—enables them to generate high-resolution images as in Fig. Taming Transformers for High-Resolution Image Synthesis, a feat which previously has been out of reach. Our formulationgives control over the generated images by means of conditioning information regarding desired object classes or spatial layouts. Finally, experiments demonstrate that our approach retains the advantages of transformers by outperforming previous codebook-based state-of-the-art approaches based on convolutional architectures.
Related Work
When performing autoregressive maximum-likelihood learning, non-causal entries of , i.e. all entries below its diagonal, are set to and the final output of the transformer is given after a linear, point-wise transformation to predict logits of the next sequence element. Since the attention mechanism relies on the computation of inner products between all pairs of elements in the sequence, its computational complexity increases quadratically with the sequence length. While the ability to consider interactions between all elements is the reason transformers efficiently learn long-range interactions, it is also the reason transformers quickly become infeasible, especially on images, where the sequence length itself scales quadratically with the resolution. Different approaches have been proposed to reduce the computational requirements to make transformers feasible for longer sequences. and restrict the receptive fields of the attention modules, which reduces the expressivity and, especially for high-resolution images, introduces assumptions on the independence of pixels. and retain the full receptive field but can reduce costs for a sequence of length only from to , which makes resolutions beyond pixels still prohibitively expensive.
Convolutional Approaches
The two-dimensional structure of images suggests that local interactions are particularly important. CNNs exploit this structure by restricting interactions between input variables to a local neighborhood defined by the kernel size of the convolutional kernel. Applying a kernel thus results in costs that scale linearly with the overall sequence length (the number of pixels in the case of images) and quadratically in the kernel size, which, in modern CNN architectures, is often fixed to a small constant such as . This inductive bias towards local interactions thus leads to efficient computations, but the wide range of specialized layers which are introduced into CNNs to handle different synthesis tasks suggest that this bias is often too restrictive.
Convolutional architectures have been used for autoregressive modeling of images but, for low-resolution images, previous works demonstrated that transformers consistently outperform their convolutional counterparts. Our approach allows us to efficiently model high-resolution images with transformers while retaining their advantages over state-of-the-art convolutional approaches.
Two-Stage Approaches
Closest to ours are two-stage approaches which first learn an encoding of data and afterwards learn, in a second stage, a probabilistic model of this encoding. demonstrated both theoretical and empirical evidence on the advantages of first learning a data representation with a Variational Autoencoder (VAE) , and then again learning its distribution with a VAE. demonstrate similar gains when using an unconditional normalizing flow for the second stage, and when using a conditional normalizing flow. To improve training efficiency of Generative Adversarial Networks (GANs), learns a GAN on representations of an autoencoder and on low-resolution wavelet coefficients which are then decoded to images with a learned generator.
presents the Vector Quantised Variational Autoencoder (VQVAE), an approach to learn discrete representations of images, and models their distribution autoregressively with a convolutional architecture. extends this approach to use a hierarchy of learned representations. However, these methods still rely on convolutional density estimation, which makes it difficult to capture long-range interactions in high-resolution images. models images autoregressively with transformers in order to evaluate the suitability of generative pretraining to learn image representations for downstream tasks. Since input resolutions of pixels are still quite computationally expensive , a VQVAE is used to encode images up to a resolution of . In an effort to keep the learned discrete representation as spatially invariant as possible with respect to the pixels, a shallow VQVAE with small receptive field is employed. In contrast, we demonstrate that a powerful first stage, which captures as much context as possible in the learned representation, is critical to enable efficient high-resolution image synthesis with transformers.
Approach
Our goal is to exploit the highly promising learning capabilities of transformer models and introduce them to high-resolution image synthesis up to the megapixel range. Previous work which applied transformers to image generation demonstrated promising results for images up to a size of pixels but, due to the quadratically increasing cost in sequence length, cannot simply be scaled to higher resolutions.
High-resolution image synthesis requires a model that understands the global composition of images, enabling it to generate locally realistic as well as globally consistent patterns. Therefore, instead of representing an image with pixels, we represent it as a composition of perceptually rich image constituents from a codebook. By learning an effective code, as described in Sec. 3.1, we can significantly reduce the description length of compositions, which allows us to efficiently model their global interrelations within images with a transformer architecture as described in Sec. 3.2. This approach, summarized in Fig. 2, is able to generate realistic and consistent high resolution images both in an unconditional and a conditional setting.
The reconstruction is then given by
Backpropagation through the non-differentiable quantization operation in Eq. (3) is achieved by a straight-through gradient estimator, which simply copies the gradients from the decoder to the encoder , such that the model and codebook can be trained end-to-end via the loss function
Here, is a reconstruction loss, denotes the stop-gradient operation, and is the so-called “commitment loss” .
Using transformers to represent images as a distribution over latent image constituents requires us to push the limits of compression and learn a rich codebook. To do so, we propose VQGAN, a variant of the original VQVAE, and use a discriminator and perceptual loss to keep good perceptual quality at increased compression rate. Note that this is in contrast to previous works which applied pixel-based and transformer-based autoregressive models on top of only a shallow quantization model. More specifically, we replace the loss used in for by a perceptual loss and introduce an adversarial training procedure with a patch-based discriminator that aims to differentiate between real and reconstructed images:
The complete objective for finding the optimal compression model then reads
where we compute the adaptive weight according to
where is the perceptual reconstruction loss , denotes the gradient of its input w.r.t. the last layer of the decoder, and is used for numerical stability. To aggregate context from everywhere, we apply a single attention layer on the lowest resolution. This training procedure significantly reduces the sequence length when unrolling the latent code and thereby enables the application of powerful transformer models.
2 Learning the Composition of Images with Transformers
By mapping indices of a sequence back to their corresponding codebook entries, is readily recovered and decoded to an image .
Thus, after choosing some ordering of the indices in , image-generation can be formulated as autoregressive next-index prediction: Given indices , the transformer learns to predict the distribution of possible next indices, i.e. to compute the likelihood of the full representation as . This allows us to directly maximize the log-likelihood of the data representations:
Conditioned Synthesis
In many image synthesis tasks a user demands control over the generation process by providing additional information from which an example shall be synthesized. This information, which we will call , could be a single label describing the overall image class or even another image itself. The task is then to learn the likelihood of the sequence given this information :
If the conditioning information has spatial extent, we first learn another VQGAN to obtain again an index-based representation with the newly obtained codebook Due to the autoregressive structure of the transformer, we can then simply prepend to and restrict the computation of the negative log-likelihood to entries . This “decoder-only” strategy has also been successfully used for text-summarization tasks .
Generating High-Resolution Images
The attention mechanism of the transformer puts limits on the sequence length of its inputs . While we can adapt the number of downsampling blocks of our VQGAN to reduce images of size to , we observe degradation of the reconstruction quality beyond a critical value of , which depends on the considered dataset. To generate images in the megapixel regime, we therefore have to work patch-wise and crop images to restrict the length of to a maximally feasible size during training. To sample images, we then use the transformer in a sliding-window manner as illustrated in Fig. 3. Our VQGAN ensures that the available context is still sufficient to faithfully model images, as long as either the statistics of the dataset are approximately spatially invariant or spatial conditioning information is available. In practice, this is not a restrictive requirement, because when it is violated, \ieunconditional image synthesis on aligned data, we can simply condition on image coordinates, similar to .
Experiments
This section evaluates the ability of our approach to retain the advantages of transformers over their convolutional counterparts (Sec. 4.1) while integrating the effectiveness of convolutional architectures to enable high-resolution image synthesis (Sec. 4.2). Furthermore, in Sec. 4.3, we investigate how codebook quality affects our approach. We close the analysis by providing a quantitative comparison to a wide range of existing approches for generative image synthesis in Sec. 4.4. Based on initial experiments, we usually set and train all subsequent transformer models to predict sequences of length , as this is the maximum feasible length to train a GPT2-medium architecture (307 M parameters) on a GPU with 12GB VRAM. More details on architectures and hyperparameters can be found in the appendix (Tab. 7 and Tab. 8).
Transformers show state-of-the-art results on a wide variety of tasks, including autoregressive image modeling. However, evaluations of previous works were limited to transformers working directly on (low-resolution) pixels , or to deliberately shallow pixel encodings . This raises the question if our approach retains the advantages of transformers over convolutional approaches.
To answer this question, we use a variety of conditional and unconditional tasks and compare the performance between our transformer-based approach and a convolutional approach. For each task, we train a VQGAN with downsampling blocks, and, if needed, another one for the conditioning information, and then train both a transformer and a PixelSNAIL model on the same representations, as the latter has been used in previous state-of-the-art two-stage approaches . For a thorough comparison, we vary the model capacities between 85M and 310M parameters and adjust the number of layers in each model to match one another. We observe that PixelSNAIL trains roughly twice as fast as the transformer and thus, for a fair comparison, report the negative log-likelihood both for the same amount of training time (P-SNAIL time) and for the same amount of training steps (P-SNAIL steps).
Tab. 1 reports results for unconditional image modeling on ImageNet (IN) , Restricted ImageNet (RIN) , consisting of a subset of animal classes from ImageNet, LSUN Churches and Towers (LSUN-CT) , and for conditional image modeling of RIN conditioned on depth maps obtained with the approach of (D-RIN) and of landscape images collected from Flickr conditioned on semantic layouts (S-FLCKR) obtained with the approach of . Note that for the semantic layouts, we train the first-stage using a cross-entropy reconstruction loss due to their discrete nature. The results shows that the transformer consistently outperforms PixelSNAIL across all tasks when trained for the same amount of time and the gap increases even further when trained for the same number of steps. These results demonstrate that gains of transformers carry over to our proposed two-stage setting.
2 A Unified Model for Image Synthesis Tasks
The versatility and generality of the transformer architecture makes it a promising candidate for image synthesis. In the conditional case, additional information such as class labels or segmentation maps are used and the goal is to learn the distribution of images as described in Eq. (10). Using the same setting as in Sec. 4.1 (i.e. image size , latent size ), we perform various conditional image synthesis experiments:
(i): Semantic image synthesis, where we condition on semantic segmentation masks of ADE20K , a web-scraped landscapes dataset (S-FLCKR) and COCO-Stuff . Results are depicted in Figure 4, 5 and Fig. 6.
(ii): Structure-to-image, where we use either depth or edge information to synthesize images from both RIN and IN (see Sec. 4.1). The resulting depth-to-image and edge-to-image translations are visualized in Fig. 4 and Fig. 6.
(iii): Pose-guided synthesis: Instead of using the semantically rich information of either segmentation or depth maps, Fig. 4 shows that the same approach as for the previous experiments can be used to build a shape-conditional generative model on the DeepFashion dataset.
(iv): Stochastic superresolution, where low-resolution images serve as the conditioning information and are thereby upsampled. We train our model for an upsampling factor of 8 on ImageNet and show results in Fig. 6.
(v): Class-conditional image synthesis: Here, the conditioning information is a single index describing the class label of interest. Results for the RIN and IN dataset are demonstrated in Fig. 4 and Fig. 8, respectively.
All of these examples make use of the same methodology. Instead of requiring task specific architectures or modules, the flexibility of the transformer allows us to learn appropriate interactions for each task, while the VQGAN — which can be reused across different tasks — leads to short sequence lengths. In combination, the presented approach can be understood as an efficient, general purpose mechanism for conditional image synthesis. Note that additional results for each experiment can be found in the appendix, Sec. D.
The sliding window approach introduced in Sec. 3.2 enables image synthesis beyond a resolution of pixels. We evaluate this approach on unconditional image generation on LSUN-CT and FacesHQ (see Sec. 4.3) and conditional synthesis on D-RIN, COCO-Stuff and S-FLCKR, where we show results in Fig. Taming Transformers for High-Resolution Image Synthesis, 6 and the supplementary (Fig. 29-39). Note that this approach can in principle be used to generate images of arbitrary ratio and size, given that the image statistics of the dataset of interest are approximately spatially invariant or spatial information is available. Impressive results can be achieved by applying this method to image generation from semantic layouts on S-FLCKR, where a strong VQGAN can be learned with , so that its codebook together with the conditioning information provides the transformer with enough context for image generation in the megapixel regime.
3 Building Context-Rich Vocabularies
How important are context-rich vocabularies? To investigate this question, we ran experiments where the transformer architecture is kept fixed while the amount of context encoded into the representation of the first stage is varied through the number of downsampling blocks of our VQGAN. We specify the amount of context encoded in terms of reduction factor in the side-length between image inputs and the resulting representations, \iea first stage encoding images of size into discrete codes of size is denoted by a factor . For , we reproduce the approach of and replace our VQGAN by a k-means clustering of RGB values with . During training, we always crop images to obtain inputs of size for the transformer, \iewhen modeling images with a factor in the first stage, we use crops of size . To sample from the models, we always apply them in a sliding window manner as described in Sec. 3.
Results Fig. 7 shows results for unconditional synthesis of faces on FacesHQ, the combination of CelebA-HQ and FFHQ . It clearly demonstrates the benefits of powerful VQGANs by increasing the effective receptive field of the transformer. For small receptive fields, or equivalently small , the model cannot capture coherent structures. For an intermediate value of , the overall structure of images can be approximated, but inconsistencies of facial features such as a half-bearded face and of viewpoints in different parts of the image arise. Only our full setting of can synthesize high-fidelity samples. For analogous results in the conditional setting on S-FLCKR, we refer to the appendix (Fig. 13 and Sec. C).
To assess the effectiveness of our approach quantitatively, we compare results between training a transformer directly on pixels, and training it on top of a VQGAN’s latent code with , given a fixed computational budget. Again, we follow and learn a dictionary of RGB values on CIFAR10 to operate directly on pixel space and train the same transformer architecture on top of our VQGAN with a latent code of size . We observe improvements of for FIDs and faster sampling of images.
4 Benchmarking Image Synthesis Results
In this section we investigate how our approach quantitatively compares to existing models for generative image synthesis. In particular, we assess the performance of our model in terms of FID and compare to a variety of established models (GANs, VAEs, Flows, AR, Hybrid). The results on semantic synthesis are shown in Tab. 2, where we compare to , and the results on unconditional face synthesis are shown in Tab. 3. While some task-specialized GAN models report better FID scores, our approach provides a unified model that works well across a wide range of tasks while retaining the ability to encode and reconstruct images. It thereby bridges the gap between purely adversarial and likelihood-based approaches.
Autoregressive models are typically sampled with a decoding strategy such as beam-search, top-k or nucleus sampling. For most of our results, including those in Tab. 2, we use top-k sampling with unless stated otherwise. For the results on face synthesis in Tab. 3, we computed scores for and report the best results, obtained with for CelebA-HQ and for FFHQ. Fig. 10 in the supplementary shows FID and Inception scores as a function of .
To address a direct comparison with the previous state-of-the-art for autoregressive modeling of class-conditional image synthesis on ImageNet, VQVAE-2 , we train a class-conditional ImageNet transformer on images, using a VQGAN with and , and additionally compare to BigGAN , IDDPM , DCTransformer and ADM in Tab. 4. Note that our model uses less parameters than VQVAE-2, which has an estimated parameter count of (estimate based on ).
Samples of this model for different ImageNet classes are shown in Fig. 8. We observe that the adversarial training of the corresponding VQGAN enables sampling of high-quality images with realistic textures, of comparable or higher quality than existing approaches such as BigGAN and VQVAE-2, see also Fig. 14-17 in the supplementary.
Quantitative results are summarized in Tab. 4. We report FID and Inception Scores for the best / in top-k/top-p sampling. Following , we can further increase quality via classifier-rejection, which keeps only the best -out-of- samples in terms of the classifier’s score, \iewith an acceptance rate of . We use a ResNet-101 classifier .
We observe that our model outperforms other autoregressive approaches (VQVAE-2, DCTransformer) in terms of FID and IS, surpasses BigGAN and IDDPM even for low rejection rates and yields scores close to the state of the art for higher rejection rates, see also Fig. 9.
How good is the VQGAN?
Reconstruction FIDs obtained via the codebook provide an estimate on the achievable FID of the generative model trained on it. To quantify the performance gains of our VQGAN over discrete VAEs trained without perceptual and adversarial losses (\egVQVAE-2, DALL-E ), we evaluate this metric on ImageNet and report results in Tab. 5. Our VQGAN outperforms non-adversarial models while providing significantly more compression (seq. length of vs. for VQVAE-2, vs for DALL-E). As expected, larger versions of VQGAN (either in terms of larger codebook sizes or increased code lengths) further improve performance. Using the same hierarchical codebook setting as in VQVAE-2 with our model provides the best reconstruction FID, albeit at the cost of a very long and thus impractical sequence. The qualitative comparison corresponding to the results in Tab. 5 can be found in Fig. 12.
Conclusion
This paper adressed the fundamental challenges that previously confined transformers to low-resolution images. We proposed an approach which represents images as a composition of perceptually rich image constituents and thereby overcomes the infeasible quadratic complexity when modeling images directly in pixel space. Modeling constituents with a CNN architecture and their compositions with a transformer architecture taps into the full potential of their complementary strengths and thereby allowed us to represent the first results on high-resolution image synthesis with a transformer-based architecture. In experiments, our approach demonstrates the efficiency of convolutional inductive biases and the expressivity of transformers by synthesizing images in the megapixel range and outperforming state-of-the-art convolutional approaches. Equipped with a general mechanism for conditional synthesis, it offers many opportunities for novel neural rendering approaches.
Taming Transformers for High-Resolution Image Synthesis
The supplementary material for our work Taming Transformers for High-Resolution Image Synthesis is structured as follows: First, Sec. A summarizes changes to a previous version of this paper. In Sec. B, we present hyperparameters and architectures which were used to train our models. Next, extending the discussion of Sec. 4.3, Sec. C presents additional evidence for the importance of perceptually rich codebooks and its interpretation as a trade-off between reconstruction fidelity and sampling capability. Additional results on high-resolution image synthesis for a wide range of tasks are then presented in Sec. D, and Sec. E shows nearest neighbors of samples. Finally, Sec. F contains results regarding the ordering of image representations.
Appendix A Changelog
We summarize changes between this version https://arxiv.org/abs/2012.09841v3 of the paper and its previous version https://arxiv.org/abs/2012.09841v2.
In the previous version, Eq. (4) had a weighting term on the commitment loss, and Tab. 8 reported a value of for all models. However, due to a bug in the implementation, was never used and all models have been trained with . Thus, we removed in Eq. (4).
We updated class-conditional synthesis results on ImageNet in Sec. 4.4. The previous results, included here in Tab. 6 for completeness, were based on a slightly different implementation where the transformer did not predict the distribution of the first token but used a histogram for it. The new model has been trained for 2.4 million steps with a batch size of 16 accumulated over 8 batches, which took 45.8 days on a single A100 GPU. The previous model had been trained for 1.0 million steps. Furthermore, the FID values were based on 50k (18k) samples against 50k (18k) training examples (to compare with MSP). For better comparison with other works, the current version reports FIDs based on 50k samples against all training examples of ImageNet using torch-fidelity . We updated all qualitative figures showing samples from this model and added visualizations of the effect of tuning top-/ or rejection rate in Fig. 14-26.
To provide a better overview, we also include results from works that became available after the previous version of our work. Specifically, we include results on reconstruction quality of the VQVAE from in Tab. 5 and Fig. 12 (which replaces the previous qualitative comparison), and results on class-conditional ImageNet sampling from in Tab. 4. Note that with the exception of BigGAN and BigGAN-deep , no models or sampling results are available for the methods we compare to in Tab. 4. Thus, we can only report the numbers from the respective papers but cannot re-evaluate them with the same code. We follow the common evaluation protocol for class-conditional ImageNet synthesis from and evaluate 50k samples from the model against the whole training split of ImageNet. However, it is not clear how different implementations resize the training images. In our code, we use the largest center-crop and resize it bilinearly with anti-aliasing to using Pillow . FID and Inception Scores are then computed with torch-fidelity .
We updated face-synthesis results in Tab. 3 based on a slightly different implementation as in the case of class-conditional ImageNet results and improve the previous results slightly. In addition, we evaluate the ability of our NLL-based training to detect overfitting. We train larger models (FFHQ (big) and CelebA-HQ (big) in Tab. 8) on the face datasets, and show nearest neighbors of samples obtained from checkpoints with the best NLL on the validation split and the training split in Sec. E. We also added Fig. 10, which visualizes the effect of tuning in top-k sampling on FID and IS.
Appendix B Implementation Details
The hyperparameters for all experiments presented in the main paper and supplementary material can be found in Tab. 8. Except for the c-IN (big), COCO-Stuff and ADE20K models, these hyperparameters are set such that each transformer model can be trained with a batch-size of at least 2 on a GPU with 12GB VRAM, but we generally train on 2-4 GPUs with an accumulated VRAM of 48 GB. If hardware permits, 16-bit precision training is enabled.
The architecture of our convolutional encoder and decoder models used in the VQGAN experiments is described in Tab. 7. Note that we adopt the compression rate by tuning the number of downsampling steps . Further note that in Eq. 5 is set to zero in an initial warm-up phase. Empirically, we found that longer warm-ups generally lead to better reconstructions. As a rule of thumb, we recommend setting for at least one epoch.
Transformer Architecture
Our transformer model is identical to the GPT2 architecture and we vary its capacity mainly through varying the amount of layers (see Tab. 8). Furthermore, we generally produce samples with a temperature and a top- cutoff at (with higher top- values for larger codebooks).
Appendix C On Context-Rich Vocabularies
Sec. 4.3 investigated the effect of the downsampling factor used for encoding images. As demonstrated in Fig. 7, large factors are crucial for our approach, since they enable the transformer to model long-range interactions efficiently. However, since larger correspond to larger compression rates, the reconstruction quality of the VQGAN starts to decrease after a certain point, which is analyzed in Fig. 11. The left part shows the reconstruction error (measured by LPIPS ) versus the negative log-likelihood obtained by the transformer for values of ranging from to . The latter provides a measure of the ability to model the distribution of the image representation, which increases with . The reconstruction error on the other hand decreases with and the qualitative results on the right part show that beyond a critical value of , in this case , reconstruction errors become severe. At this point, even when the image representations are modeled faithfully, as suggested by a low negative log-likelihood, sampled images are of low-fidelity, because the reconstruction capabilities provide an upper bound on the quality that can be achieved.
Hence, Fig. 11 shows that we must learn perceptually rich encodings, \ieencodings with a large and perceptually faithful reconstructions. This is the goal of our VQGAN and Fig. 12 compares its reconstruction capabilities against the VQVAE used in DALL-E . We observe that for and codebook entries, both the VQVAE and VQGAN capture the global structure faithfully. However, the textures produced by the VQVAE are blurry, whereas those of the VQGAN are crisp and realistic looking (\egthe stone texture and the fur and tail of the squirrel). When we increase the compression rate of the VQGAN further to , we see that some reconstructed parts are not perfectly aligned with the input anymore (\egthe paw of the squirrel), but, especially with slightly larger codebooks, the reconstructions still look realistic. This demonstrates how the VQGAN provides high-fidelity reconstructions at large factors, and thereby enables efficient high-resolution image synthesis with transformers.
To illustrate how the choice of depends on the dataset, Fig. 13 presents results on S-FLCKR. In the left part, it shows, analogous to Fig. 7, how the quality of samples increases with increasing . However, in the right part, it shows that reconstructions remain faithful perceptually faithful even for , which is in contrast to the corresponding results on faces in Fig. 11. These results might be explained by a higher perceptual sensitivity to facial features as compared to textures, and allow us to generate high-resolution landscapes even more efficiently with .
Appendix D Additional Results
The qualitative comparison corresponding to Tab. 4 and Tab. 6 can be found in Fig. 14, 15, 16 and 17. Since no models are available for VQVAE-2 and MSP, we extracted results directly from the supplementaryhttps://drive.google.com/file/d/1H2nr_Cu7OK18tRemsWn_6o5DGMNYentM/view?usp=sharing and from the provided sampleshttps://bit.ly/2FJkvhJ, respectively. For BigGAN, we produced the samples via the provided modelhttps://tfhub.dev/deepmind/biggan-deep-256/1. Similarly, the qualitative comparison with the best competitor model (SPADE) for semantic synthesis on standard benchmarks (see Tab. 2) can be found in Fig. 40 (ADE20K) and Fig. 41 (COCO-Stuff)samples were reproduced with the authors’ official implementation available at https://github.com/nvlabs/spade/.
Comparison to Image-GPT
To further evaluate the effectiveness of our approach, we compare to the state-of-the-art generative transformer model on images, ImageGPT . By using immense amounts of compute the authors demonstrated that transformer models can be applied to the pixel-representation of images and thereby achieved impressive results both in representation learning and image synthesis. However, as their approach is confined to pixel-space, it does not scale beyond a resolution of . As our approach leverages a strong compression method to obtain context-rich representations of images and then learns a transformer model, we can synthesize images of much higher resolution. We compare both approaches in Fig. 27 and Fig. 28, where completions of images are depicted. Both plots show that our approach is able to synthesize consistent completions of dramatically increased fidelity. The results of are obtained from https://openai.com/blog/image-gpt/.
Additional High-Resolution Results
Fig. 29, 30, 31 and Fig. 32 contain additional HR results on the S-FLCKR dataset for both () and () (semantically guided). In particular, we provide an enlarged version of Fig. 5 from the main text, which had to be scaled down due to space constraints. Additionally, we use our sliding window approach (see Sec. 3) to produce high-resolution samples for the depth-to-image setting on RIN in Fig. 33 and Fig. 34, edge-to-image on IN in Fig. 35, stochastic superresolution on IN in Fig. 36, more examples on semantically guided landscape synthesis on S-FLCKR in Fig. 37 with and in Fig. 38 with , and unconditional image generation on LSUN-CT (see Sec. 4.1) in Fig. 39. Moreover, for images of size , we provide results for generation from semantic layout on (i) ADE20K in Fig. 40 and (ii) COCO-Stuff in Fig. 41, depth-to-image on IN in Fig. 42, pose-guided person generation in Fig. 43 and class-conditional synthesis on RIN in Fig. 44.
Appendix E Nearest Neighbors of Samples
One advantage of likelihood-based generative models over, \eg, GANs is the ability to evaluate NLL on training data and validation data to detect overfitting. To test this, we trained large models for face synthesis, which can easily overfit them, and retained two checkpoints on each dataset: One for the best validation NLL (at the 10th and 13th epoch for FFHQ and CelebA-HQ, respectively), and another for the best training NLL (at epoch 1000). We then produced samples from both checkpoints and retrieved nearest neighbors from the training data based on the LPIPS similarity metric . The results are shown in Fig. 45, where it can be observed that the checkpoints with best training NLL (best train NLL) reproduce the training examples, whereas samples from the checkpoints with best validation NLL (best val. NLL) depict new faces which are not found in the training data.
Based on these results, we can conclude that early-stopping based on validation NLL can prevent overfitting. Furthermore, the bottleneck for our approach on face synthesis is given by the dataset size since it has the capacity to almost perfectly fit the training data. Unfortunately, FID scores cannot detect such an overfitting. Indeed, the best train NLL checkpoints achieve FID scores of 3.86 on CelebA-HQ and 2.68 on FFHQ, compared to 10.2 and 9.6 for the best val. NLL checkpoints. While validation NLL provides a way to detect overfitting for likelihood-based models, it is not clear if early-stopping based on it is optimal if one is mainly interested in the quality of samples. To address this and the evaluation of GANs, new metrics will be required which can differentiate between models that produce new, high-quality samples and those that simply reproduce the training data.
Our class-conditional ImageNet model does not display overfitting according to validation NLL, and the nearest neighbors shown in Fig. 46 also provide evidence that the model produces new, high-quality samples.
Appendix F On the Ordering of Image Representations
For the “classical” domain of transformer models, NLP, the order of tokens is defined by the language at hand. For images and their discrete representations, in contrast, it is not clear which linear ordering to use. In particular, our sliding-window approach depends on a row-major ordering and we thus investigate the performance of the following five different permutations of the input sequence of codebook indices: (i) row major, or raster scan order, where the image representation is unrolled from top left to bottom right. (ii) spiral out, which incorporates the prior assumption that most images show a centered object. (iii) z-curve, also known as z-order or morton curve, which introduces the prior of preserved locality when mapping a 2D image representation onto a 1D sequence. (iv) subsample, where prefixes correspond to subsampled representations, see also . (v) alternate, which is related to row major, but alternates the direction of unrolling every row. (vi) spiral in, a reversed version of spiral out which provides the most context for predicting the center of the image. A graphical visualization of these permutation variants is shown in Fig. 47. Given a VQGAN trained on ImageNet, we train a transformer for each permutation in a controlled setting, i.e. we fix initialization and computational budget.
Fig.47 depicts the evolution of negative log-likelihood for each variant as a function of training iterations, with final values given by (i) 4.767, (ii) 4.889, (iii) 4.810, (iv) 5.015, (v) 4.812, (vi) 4.901. Interestingly, row major performs best in terms of this metric, whereas the more hierarchical subsample prior does not induce any helpful bias. We also include qualitative samples in Fig. 48 and observe that the two worst performing models in terms of NLL (subsample and spiral in) tend to produce more textural samples, while the other variants synthesize samples with much more recognizable structures. Overall, we can conclude that the autoregressive codebook modeling is not permutation-invariant, but the common row major ordering outperforms other orderings.