{'fraction_non_alphanumeric': 0.018722835172183216, 'fraction_numerical': 0.007062855232363758, 'mean_word_length': 4.681149097815765, '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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Playing for Depth

Estimating the relative depth of a scene is a significant step towards understanding the general structure of the depicted scenery, the relations of entities in the scene and their interactions. When faced with the task of estimating depth without the use of Stereo images, we are dependent on the availability of large-scale depth datasets and high-capacity models to capture the intrinsic nature of depth. Unfortunately, creating datasets of depth images is not a trivial task as the requirements for the camera mainly limits us to areas where we can provide the necessities for the camera to work. In this work, we present a new depth dataset captured from Video Games in an easy and reproducible way. The nature of open-world video games gives us the ability to capture high-quality depth maps in the wild without the constrictions of Stereo cameras. Experiments on this dataset shows that using such synthetic datasets increases the accuracy of Monocular Depth Estimation in the wild where other approaches usually fail to generalize.


Introduction
Considering the accurate and fast reaction of human visual cortex in estimating the depth of a scene, the task of Monocular Depth Estimation is still an open problem which is more complex than trying to estimate the depth using pairs of stereo images. contrary to their more straightforward approach, Stereo correspondence requires the availability of more than one image to estimate the depth of a scene which is not feasible in many scenarios [1] [2]. Limited availability of Stereo cameras and their rare use in everyday activities are what drives the researchers towards estimating depth using only monocular images.
Estimating monocular depth is a challenging area of research as it is tied to both understanding the global structure of an image and the relations of its entities with each other. For humans who have a rich understanding of the world around them this makes for a trivial task to estimate depth using Monocular Cues such as Textures, Occlusions & Haze, Brightness, Defocus & Blur, Interpolation and Linear Perspective [3].
Integrating the aforementioned cues to end up with a monolithic model capable of estimating depth is a challenging task. Considering all of the monocular cues in a scene, it is still possible to conjure a situation in which a human is mislead about the depth of the scene. There are a variety of situations in the wild in which the global structure of the scene is misleading enough to lead the model to estimate the depth completely wrong. These situations can be created artificially using Optical Illusions (Fig 2) or naturally occur in the wild (Fig 3) where the only cue helping us estimate the depth is the context of the scene as the Monocular Cues are rarely of help considering the complexity of these scenes. Some instances where the scene is illusive enough to result in estimation errors are shown in Figure 3: Lacking the necessary knowledge of how Mirrors look and work results in trying to estimate the depth of the mirror's reflection. Transparent objects such as a car's windshield or an apartment's glassy windows results in errors when estimating depth. an advertisement or poster printed on a wall should only be treated as a flat object with linear and flat depth which is hard for most models to understand. These are examples of situations where the traditional methods of depth estimation [4] fail to handle the complexity of scenes.
The recent achievements in Depth Estimation is widely attributed to the advancements of deeper architectures and large scale datasets used to train them. Unfortunately the scope of locations these datasets provide are lacking in variety, for instance notable depth datasets are limited to where the capturing camera could roam free such as interiors [5] or roads [6]. Extrapolating for scenes which are outside of these domains occasionally results in inaccurate depth estimations. On the other hand a large portion of these datasets contain heavy noises which forces the researchers to either mask them completely or fill them using inpainting [7] [8].
The limited scope and noise-ridden state of these datasets has resulted in attempts to gather depth datasets using other means than Stereo images [9] [10]. In this paper, we use a novel approach to create a depth dataset which can contain a vast array of different locations in the wild with no noise whatsoever. We then introduce an architecture minimizing multiple losses to estimate the depth of images in the wild and provide comparisons with other notable works in the field.

Related Work
User-Specified Depth Inputs. By considering a scene as a combination of Foreground and Background and having the aid of users to determine these two layers, one can estimate the global depth of a scene [11]. The main problem of these approaches is the need of user hints about the relative depth of the scene without which the estimation would not be able to work. Monocular Datasets. Until recently a great deal of research in depth estimation was based on using a handful of RGB-D datasets which were mainly limited to scenes where the capturing device 1 could freely roam, e.g. indoor scenes [5] or constrained outdoor locations [3]. The main problems of these datasets are the location limitations, noisy captures which need inpainting or masking and the time consuming procedure of physically moving the camera around by hand or by using a robot. Ordinal Datasets. Instead of trying to label full-scene depth images, these approaches rely on point-wise ordinal relations to estimate the depth of the scene [12] [10] [13]. The dataset is gathered mainly by crowd-sourcing and the goal is for each user to differentiate between the relational depth of two random points in the scene. By having lots of points that can tell which objects are farther and which ones are closer, a model can be built to approximate the global ordinal depth of the scene. a hardship specific to this approach is the method of data gathering which relies mainly on crowdsourced monetary services such as Amazon Mechanical Turk. View Generation. This approach uses a collection of images from different viewpoints of a scene to generate a new view for the scene [14]. This idea has been used on Side-by-Side 3D Movies (as a dataset) to generate the right   [15]. This process generates probabilistic disparity maps which can then be used to shift the left image (as input) and render the right image (as output). One advantage of 3D Movies is the vast number of frames which can be extracted from the videos and used as a dataset. Another way to approach this method is to use many Internet photos to approximate a 3D model of a scene [16]. By gathering a large dataset of real-world landmarks with many photos for each one, one can construct a 3D Model of the landmark using SfM 2 and MVS 3 methods. After refining the depth maps given by the reconstructed 3D scene, one can use methods from previously discussed work (such as Monocular & Ordinal methods) to estimate a final depth for the image. The depth maps aid in general depth estimation while the point clouds are used for determining Ordinal relations between objects and both contribute to the final Depth of the scene [16]. Reliance on SfM and MVS methods takes many steps to finally end up with a proper dataset to train on. a State-of-the-Art application should estimate the 3D struc-2 Structure from Motion 3 Multi View Stereo ture which are usually noisy in nature, a different step should be taken to refine the noisy data and correct/remove outliers (such as people standing in front of a landmark). Our approach does not need these refinement and preprocessing steps, as the depth maps are properly rendered and no noise is present in their structure.

Dataset Construction
For the past couple of years Video Game realism has had a steady growth thanks to a vast array of complex technological advancements and raw computational power. On the other hand the world scale of these game have also been rising both in quantity and quality 4 . Even considering the large scale of these maps, the details which fill these worlds and give them their lifelike characteristics can severely differ from each other 5 . Considering this we have chosen Grand Theft Auto V as the main Limited Datasets

Unlimited Datasets
Our Dataset Depth in the Wild Figure 4: Notable Depth datasets source of generating samples for the Gaming for Depth (GfD) dataset. The vast variety of places, events, actions and objects in this game is astounding and the attention to detail in this game is superior to most games. Interior details, streets full of people and vehicles, residential and recreational areas, different building architectures, different and controllable weather and lighting conditions are just a small fraction of the lively world of GTA V. These promising characteristics make this game a suitable candidate for automatic extraction of hard-to-acquire real world datasets for tasks such as Semantic Segmentation and Depth Estimation.
To extract the depth maps, We inject a Di-rectX driver to the game to redirect all of the rendering commands to it. We then proceed to extract the Depth info of each frame displayed within the game and record it. This gives us the ability to capture depth frames up to 8K resolutions.
The nature of video games gives us the ability to meddle with the world around us. This is a powerful ability for dataset generation since one can come up with different lighting or sit-uations for just one simple scene. Most of the Depth datasets don't have depth data for situations where the overall lighting may be too dim or even don't have enough lighting variety for one particular scene. Most models based on these datasets end up functioning normal if presented with the same lighting conditions and they may act unfavorably when met with input which has a different light setting. To avoid this problem we inject a trainer into the game to control the global lighting conditions by timing the speed of Sunrise and Sunset. Just by accelerating this timeframe we can have a series of depth images from one scene with different light settings, e.g. sunrise, midday, sunset and midnight.
We also account for different weather conditions by injecting another trainer to control the weather and automatically changing it in short intervals. This gives us the ability to extract different samples from weather conditions such a sunny, rainy, foggy, stormy and smoggy. Some samples of the dataset showing day/night cycles and weather conditions are shown in section 7.
The GfD dataset consists of images scaling from half a meter to several Kilometers long. This property of the dataset makes it hard to test the accuracy of the models trained on it with limited-scope indoor datasets such as NYU or SunRGBD. Training a model naively on the GfD dataset results in nearly the same overall depth for the mentioned datasets since most of the scenes are limited to indoor distances. One way to reduce the effects of this range, is to preprocess and normalize the images before training. We have tested Histogram Equalization, Log-Transforms and Standardization techniques to normalize the range of the depth maps. Histogram Equalization, results in depth maps in which the depth of the scene is localized between the nearest and farthest objects, meaning that we end up with a "relativistic" depth between the objects and not the depth that was originally extracted from the game (a characteristic needed in some use-cases and disregarded in others). a downside to Histogram Equalization is the amount of noise it introduces to the overall image especially in scales smaller than the initial image resolution. The log-transform of the depth maps proved to be more useful in cases which we want the overall depth of the scene to stay relevant after rescaling it. Standardizing the images proved to be effective where the former techniques failed. There are various filters applied to the user's viewpoint throughout the game. These filters are used when wearing shaded glasses or helmets, in different weather conditions or in some cutscenes of the game to give the overall image a specific color tone. Standardizing the images removes the effect of these color tones and makes the image colorfully relatable to the rest of the images in the dataset.
We used the Histogram-Equalized, Log-Transformed and Standardized versions of the GfD dataset as inputs to the model and for the sake of global depth scale, the Standardized version worked better considering the propagation problem of brightness intensity (referred in 4.1) while the Histogram-Equalized version proved useful in vision tasks where we only needed a relative notion of depth between the objects in the scene.

Method
This section explains the learning architecture and the Loss objectives used to model the Depth Estimation task.

Network Architectures
Our initial experiments with the GfD dataset consisted of networks that had worked properly with depth data in the recent literature, which frequently involves the variations of the U-Net (Hourglass) [10] [16] and Inception [17] architectures. One of the driving forces behind this decision is the ability of these architectures to prevent the loss of high frequency details in the subsequent layers of the network thanks to the skip-like layers. In the U-Net architecture, the middle layer also acts as an embedding layer for the domain of training images. The combination of the middle embedding layer with the skip layers are effective in Image-to-Image tasks where we need to transform an image into another domain, e.g. Automatic Colorization [18], Scene Rendering [19].
These specific characteristics of the U-Net are what makes it rather unsuitable for the use case of image-to-image Depth Estimation. Unlike tasks such as Image Colorization where the skip layers positively affect the generation of global and local details in the predicted image, these layers tend to negatively impact the prediction in the task of Depth Estimation.
The outer skip layers of the U-Net are able to bypass the convolutions taking place in the inner layers and be present at the final layers of the network. While this is a powerful characteristic in many tasks, it usually backfires while estimating depth. The presence of initial layers of the network at the final layers, poses the risk of brightness intensity saturation in which the network prefers to estimate the depth solely based on the intensity data provided by the initial skip layers of the U-Net.
This problem is presented in Figures 5 and  6. Without the aid of skip layers, generating Depth maps and refining them would be hard, but while used, they result in cases where the network relies heavily on the data provided by them. The shirt worn by the man in should be considered to have the same depth as him, which also applies to the hearts on the card [10] and the carpet on the ground [10]. This problem is present in many situations such as colorful paintings on a white wall, symbols and text on objects or an open window inside a dark room: In all these situations the network prefers to estimate the depth based mainly on the brightness intensity and not the intrinsics of the image, resulting in subpar performance in many situations. Applying weights and dynamic Dropouts to outer skip layers does not hinder their negative effects on the final depth map.
Another family of architectures which showed promising results in our experiments were the networks designed for the task of Semantic Segmentation [20] [21]. Designed for classifying individual pixels, these models exhibit stronger inference between objects of the scene when faced with the task of Depth Estimation. One downside to these architectures are the rather large memory requirements which forced us to use at most 3 batch sizes at once on a Geforce 1080Ti. Another problem is the noisy artifacts introduced during training to the final depth maps. Even using the multiscale scale invariant gradient matching objective (explained in section 4.3) couldn't completely rid the outputs of these networks from these noisy estimation.
These limitations led us to design a residual architecture which is able to account for the downsides mentioned above.

Residual Architecture
With the recent advent of Residual networks and their outstanding performance in Computer Vision tasks, we have seen a number of tries to apply these architectures to the task of Depth Estimation [22] [23]. Depth Estimation is inherently a harder task than other image to image translation topics such as colorization, style transfer or scene rendering due to the need for inference between the object relations in the scene. To maximize the capacity of our model, we opt to use a modified version of Resnet in which Batch Normalization and subsequent ReLU activations have been stripped from each residual block [24].
Based on a series of experiments, we empirically found removing the Batch Normalization layers beneficial to the overall quality of estimated depth maps and prevent the creation of noisy artifacts after prolonged training of the model. This issue along with the memory consumption of the batch normalization layer (which uses the same amount of memory as the previous convolutional layer), led us to remove this layer as also done in [25]. a Comparison of our residual block and the original implementation [26] is shown in Fig 7. We input a 256 × 256 image to the network and downsample it to 64 × 64 dimensions. We then use 32 residual blocks of 64x64 input sizes where each block has 256 convolutional layers. We use the subpixel convolutional neural network layer proposed in [27] to upsample the final residual block's output to 256 × 256. This upsampling technique introduced lesser artifacts and pixelated outputs to the final depth map where the bilinear and transposed convolution layers fail or produce noisy artifacts.

Objective Functions
Scale-Invariant Loss. The depth range of the GfD dataset makes comparing the predicted depth maps with the ground truth impractical. To solve this problem we use the approaches introduced in [7] [8]. Even if the scaling of depth maps are different, the relative depth of pairs of corresponding pixels between the predicted depth map y and ground truth y * should stay the same. This relation can be defined in the log-domain as: Expanding and simplifying equation 1 results in an equation with similarities to the l2 (and also MSE ) loss functions (let D i = log y − log y * ): Total Variation Loss. One of the notable aspects of depth maps is their usual continuity in local patches of the image. When training a network on the task of pixel-based image to image translation, we are faced with discontinuities and noisy artifacts in the overall predicted depth map. Relying mainly on the L2 or Scale-Invariant loss functions proves effective for estimating the global depth of the scene but it usually fails to account for the small high-frequency details in the scene. Minimizing the L2-based loss functions is the same as maximizing the log-likelihood of a Gaussian, thus assuming our Depth images come from a Gaussian distribution. This assumption which is a fundamental part of our loss functions, results in the blurry depth predictions of our network.
There are different approaches to improving the quality of the predicted blurry depth maps. Using Conditional GANs 6 [18] is a relatively recent approach in improving the quality of the depth images. The downside of this method is the possible corruption of the generated depth images. The Discriminator is trained to discriminate between the real and fake images generated by the Generator. Because of a lack of context, the Discriminator only tries to make the generated images "look" more realistic without any access to the context of the task which results in depth images 6 Generative Adversarial Networks which look real but are fundamentally flawed in many semantic concepts related to Depth Estimation.
We use the Total Variation loss as an objective function to enforce the matching of ground truth gradients with that of the predicted depth map. This term not only enforces the gradients and edges to be similar to the ground truth but also contributes to smoothing the overall prediction and controlling the amount of depth discontinuities and noisy artifacts in the final output: While effective for a single scale, we found that applying this term to multiple scales of the generated output can improve the quality of the predicted depth maps even further: where D s i is the depth map value at scale s and position i.
This criterion has been used successfully in tasks where we want the generated image to stay consistent in areas with the same intensity such as Colorization [28] and Depth Estimation [8].

Training & Evaluation
We train the model for 50 epochs and use the ADAM optimizer with a learning rate of 0.0004 and its default parameters. We halve the learning rate by 0.65 × LR every 10 5 iterations as this allows the network to settle on a final local optimum. We train using batches of size 16.
We only train the model on the GfD dataset and do not train the model on any of the test datasets (which results in differences of depth scale). We apply random scaling to images (up to 30 pixels) and crop the scaled version back to 256 pixels. We also flip the batches randomly to potentially double the dataset capacity.
We tested the final model on the Make3D and NYUDepth v2 datasets. We compare our method to prior works of [8] and [10]. Standardizing the dataset has resulted in resistance to the brightness intensity and

Failure Cases
We disabled the Depth of Field and Motion Blur settings in GTA V to be able to capture high definition images from the game. This choice results in a dataset which has little to offer to the model in case of depth information related to blurred and out of focus images. The consequence of this choice can be seen in images where the majority of the scene is out of focus and blurred.

Conclusions
In this paper we have shown a new way to gather depth images from Video Games and use them to train models which are useful in the wild and not limited to the current domainlimited datasets. This approach is easy to use and can easily be done with a vast array of different Video Games available on the market. We then used this dataset of nearly 200, 000 images to train a model which achieves comparable performance in the task of Depth Estimation in the Wild.
The idea of using the extracted Depth of Video Games can be extended to use the other semantic information which lies dormant in the Video Game data such as the Semantic Info of the scene (used for semantic segmentation) [29] [30] and also the Normal Surface Maps of the scene. These two auxiliary information can greatly help in estimating the Depth of a scene as shown in [8]. In future we hope to expand the GfD dataset to more auxiliary information which can then be used to construct a model which has access to these data for better prediction in the real world scenarios.  data to account for illumination and weather changes. By recording the transitions and using them as training data, we can help the model stay invariant to dynamic changes that don't affect depth estimation such as the sun and shadows, moving clouds, puddle reflections or day/night cycles. Fig 14 compares results between [8], [10] and our approach on the DIW dataset. As can be seen, our approach shows resistance to rapid changes in brightness intensity and illumination. Since we are not directly using skip-connections throughout our network, our model is less vulnerable to texture pattern phantoms which can be seen in the case of the pattern below the cat or the hearts on the card.