{'fraction_non_alphanumeric': 0.03525046382189239, 'fraction_numerical': 0.013153780408997102, 'mean_word_length': 5.031179280864974, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Enhancing Photorealism Enhancement

We present an approach to enhancing the realism of synthetic images. The images are enhanced by a convolutional network that leverages intermediate representations produced by conventional rendering pipelines. The network is trained via a novel adversarial objective, which provides strong supervision at multiple perceptual levels. We analyze scene layout distributions in commonly used datasets and find that they differ in important ways. We hypothesize that this is one of the causes of strong artifacts that can be observed in the results of many prior methods. To address this we propose a new strategy for sampling image patches during training. We also introduce multiple architectural improvements in the deep network modules used for photorealism enhancement. We confirm the benefits of our contributions in controlled experiments and report substantial gains in stability and realism in comparison to recent image-to-image translation methods and a variety of other baselines.


P H O T O R E A L I S M has been the defining goal of computer
graphics for half a century. In 1977, Newell and Blinn [1] surveyed a decade of work on this problem. In the ensuing four decades, substantial further progress has been made, due in part to physically based simulation of light transport [2], principled representation of material appearance [3], [4], and photogrammetric modeling [5]. These techniques and their approximations have been integrated into realtime rendering pipelines, substantially advancing the realism of computer games [6]. Nevertheless, a look at even the most sophisticated real-time games will quickly reveal that photorealism has not been achieved. An ineffable difference in the appearance of simulation and reality remains.
In recent years, a complementary set of techniques has been developed in computer vision and machine learning. These techniques, based on deep learning, convolutional networks, and adversarial training, bypass physical modeling of geometric layout, material appearance, and light transport. Instead, images are synthesized by convolutional networks trained on large datasets. These techniques have been used to synthesize representative images from a given domain [7], [8], [9], to convert semantic label maps to photographic images [10], [11], [12], [13], [14], [15], [16], and to attempt to bridge the appearance gap between synthetic and real images [17], [18], [19], [20], [21], [22], [23], [24], [25]. Images synthesized by these approaches capture aspects of photographic appearance that often elude even state-of-theart computer games. On the flip side, these approaches are largely disconnected from the rendering pipelines that drive computer games, can be hard to control, and often produce jarring artifacts that would be unacceptable in productionquality media.
In this work, we take a step towards melding these two complementary routes to photorealism. We seek to build on the infrastructure developed in the production of modern games and enhance their photorealism via techniques developed in the deep learning community. Our starting point is a set of intermediate buffers (G-buffers) produced by game engines during the rendering process [6], [26]. These buffers provide detailed information on geometry, materials, and lighting in the scene. We train convolutional networks with these auxiliary inputs to enhance the realism of images produced by the rendering pipeline. To integrate these buffers into the photorealism enhancement flow, we design new network components that modulate features from a rendered image according to information extracted from the buffers.
We also seek to eliminate artifacts that can be seen in the results of prior deep-learning approaches, which often hallucinate objects. To this end, we analyze the datasets that are commonly used for photorealism enhancement. Our analysis reveals that their scene layouts differ in ways that can explain artifacts commonly seen in prior work. To better align the datasets and alleviate the artifacts, we propose a new strategy for sampling image patches during training. We further design a new adversarial training objective that facilitates enhancements that are geometrically and semantically consistent with the content of the input image.
Combining all of our contributions, our approach significantly enhances the photorealism of rendered images (Fig. 1). It can add gloss to cars (1 st row), green parched hills (2 nd row), and rebuild roads (3 rd row). Training it with different real-world image collections (e.g., Cityscapes [28], KITTI [29], or Mapillary Vistas [30]) expresses the corresponding visual styles in the output (Fig. 2).
Our analysis further suggests that standard metrics confound differences in style and content. Motivated by this observation, we develop a new family of metrics that mitigate the effect of mismatched scene layouts and provide a finer-grained assessment of realism at multiple levels.
We compare the presented approach against a broad array of strong baselines that represent diverse perspectives on photorealism enhancement. We also conduct a perceptual experiment to assess photorealism. The results indicate that our approach consistently produces the most realistic results, by a wide margin. In all experiments, our approach outperforms all baselines and sets a new state of the art in photorealism enhancement.

R E L AT E D W O R K
Photorealistic images can be synthesized by simulating all the physical processes involved in image formation. However, this simulation is computationally expensive, may not be feasible at interactive rates, and requires physically accurate arXiv:2105.04619v1 [cs.CV] 10 May 2021 Rendered images from GTA V Enhancement by our method (trained to mimic Cityscapes) Fig. 1. We train convolutional networks to enhance the photorealism of rendered images, using intermediate buffers produced by a conventional rendering engine. Left: frames from a modern computer game (GTA V) [27]. Right: same frames enhanced by our approach to mimic the style of Cityscapes [28]. Enhancements by our method are semantically consistent and non-trivial. For example, our method adds gloss to cars (1 st row), reforests parched hills to mimic German climate (2 nd row), and paves roads with smoother asphalt (3 rd row). Insets magnify marked regions. models of scenes, objects, materials, and lighting. As a result, a variety of approximations have been developed that generate images that may not be physically correct, but nevertheless appear realistic to varying extents [6], [31].
Methods for conditional image synthesis aim to learn the complete image formation process from data [10], [11], [12], [14], [32], [33], [34], [35]. These works often focus on synthesizing images from semantic label maps. As such, the synthesis is severely underconstrained. Since geometric structure is only provided through the silhouettes of objects and their composition in the label map, substantial ambiguity remains, leading to visible artifacts and temporal inconsistency. Furthermore, the reliance on semantic label maps requires annotated real-world data, which is extremely laborious to create at large scale [28]. Instead of trying to synthesize images, our approach enhances already rendered images, integrates scene information to produce geometrically and semantically consistent images, and does not require any annotation of real data.
Image-based rendering techniques can produce results that are indistinguishable from photographs by recycling real imagery of a scene for rendering novel views [36], [37], [38], [39], [40], [41], [42], [43], [44]. However, they require capturing photos of the scene of interest beforehand and make it difficult to manipulate captured scenes afterward. Furthermore, novel views need to be fairly close to the prerecorded camera trajectory to avoid artifacts.
Another promising direction combines traditional rendering with data-driven approaches. Johnson et al. proposed to improve the realism of rendered images by transferring nearest neighbor patches from similarly structured photographs [45]. Liao et al. retrieved nearest neighbor patches in a learned feature space [46]. Reinhard et al. matched color distributions of a source image to a target image [47] and showed that this can enhance the realism of computer graphics images. Subsequent work introduced increasingly sophisticated techniques for photographic style transfer between images [18], [48], [49], [50], [51], [52], [53], [54]. While early CNN-based methods required costly optimization per image [55], improvements in feature normalization reduced computation [56], enabled transfer to new styles [57], and increased semantic consistency [14], [34], [35]. Recent work has focused on encoder/decoder structures, mixing content and style of source and target images [53], [58]. Common to all style-transfer and example-based approaches [24] is the dependence on a favorable reference image. Differences in content or layout between rendered and reference images hurt the quality of enhanced images. This is especially problematic for enhancing dynamic content. Our approach learns the style from an image collection through adversarial training and does not require reference images for enhancement.
Our approach is aligned with work on unpaired imageto-image translation, which learns a mapping from one image collection to another [19], [20], [21], [59], [60]. By training on large datasets, these methods do not depend on favorable reference images, and often learn to capture the unique styles of datasets very well. However, as there are no direct correspondences across image collections (e.g., through paired images), the methods need to learn suitable correspondences implicitly. This is challenging and often produces images that appear realistic at first glance, but contain artifacts that are inconsistent with the input images. Improving the consistency between input and output has received a lot of attention and led to additional constraints on this ill-defined problem. Notable improvements came from cycle-consistency [59], [61], custom attention modules [62], temporal regularization [63], modeling sensor noise [64], geometric constraints in the image plane [65], constraints derived from depth maps [66], and contrastive losses [60].
Many approaches to image synthesis or translation have employed adversarial objectives, which involve a discriminator network that evaluates the realism of generated images. The discriminator is commonly trained alongside a network performing the image generation [10], [59]. One intention of this setup is for the discriminator to learn high-level semantic concepts to provide high-quality supervision to the generator network. However, with a simple binary classification objective, the discriminator may focus on low-level textures and patches instead, since these already provide discriminative features. To direct attention to highlevel semantic content, a number of modifications have been proposed. For example, the binary real vs. fake decision can be accompanied by a classification objective [67], [68]. Additional semantic segmentation maps can be concatenated to the input image [12], [69], projected to a highdimensional feature space [8], [15], [70], or processed via a separate network stream [71]. These works use groundtruth annotations for guiding the discriminator. While this provides ground-truth semantic information, it restricts the image collections available for training to densely annotated datasets compatible with the synthetic label maps at hand. In our work, we leverage a robust semantic segmentation network [72] to provide label maps that are approximately consistent for synthetic and real images. Previously, Hoffman et al. used a segmentation network for synthetic-to-real translation [19]. In contrast to prior work [19], [23], we neither train the segmentation network on any of our datasets nor apply it to enhanced images. This is for two reasons. First, training a segmentation network on synthetic data is prone to overfitting. Thus a network trained in this way may not provide semantically consistent guidance for the transition from synthetic to real images during the training of the generator. Second, incorporating a segmentation network during training can result in generated images that are easy for the segmentation network to parse but are not necessarily more realistic.
Providing the discriminator with additional semantic information supports adaptive processing for different semantic categories. Incorporating the information into the learning objective is an even stronger type of supervision, as the distinction between different objects is explicitly learned. However, datasets that are commonly used in syntheticto-real translation are limited in their diversity, especially in the context of urban driving [27], [28], [73]. Thus highcapacity networks may overfit to spurious artifacts in the data, leading to suboptimal performance of the generator [74], [75]. Prior research addressed this overfitting via regularization [76], [77] or augmentation [74]. We take inspiration from the neural patch discriminator of Li and Wand [78] and train our discriminator on feature maps from a pretrained VGG network. In contrast to the single-image style transfer approach of Li and Wand, we use multiple feature maps extracted from different layers of the VGG network, and train a discriminator on each.
Prior work hypothesized that differences in scene layout may be a key contributing factor in suboptimal performance in image translation [19] or in training semantic segmentation models [79], [80], and addressed this challenge via regularization [76], semantic consistency losses [19], [81], and matching source and target images [79]. Akin to the work of Li et al. on semantic segmentation [79], we address the layout mismatch via semantics-aware sampling. However, Li et al. train a dedicated network for matching samples across datasets at image level, which significantly reduces the samples available for training, and hence diversity. We devise a simpler sampling strategy that requires no training and operates at the patch level, leaving sufficiently many diverse samples for training.
Our work is inspired by hybrid approaches that integrate the conventional rendering pipeline in a more structured way, such that information about a scene generated during rendering can be subsequently exploited by a learning-based approach. Nalbach et al. demonstrated that a CNN can learn to shade G-buffers rendered by a conventional rendering pipeline [82]. AlHaija et al. combined this approach with an adversarial loss to improve the realism of rendered images [83]. We introduce a different network structure that better integrates the G-buffers, as well as a new discriminator architecture and training objective, leading to significantly better results.
Bi et al. developed a pipeline that enhanced the realism of low-quality renderings of indoor scenes [84]. Their approach relies on the availability of paired low-quality and highquality renderings of the same scenes, involves a number of synthesis stages with different losses, and produces results of limited fidelity. Our work is different in several ways. We assume higher-quality input, as produced by modern computer games. We do not rely on the availability of rendered images at different levels of quality, but do utilize auxiliary buffers produced by rendering engines. Our approach also differs in the network architecture, training objectives, and the application domain. We demonstrate significantly better results, with temporal consistency and measurably higher realism than high-production-value commercial games.

Overview
Fig. 3 provides an overview of our approach. Our method consists of an image enhancement network, which takes as input a rendered image and outputs an enhanced image. To facilitate the enhancement, we provide additional inputs to the network. Specifically, we extract intermediate rendering buffers (G-buffers) from the graphics pipeline. These Gbuffers provide information on the geometry, materials, and lighting in the scene. The G-buffers are processed by a Gbuffer encoder network, which outputs G-buffer features at multiple scales. This is described in Sec. 3.2. The Gbuffer features are then provided as input to the image enhancement network, where they are used to modulate image features. The image enhancement network is based on HRNetV2, which demonstrated strong performance on a variety of dense prediction tasks [86] (see Fig. 4). The HRNet processes an image via multiple branches that operate at different resolutions. Importantly, one feature stream is kept at relatively high resolution ( 1 4 of the input resolution) to preserve fine image structure. We modify the HRNet architecture as follows. First, we replace the initial strided convolutions by regular convolutions to have the network operate on the full resolution and preserve even finer detail. Second, within the residual blocks in each branch we replace the batch normalization layers by rendering-aware denormalization (RAD) modules, described in Sec. 3.2. The modified blocks modulate the feature streams based on information extracted from the G-buffers.
The image enhancement network is trained with two objectives. First, an LPIPS loss [87] penalizes large structural differences between the input and output images. Second, a perceptual discriminator evaluates the realism of output images. The discriminator, described in Sec. 3.3, is trained to distinguish images enhanced by our network and real photographs from a target dataset. During training, a specific sampling strategy for selecting real and synthetic image patches is used to significantly reduce artifacts that are  Fig. 4. Image enhancement network. We replace the batch normalization layers within HRNet by rendering-aware denormalization (RAD), forming RAD blocks (RB). Each branch of the HRNet receives a G-buffer feature tensor at a matching scale (different scales are coded by color). Original feature streams are shown in gray. We omit initial stem convolutions as well as transition and fusion layers for clarity.
commonly observed in prior work. This is described in Sec. 3.4.

Leveraging conventional rendering pipelines
Many real-time rendering methods factor the rendering process into multiple passes. A particularly popular approach is deferred shading or deferred lighting, which decouples visibility and shading computations by caching intermediate rendering results in image-sized G-buffers [6], [26], [88], [89]. Although G-buffers generally contain no explicit semantic information, they are consistent with semantic entities [27], [90]. Since they capture geometry and material properties, using them as auxiliary input allows a network to condition the synthetic-to-real translation on the geometry, materials, and illumination of a scene.

Extraction of G-buffers.
We base our work on the popular game Grand Theft Auto V. To obtain G-buffers from the game, we follow recent approaches to extracting rendering resources from computer games [27], [85], [91]. Specifically, we extract G-buffers that provide information about geometric structure (surface normals, depth), materials (shader IDs, albedo, specular intensity, glossiness, transparency), and lighting (approximate irradiance and emission, sky, bloom). Some of these are illustrated in Fig. 5. We further augment this set with two quantities we derive from the G-buffers. First, we reflect for each pixel the view vector at the surface normal to obtain a reflection vector. Second, we compute the dot product between the surface normal and the reflection vector.
While we extract an extensive set of G-buffers for providing comprehensive information about the scene to the generator network for best results, our experiments in Sec. 4.4 confirm that substantial enhancements can be achieved even if only a subset of the buffers is available.
G-buffer encoder. The G-buffers we extract mix one-hot encodings for material information, dense continuous values for normals, depth, and color, and sparse continuous information for bloom and sky buffers. For some image regions the G-buffers are zero, depending on the objects being rendered. Sky regions, for example, contain no geometry and material information. And transparent regions and highlights are only present for a small number of objects.  Fig. 6. G-buffer encoder. The G-buffer encoder accounts for different data types and varying spatial density of the G-buffers. It processes them via multiple streams (0-c), which are fused into a joint representation in accordance with one-hot-encoded object IDs. The features are further transformed via residual blocks (see Fig. 7), of which the orange blocks downscale the tensors. The output scale of the feature tensors is red, the channel width is blue. Scales match with branches in the image enhancement network.
To account for the different types of data in the G-buffers, we process the G-buffers via a G-buffer encoder (Fig. 6). The G-buffer encoder consists of multiple network streams that process the same set of G-buffers. Each stream comprises two residual blocks, shown in Fig. 7.
Let f c denote a feature tensor from a stream targeting object class c, and let m c denote a mask for objects of that class. We then fuse the tensors via c m c · f c .  Fig. 7. Residual blocks. We employ residual blocks in the G-buffer encoder and RAD modules. The blocks consist of convolutional layers (kernel size 3) with spectral normalization [92] and ReLUs. Changes in channel width or downscaling are performed in Conv 1 and Conv P. If channel width and resolution are constant, the projection via Conv P is omitted.

G-bu er features
Image features  Fig. 8. Rendering-aware denormalization (RAD) modulates image feature tensors via encoded geometry, material, lighting, and semantic information from a conventional rendering pipeline. The image features are normalized via group normalization, then scaled and shifted via perelement weights γ, β. The weights are learned and adapt to G-buffer features received from the G-buffer encoder (Fig. 6). To better adapt the weights, we transform the G-buffer features via three residual blocks within each RAD module.
The object IDs group multiple class labels from semantic segmentation maps (e.g., all vehicle classes are mapped to the same ID to reduce the number of separate network streams). This way, the streams can map information from the Gbuffers differently for certain types of objects. The fused feature tensors are further processed via residual blocks. We extract a feature tensor before each downsampling residual block to obtain tensors at multiple scales. The feature tensors are ingested by the image enhancement network via RAD modules.

Rendering-Aware Denormalization (RAD).
Our renderingaware denormalization modules take inspiration from recent work on modulating feature tensors based on external information [9], [14], [34], [35]. In contrast to prior work, which conditions on semantic classes [14], style features [34], [35], optical flow [16], or noise [9], our modules learn weights from a comprehensive scene representation. Specifically, our modules transform a feature tensor received from the Gbuffer encoder network via 2 residual blocks (Fig. 7). The transformed features are used to learn elementwise scale and shift weights γ and β. The weights represent the parameters of an affine transformation of normalized image features (Fig. 8).
Controlled experiments reported in Sec. 4.4 confirm that RAD modules deliver better results than SPADE [14] when applied to ingesting G-buffer features into the image enhancement network.  Fig. 9. Perceptual discriminator. Realism of enhanced images is evaluated via a perceptual discriminator. It consists of pretrained robust segmentation (MSeg [72]) and perceptual (VGG [93]) networks. These provide high-level semantic information via label maps and perceptual feature tensors. The maps and tensors are ingested by discriminator networks, which produce a realism score map. For clarity, we only show a single discriminator network, indicated by the dashed rectangle.

Perceptual discriminator
During training of the image enhancement network, the realism of enhanced images is evaluated via a perceptual discriminator. The discriminator consists of a robust semantic segmentation network, a perceptual feature extraction network, and multiple discriminator networks (Fig. 9). We employ MSeg [72] for semantic segmentation and VGG-16 [93] for perceptual feature extraction. Both networks are pretrained and are not optimized during training of the image enhancement network. We apply the segmentation network to real images from a target dataset and unmodified rendered images. This provides compatible semantic information for real and synthetic images. It also enables training on datasets without ground-truth annotations. In practice, we apply the segmentation network once to all images and cache results. Prior work trained a segmentation network on synthetic data and applied it during training to ensure semantic consistency [19]. We avoid this as networks trained on synthetic data can generalize poorly to real data. Thus segmentations from such a network can differ substantially when applied to original and enhanced images. We also avoid backpropagating through the segmentation network as this may result in images that are easy to segment but not necessarily realistic.
Applying the VGG feature extraction network to real and enhanced images provides perceptual features at several levels of abstraction. We extract feature tensors from the relu layers of the VGG and train a discriminator network for each level. This way each network specializes on a different perceptual level.
The discriminator networks (Fig. 9) each consist of a stack of five Convolution-GroupNorm-LeakyReLU (CGL) layers, which produces a 256-dimensional feature tensor y, and a Convolution-LeakyReLU-Convolution (CLC) layer, which projects the feature tensor down to a single-channel map z. The feature tensor y is further fused with an embedding tensor e via an inner product. The embedding tensor contains a 256-dimensional embedding per pixel, learned from the label maps discussed above. The inner product of features and embeddings was used in prior work [8], [15], [70].
Further details on the architecture of the discriminator networks are provided in the supplementary material.

Layout differences cause artifacts
In an adversarial setup as we employ it, a discriminator is trained to classify images, assigning a real or fake label to each image or pixel. During training, the discriminator will pick up any feature that allows it to easily discriminate real and fake images. For example, if sensor noise is present in real images, but not in synthetic ones, the discriminator will quickly learn to correctly label a noisy patch as real. Backpropagating the gradient from the discriminator to the generator encourages the generator to add noise to synthetic images, making them appear more realistic.
A problem arises when fake and real images can be distinguished by relying on spurious features. For example, the probability of seeing sky at the top of an image from GTA V is much higher than for Cityscapes, as can be seen in the probability density maps in Fig. 10. Conversely, at the same position it is much more likely to find trees in Cityscapes than in GTA. Thus, a classifier trained on uniformly sampled images from both datasets may easily identify (real) images from Cityscapes by checking the top of the image. If the top contains some texture resembling trees, it is more likely to be real. Putting this discriminator to work in an adversarial training setup will push the generator to place trees in the sky. This affects the probability of seeing certain classes at specific positions. For example, GTA is more likely to have sky at the top of the image, while Cityscapes is more likely to have trees there and a star logo on the hood of the car. Fig. 11 illustrates the impact of this structural mismatch on photorealism enhancement.
Confirming evidence for this hypothesis comes from recent methods that employ GANs to translate GTA V to Cityscapes -they indeed hallucinate trees at the top or star logos at the bottom of images, as shown in Fig. 11.
Sampling matching patches. Our analysis suggests that randomly sampled images from GTA and Cityscapes differ in their layout in expectation, although they may contain the same type and quantity of objects [85]. This suggests that the standard strategy of comparing image patches that are as large as possible to maximize context [19], [20], [60], [76] is suboptimal for enhancing realism. We propose a different sampling strategy.
First, we shrink the crop size to an area of only about 7% of the full image. This contrasts with prior work which ingests 30-50% of an image as a single patch. Experiments in Sec. 4.4 confirm that this simple modification already improves results significantly.
Second, we match sampled patches across datasets to balance the distribution of objects presented to the discriminator. Specifically, we process patches from synthetic images with a VGG network [93], pretrained on ImageNet [94], and extract feature tensors at the last relu layer. We crop patches at a width of 196 pixels, which corresponds to the receptive field of VGG at this layer. We thus obtain a 1 × 1 × 512 dimensional feature vector per patch. Let φ(p i ) denote the feature vector computed from patch p i . We consider two patches as matching if they have a cosine similarity above 0.5: where P real is the set of patches extracted from real images. For efficiency, we unit-normalize φ(p i ) and compute the L 2 distance via FAISS [95]. Examples of matching patches across GTA and Cityscapes are shown in Fig. 12.

Implementation & training details
We train the generator and discriminator with an L 2 loss. The generator is further regularized with an LPIPS loss (λ = 5) [87]. We train all networks with Adam [96] (β 1 = 0.9, β 2 = 0.999, weight decay 0.0001). The learning rate is set to 0.0001 and halved every 100K iterations. We clip gradient magnitudes greater than 1000 for all networks. All discriminators are regularized with a gradient penalty on real data (γ = 0.06) [77]. We train with batch size 1 for 1M iterations (controlled experiments 600K).
Adversarial training can become unstable if discriminators become too strong and cease to provide meaningful gradients to the generator [74], [97]. In addition, we have encountered training difficulties that stem from the use of multiple discriminators. For example, we have observed that discriminators that operate on low-level VGG features tend to learn faster, and are thus prone to dominating the training and overfitting. To stabilize training and prevent overfitting of individual discriminator networks, we throttle the training speed of each discriminator by randomly skipping the backward pass for this discriminator with a certain probability. The probability of skipping the backward pass is determined by the current performance of the discriminator. Intuitively, the better a discriminator becomes at judging realism, the closer it is to overfitting, and the less frequently it will be updated by our training protocol. This strategy keeps all discriminators roughly at the same level of performance as training progresses. A similar mechanism was used in ABC-GAN [98] to balance generator and discriminator training. We use this idea to balance multiple discriminators. Our computation of the probability of skipping the backward pass for a given discriminator is inspired by the augmentation probability of Karras et al. [74]. (Different from Karras et al., we take into account both real and fake samples in computing the update heuristic.) GTA MUNIT [20] Cycada [19] CUT [60] TSIT [35]

Metrics
A number of metrics for evaluating the realism of generated images have been proposed. The most common are the Inception Score (IS) [99], the Fréchet Inception Distance (FID) [100], and the Kernel Inception Distance (KID) [101]. Among these, the KID has been shown to be superior [101], and we use it in our evaluation for this reason. However, our analysis in Sec. 3.4 on the structural shift across datasets implies that quality assessment using the KID may be misleading due to mismatched scene layouts. The KID compares features extracted from the pool3 layer of an inception network [102], which corresponds to high-level semantic concepts. Thus, roughly speaking, the KID measures distance between semantic structure, but not necessarily a difference in perceived realism. This is problematic, since in enhancing the photorealism of synthetic images we aim to retain the scene structure and semantic content of the source image, rather than shift them towards scene structures that may be more common in the real-world dataset. Put another way, we can trivially minimize the KID by reproducing a real image from the target dataset and ignoring rendered images altogether. Thus, preserving semantic content poses a lower bound on the KID, a level below which the KID should not be driven. Overall, the KID objective is misaligned with the broader photorealism enhancement objective and is a problematic metric for this reason.
We propose a different set of metrics that alleviate this problem. Our metrics build on the KID, but incorporate some key changes. In order to better assess the difference between images at several perceptual levels, we replace the features from the inception network with features extracted at different layers of VGG, since this architecture has been widely used for assessing perceptual image quality [11], [87]. To address the problem of mismatched layouts in the source and target datasets, we align the distribution of patches for GTA Cityscapes Fig. 13. Semantically corresponding patches sampled for calculating our sKVD metrics.
which we extract features. Specifically, we extract quadratic patches of 1 8 of the image size from the semantic label maps of source and target datasets. We downsample these patches to a resolution of 16 × 16 to obtain a 256-dimensional vector. The vectors obtained in this way correspond to ground-truth semantic descriptions of the patches. For each such vector from the synthetic dataset, we find the nearest neighbor in the set of vectors from the real dataset. We retain pairs of vectors with more than 50% matching entries. This way, we obtain a set of semantically corresponding patches from the two datasets (Fig. 13).
More formally, let σ denote the vector encoding of a patch and [·] the Iverson bracket. We sample the nearest neighbor patch for p i by where k iterates over elements in the vector encoding. Following the construction of KID [101], we define our metric as the squared maximum mean discrepancy (MMD) between features from a VGG-16, computed on corresponding patches. 1 The different feature representations of the VGG give rise to a family of metrics, characterized by the layer at which feature maps are extracted. We extract features at relu1-2, relu2-2, relu3-3, relu4-3, relu5-3, and term the corresponding metrics sKVD * for semantically aligned Kernel VGG Distance with a subscript indicating the corresponding VGG relu layer.

Comparison to prior work
For the comparison to prior work, we select a number of baselines that represent multiple lines of work that can be applied to photorealism enhancement. For methods that require semantic segmentation labels as input, we provide maps for 1. To compute the MMD, we use the same polynomial kernel as Binkowski et al. [101]. synthetic and real images predicted by MSeg [72], the same robust segmentation network we employ in the discriminator of our method (see the supplement for examples). We report overall results in Tab. 1 and show examples in Fig. 14 and in the supplement.
Color transfer. We compare against classic work on color transfer. Namely, we evaluate the seminal work of Reinhard et al. [47] (Color Transfer) and the color distribution transfer (CDT) of Pitié et al. [49]. Modifications by these methods are restricted to colors of individual pixels. While this prevents enhancements of textures, it also prevents the introduction of artifacts common to more aggressive learningbased approaches, thus keeping the resulting images fairly close to the original input (Fig. 14). Consequently, the largest improvements can be observed in the metrics for low-level features (sKVD 1−2 and sKVD 2−2 ), where the gains match the level of more recent deep learning approaches.
Photo style transfer. We compare against a closed-form solution for fast photographic style transfer (PhotoWCT) [53] and the state of the art, based on wavelet transforms (WCT2) [54]. Both photo style transfer approaches require a style image and semantic segmentation maps for both source and style image. While color transfer methods apply transformations to individual pixel colors, photo style transfer methods perform transformations in learned higher-level feature spaces guided by semantic segmentations, and thus modify images more strongly. However, photo style transfer methods rely on a favorable style image that matches that input synthetic image. When the input image changes, as happens during interactive exploration of a synthetic environment, photo style transfer can produce unrealistic color shifts or temporal instability.

Conditional image synthesis.
We compare against a representative approach to conditional image synthesis, SPADE [14], as it dominates preceding approaches (e.g., [10], [11], [12]). We use a model pretrained for synthesizing urban street scenes, provided by the authors. (The model is pretrained on segmentation ground-truth from Cityscapes, which is compatible with GTA.) SPADE considerably underperforms other methods. This can be explained by two factors. First, synthesizing a photo from only a semantic segmentation map is more challenging than modifying a given image. Second, since SPADE is trained to synthesize images from the Cityscapes dataset (and does so quite well), the distribution shift in scene layouts between Cityscapes and GTA takes this model far outside its training distribution.
Image-to-image translation. We compare against Cycada [19], which was specifically designed for adapting synthetic images to real photos. To this end, it augments the commonly used pixel-level cycle-consistency with a feature-level cycle-consistency and a semantic consistency loss. The latter leverages corresponding semantic labels to preserve the content of the synthetic images. As Cycada was originally trained on GTA V and Cityscapes already, we use images provided by the authors. We further compare against MUNIT [20], CUT [60], and TSIT [35]. MUNIT extends the CycleGAN [59] architecture to multi-modal translation and adds a domain-invariant perceptual loss. CUT and TSIT abandon the cycle consistency constraint. CUT builds instead on contrastive learning, and TSIT uses an exemplar style image for transferring style features. We find that among the various types of baselines, imageto-image translation methods perform best, and within this group Cycada demonstrates the best results. Although Cycada makes use of more explicit semantic information than other methods that use a perceptual loss, it still hallucinates extraneous objects (see Fig. 11). A possible reason may be its segmentation network, which is pretrained on unmodified synthetic images and is not updated during training of the image synthesis network. Thus Cycada implicitly assumes that the drift between synthetic and real images will be limited and the segmentation network will continue to work reliably. Another possible reason is training on large image patches (see Sec. 3.4 for the associated discussion).

Perceptual experiment
We additionally compare our approach to all baselines in a large-scale crowdsourced perceptual experiment. The setup of the perceptual experiment follows prior work and is based on pairwise comparisons with no time limit [11]. We sample 500 images from GTA and compare enhancements from our method to baselines. For each image, our method is paired with each baseline. The pairs are presented to crowd workers. Each pairing is shown 10 times in total (across workers), resulting in 50,000 comparisons in all. The assignment of pairs to workers, their order of presentation, and the left-right order within pairs are all randomized. To filter unreliable workers we include sentinel tasks. The results are shown in Fig. 15. We find that images enhanced by our method are consistently considered more realistic than all baseline methods. The results are statistically significant for all methods (error bars indicate 95% confidence intervals).

Controlled experiments
To assess the effect of specific ideas in our approach, we conduct a set of controlled experiments. We evaluate our sampling strategy, the importance of G-buffers, architectures for ingesting G-buffers, and different setups for the adversarial loss. The results are shown in Tab. 2. The first column identifies the experimental question and the second row lists the baseline condition. The first row provides reference metrics for unmodified GTA images. The last row provides the metrics for our full approach.
How to sample? To assess how the patch sampling strategy affects photorealism enhancement, we compare uniform sampling with different patch sizes (196,256,400) to the sampling of matching patch pairs (Ours). The results are consistent with our hypothesis that sampling at smaller patch sizes reduces the mismatch between source and target datasets. We observe stronger hallucination artifacts for larger patch sizes (Fig. 16, columns 2 & 3). Sampling at smaller patch sizes reduces the sKVD considerably. Sampling matching patches further reduces sKVD at medium to high levels of abstraction, while slightly increasing sKVD at the lowest level (Tab. 2, How to sample?). This may be explained by the benefits of diversity when uniformly sampling patches, offset by the distribution mismatch for higher levels.

Do G-buffers help?
The set of available G-buffers depends on the rendering method used by the game and the method for capturing G-buffers. For example, recording at video rates and lack of deep integration with the game engine limited the set of G-buffers recorded for the VIPER dataset [85].
(The set of G-buffers available for VIPER includes normal, reflection, depth, normal · view, and semantic segmentation.) To investigate the effect of the available set of G-buffers on photorealism enhancement, we compare three conditions: not using G-buffers at all (No G-buffer), the limited set of buffers available for VIPER [85] (VIPER), and our full set.
We find that without any G-buffers, enhanced images are significantly less realistic at all but the lowest level. Without any auxiliary information provided by the G-buffers, the network seems to focus much more on low-level features. Adding the buffers from VIPER improves realism at all levels, with the strongest effects observed at low and medium levels. With our full set, the sKVD 1−2 is higher, which suggests that the network allocates more capacity to enhancing mid-and high-level features, for which sKVD is reduced.

How to ingest G-buffers?
We investigate several strategies for ingesting the G-buffers into the image enhancement network. The first is to simply append them to the rendered image (Concat). This corresponds to the strategy employed by AlHaija et al. [83]. As this variant does not treat G-buffers in any special way, RAD modules are not required, and we use instance normalization instead. This condition uses a standard HRNet architecture for image enhancement (no RAD modules or RAD blocks). In the second condition, we replace our RAD modules by SPADE modules [14] (SPADE). The third condition is our full approach, which uses our RAD modules (last row of Tab. 2).
The results indicate that simple concatenation yields better results than the SPADE modules. The results with SPADE modules are volatile across the dataset, ranging from realistic images to complete failures with strong artifacts and color shifts (Fig. 17, middle column). In contrast, our results with RAD modules are of consistently high quality (Fig. 17, right column). This is confirmed by all metrics in Tab. 2.
Which discriminator? We now assess the importance of specific ideas in the perceptual discriminator. As a baseline we pick the PatchGAN discriminator since it is standard in image-to-image translation [10], [12], [14], [20], [32], [34], [35]. Specifically, the PatchGAN condition uses four discriminator networks that each ingest images at a different scale. The network stems share the same architecture as our discrminator networks, except for the projection of segmentations, which is not part of the PatchGAN architecture. In the next condition, we remove the robust segmentation network from our approach (No projection). In the third condition, we train the discriminator without adaptively throttling the different discriminator networks as described in Sec. 3  backprop). The fourth condition is our full approach (last row of Tab. 2). As reported in Tab. 2, the results with the PatchGAN discriminator are significantly less realistic. This is illustrated in Fig. 18. The projection layer and adaptive backpropagation both help, but at different perceptual levels. Removing adaptive backpropagation hurts sKVD at all but the highest level. Removing the projection layer increases sKVD at the higher levels. The effect of the projection layer is illustrated in Fig. 19. The combination of projection and adaptive backpropagation is beneficial when all levels are taken into account.

C O N C L U S I O N
Our approach significantly enhances the realism of rendered images. This is confirmed by a comprehensive evaluation of our method against strong baselines. Intuitively, our method achieves the strongest and most consistent results for objects and scenes that have clear correspondences in the real dataset; our method excels at road textures, cars, and vegetation. Objects and scenes that are less common in the real images (e.g., close-up pedestrians) are modified less convincingly. Overall, our approach produces high-quality enhancements that are geometrically and semantically consistent with the input images while matching the style of the respective dataset. (Additional results with Mapillary Vistas are shown in Fig. 20 and in the supplement.) Our method integrates learning-based approaches with conventional real-time rendering pipelines. We expect our method to continue to benefit future graphics pipelines and to be compatible with real-time ray tracing. Inference with our approach in its current unoptimized implementation takes half a second on a Geforce RTX 3090 GPU. Since Gbuffers that are used as input are produced natively on the GPU, our method could be integrated more deeply into game engines, increasing efficiency and possibly further advancing the level of realism.
Additional results are shown in the supplementary video. Images produced by our method are structurally consistent with the input scenes, which can facilitate the use of groundtruth annotations that may be available for synthetic data [27], [85]. To support future research, we will release enhanced images for the GTA V and VIPER datasets.

GTA
Ours (PatchGAN) Ours Fig. 18. Our perceptual discriminator (right) is more effective than a PatchGAN discriminator (middle). Note the stronger enhancements such as lights and reflections on the car on the right.