{'fraction_non_alphanumeric': 0.030244060650287844, 'fraction_numerical': 0.015162571961404362, 'mean_word_length': 4.9210273643783005, '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}}
Rethinking Monocular Depth Estimation with Adversarial Training

Monocular depth estimation is an extensively studied computer vision problem with a vast variety of applications. Deep learning-based methods have demonstrated promise for both supervised and unsupervised depth estimation from monocular images. Most existing approaches treat depth estimation as a regression problem with a local pixel-wise loss function. In this work, we innovate beyond existing approaches by using adversarial training to learn a context-aware, non-local loss function. Such an approach penalizes the joint configuration of predicted depth values at the patch-level instead of the pixel-level, which allows networks to incorporate more global information. In this framework, the generator learns a mapping between RGB images and its corresponding depth map, while the discriminator learns to distinguish depth map and RGB pairs from ground truth. This conditional GAN depth estimation framework is stabilized using spectral normalization to prevent mode collapse when learning from diverse datasets. We test this approach using a diverse set of generators that include U-Net and joint CNN-CRF. We benchmark this approach on the NYUv2, Make3D and KITTI datasets, and observe that adversarial training reduces relative error by several fold, achieving state-of-the-art performance.


Introduction
Depth estimation is one of the most extensively studied tasks by the computer vision community, largely due to its value in facilitating scene understanding and geometric relations between objects [27,29,10]. Fusing depth has demonstrated improved performance on a number of computer vision tasks including semantic segmentation, topographical reconstruction, and activity recognition [54,33,17]. Previously, the computer vision community relied on multiview methods such as stereo vision and structurefrom-motion for depth estimation [40,4,3,38,55,2]. However, situations where multiple measurements from the same scene may not be available or difficult to acquire mo- tivate the need for developing monocular depth estimation methods.
Though deep networks have shown promise in estimating depth from monocular images, many methods rely on local pixel-wise loss functions that do not capture higherorder statistics of the training data. To make these networks more context-aware, many loss functions calculate image gradients to capture changes in depth and preserve structural details [10,48,19]. This problem has also been partially addressed by the many combinations of deep learning and graphical model-based methods [31,11,34,35]. CNN-graphical model setups such as jointly trained CNN-CRF methods are more context-aware as compared to regular CNNs. While hybrid CNN-CRF models such as Liu et al. [31] and Mahmood et al. [34,35] maintain some spa-tial consistency between the prediction and the ground truth depth map via the pairwise potential, over-segmenting the image into super-pixels prevents the network from learning higher-order statistics that may describe depth cues in the image.
Recently, conditional generative adversarial networks (cGANs) have become an emerging technique in learning mapping distributions of high-dimensional data [21]. Such methods have mainly been used for image-to-image translation tasks such as artistic style transfer, super-resolution [5], and synthetic data refinement [50]. However, they can also be used in inference tasks such as semantic segmentation [32], in which the generator learns a mapping from objects to their semantic labels in an image, and the discriminator provides feedback to the generator about its accuracy. As argued by Luc et al. and Isola et al. [32,21], this adversarial term can be interpreted as a non-local loss that penalizes the joint configuration of pixel values. We argue further that this non-local loss, when calculated at the patch-level, is beneficial for learning depth cues. From our experiments, the benefits of conditional adversarial learning are two fold: a) networks can learn a loss function for depth estimation, which promotes the recovery of features that would be generally lost due to the limitations of a local pixel-wise loss function, and (b) such a setup is more context-aware, as the discriminator forces the generator to generate realistic pixel configurations of predicted depth that would be indistinguishable from ground truth depth maps.
Contributions: In this work, we propose that deep learning-enabled monocular depth estimation can be enhanced with adversarial training. We demonstrate an improvement over state-of-the-art depth estimation results on NYUv2, Make3D and KITTI datasets using conditional GANs, and investigate how the addition of an adversarial term affects performance when using encoder-decoder network and CNN-graphical model setups as generators. The specific contributions of our work are summarized below: 1. We describe a framework for context-aware depth estimation with stable adversarial training. Our framework learns a non-local loss function for depth estimation by incorporating a patch-level adversarial term, in which the discriminator classifies regions in the depth map predictions as synthetic or realistic. Depth regions that are predicted as synthetic penalize the generator for producing unrealistic depth configurations that fail to mimic real depth regions.
2. We present state-of-the-art algorithms and models for monocular depth estimation on the NYUv2, Make3D and KITTI datasets, and demonstrate how adversarial training can be adapted for different model types.

Monocular Depth Estimation.
Historically, depth estimation has been approached by multiview methods such as stereopsis [55]. A large body of knowledge has also focused on recovering depth from shading [43], texture [2], and focus [38]. Many approaches for monocular depth estimation rely on hand-crafted features, probabilistic graphical models, and deep networks to extract multi-scale contextual information in scenes. Prior to deep networks, depth estimation became posed as a Markov Random Field (MRF) learning problem. Saxena et al. [48] used a patch-based MRF to model relations between the depth of image patches with its immediate neighbors at different scales. Liu et al. [29] used both semantic and superpixel segmentation information from single images to help guide depth perception, using a pixel-based MRF and superpixel-based MRF to incorporate semantic and geometric constraints respectively. Ladicky et al. [25] also incorporated semantic information by learning a joint classifier to predict both depth and semantic labels. Following the breakthrough performance of CNNs for regression and classification tasks, depth estimation is often posed as a regression problem using end-to-end trained deep networks, with some recent efforts being made combine deep networks with graphical models. Eigen et al. [10] was the first to use CNNs for monocular depth estimation, in which they proposed a multi-scale deep network that first generates a coarse depth using a fully connected layer, followed by a refinement network that recovers texture details. Laina et al. [26] adopted a fully convolutional architecture that learns an upsampling convolution layer instead of a fully-connected layer to obtain finer depth estimates at higher resolutions, and exploits network depth to capture global information in an image. Liu et al. [31] presented a CNN-CRF network where the unary potential is a regression term that predicts depth for a given superpixel using fully convolutional layers, and the pairwise potential is a smoothness term measures intensity, color and texture differences between neighboring superpixels. Wang et al. [54] introduced a hierarchical CNN-CRF that jointly predicts depth and semantic segmentation from the same features, and was able to refine superpixel-wise CNN depth predictions. Xu et al. [57] learned multi-scale representations by recovering depth maps at each side output of an encoder-decoder network using a continuous CRF framework, and later followed their work by incorporating attention modules at the bottleneck of their encoder-decoder network [58].
In addition to advancements made in neural network architectures to incorporate context, there is also interest in engineering novel loss functions for recovering depth beyond L L1 , L L2 , and Huber (Smooth L L1 ). Eigen et al. [10] was the first to use L L1 loss in log-space and gradient loss terms in deep networks. The use of logL L1 downweights the contribution of depth errors at background pixel indices which tend to have less rich information, and the use of gradient terms help preserve details on local structure and surface regions. Laina et al. [26] introduced the BerHu loss, which penalized low and high errors by an 1 -norm and 2 -norm respectively. Jiao et al. [22] observed that on some depth estimation benchmarks, the distribution of depth values are skewed towards the foreground, which motivated a different loss function than Eigen et al. that weighted depth errors at the background indices more heavily than those at the foreground indices.
The GAN framework was first presented by Goodfellow et. al. in [47,14,15] and was based on the idea of training two networks, a generator and a discriminator simultaneously with competing losses. While the generator learns to generate realistic data from a random vector, the discriminator classifies the generated image as real or fake and gives feedback to the generator. GANs have recently been used for a variety of different applications [49,8,6,1] including image-to-image translation [21] and style-transfer and synthetic data generation [34]. Although, GANs have a generative and artistic ability, in order to harness the benefits of the GAN framework for specific vision applications they must be conditioned by additional information. This auxiliary information can be class labels, images or any other kind of data. Such a setup is termed conditional GANs (cGANs) and was first introduced by Mirza et al. [36]. In cGANs, the noise vector typical to GAN problems is combined with this auxiliary conditioning information resulting in generative models that are capable of transferring between domains. This approach has been used for paired [21] and unpaired image-to-image translation [60]. Since their advent, cGANs have been used for a variety of computer vision tasks, most notably in semantic segmentation [32]. Recently, Krishna et al. [44] used cGANs for cross view image synthesis. Wang et al. [53] have used cGANs for jointly learning shadow detection and removal and Hong et al. [20] used it for structured domain adaptation. In the joint landscape of both monocular depth estimation and GANs, Pilzer et al. [42] describes an unsupervised approach for depth estimation using cycle-consistent adversarial training. Because this approach uses unpaired data, the adversarial training does not explicitly preserve structural information and surface regions from depth prediction and its ground truth [16].

Conditional GAN Framework for Depth Estimation
In this section, we describe the conditional GAN objective for training depth estimation networks with non-local adversarial loss, followed by network architecture details. We denote A and A d as the RGB and depth image domains respectively, and a and a d as training examples in A and A d . Additionally, we denote G as a mapping function G : A → A d that learns a mapping from RGB to depth, and D as the discriminator network for G.

Conditional GAN Objective
The conditional GAN framework consists of two networks that compete against each other in a min-max game to respectively minimize and maximize the objective, min G max D L(G, D). The generator G learns a mapping from A to A d , and the discriminator D distinguishes between real and synthesized pairs of depth and RGB. To train this framework for depth estimation for paired data, the conditional GAN objective consists of an adversarial loss term L GAN and a per-pixel loss term L L1 to penalize both the joint configuration of pixels and accuracy of the estimated depth maps.
The adversarial loss is used to match the distribution of generated samples to that of the target distribution. For the mapping G : A → A d , we can express the adversarial objective as the binary cross entropy loss of D in classifying real/synthesized pairs. We can express this loss as: (1) The L 1 loss term is used to score the accuracy of the depth estimation by G, The motivation for using an adversarial loss is to incorporate non-local information, which has been shown to be instrumental for monocular depth estimation. We train a generator to learn a mapping between a RGB image and its corresponding depth map, and a discriminator to distinguish between ground truth and predicted depth conditioned on the RGB image on the patch-level. Per-pixel losses are generally local, in that each output pixel is considered conditionally independent from all other pixels given the image. When used in depth estimation, per-pixel losses such as L L1 and L L2 tend to produce blurry results, as the total relative error is averaged across all pixels which. An adversarial loss, on the other hand, penalizes the joint configuration of pixel predictions made in an image. The adversarial loss can be interpreted as a non-local loss that can help preserve more details. The adversarial loss comes from the discriminator, which classifies overlapping pairs of image and depth patches as being real or synthetic. By controlling the size of the patch, we can control the size of the non-locality, with bigger patches incorporating more global information in the image. Experimentally, we observed that predicting on 70 × 70-sized patches allowed the generator to make fine-grained depth predictions. Thus, we can write the loss function for the conditional GAN framework as: where, λ is a mixing parameter. As argued in Isola et al. [21], such an adversarial loss setup can be thought as a learned loss function where the adversarial loss is learned as the discriminator and generator are trained.

Stabilizing GAN training
As noted in previous works, the training procedure for GANs can be very unstable and lead to mode collapse and gradient artifacts in the depth predictions [14]. To address this, we apply spectral normalization in both the generator and the discriminator. Spectral normalization was first introduced in Miyamoto et al. [37], and was used to control the Lipschitz constant of the discriminator such that the spectral norm σ of the convolution weights W in the network would be bounded by the Lipschitz constraint: σ(W ) = 1. As a result, the discriminator is more stable during training and can avoid exploding gradients. Following the two-timescale update rule in Heusal et al. [18], the learning rate for the discriminator was set to be four times the learning rate of the generator to increase speed of convergence. In subsequent experiments by [59], spectral normalization was empirically determined to be also beneficial for stabilizing the generator, allowing for fewer discriminator updates per generator update. We also further stabilize the discriminator by using a buffered data input from the generator, which consists of previously generated and classified pairs and ground truth data. This approach to stabilizing the GAN training procedure was presented in Shrivastava et al. [50], and has been used in several proceeding works [21,34]. In our observations, we found that these techniques reduced visual artifacts made by the generator, which resulted in more smoothly-varying depth estimates. Figure 3: Joint CNN-CRF training paradigm. CNN-CRF models are more context aware as compared to regular CNN models. However, due to computational complexity we used this model as a generator on a super-pixel level.

Network Architectures
In this section, we provide details of the two different types of network architectures used as a generator for depth estimation with adversarial training.
Encoder-Decoder Networks. Encoder-decoder networks are commonly used in many deep network approaches for monocular depth estimation [26,57,58,22,39]. One formulation, the U-Net achitecture by Ronneberger et al. [45], draws skip connections between convolution layers on the encoder path and up-sampling layers on the decoder path that have the same spatial size. These connections are made between feature maps to recover and enforce spatial information across multiple resolutions and enforce spatial consistency on the output image, where the input and outputs are expected to align channel-wise [9]. We demonstrate that introducing an adversarial term can recover higher order information, while also preserving object boundaries and shape details (Fig. 4, Table 1). Our implementation of U-Net (Fig. 2) assumes that input images are 256 × 256, as the inputs are down sampled to 1 × 1 pixel at the bottleneck. Pooling and up-sampling operations are replaced with 4 × 4 convolution filters with stride 2 × 2 and transposed convolutions respectively. The U-Net loss can be defined as, Joint CNN-CRF Network. In this section we explain the how an adversarial loss can be used in a joint CNN-CRF network. Assuming x ∈ R n×m be an image which has been divided into g superpixels and y = [y 1 , y 2 , ..., y g ] ∈ R be the depth vector corresponding each superpixel. In this case the conditional probability distribution of the raw data can be defined as, and E is the energy function. In order to predict the depth of a new image we must solve the maximum aposteriori (MAP) problem, y = argmax y P r(y|x). Let ψ and φ be unary and pairwise potentials over superpixel nodes N and edges S of x, then the energy function can be formulated as, (6) where, ψ regresses the depth from a single superpixel and φ encourages smoothness between neighboring superpixels. The objective is to learn the two potentials in a unified convolutional neural network (CNN) framework. This setup is shown in Fig. 3. The unary part takes a single image superpixel patch as an input and feeds it to a CNN which outputs the regressed depth of that superpixel. Based on [31,35] the unary potential can be defined as, where h i is the regressed depth of superpixel i ∈ N and γ represents CNN parameters. The pairwise potential function is based on the standard CRF vertex and edge feature function studied in [34]. Let β be the network parameters and S be the similarity matrix where S k i,j represents k similarity metrics between the i th and j th superpixel. We use the intensity difference and grayscale histogram as pairwise similarity metrics using 2 -norm. The pairwise potential can be defined as, The overall energy function is, (9) During training the negative log likelihood of the probability density function is calculated from Eq. 5 and minimized with respect to the two learning parameters, γ and β. Two regularization terms are added to the objective function to penalize heavily weighted vectors. Assuming N is the number of images in the training data, (10) As in section 3.1, incorporating adversarial loss in this setup means treating the objective function above as the generator and jointly training the discriminator and generator using the following loss,    MatConvNet respectively [41,52], and trained on Nvidia P100 GPUs using Google Cloud. Both networks trained for 150 epochs with a base learning rate of 0.0002 with ADAM optimization in both the generator and the discriminator, followed by a linear step decay for 150 epochs. Both networks were trained from scratch, and used Xavier weight initialization and Spectral normalization in the generator and the discriminator, with the input also normalized to be between [-1, 1]. To prevent mode collapse, patches were pooled and fed to the discriminator in batches rather than individual images in each iteration. A pooling history of randomly selected 50 patch pairs was used in the discriminator. Dropout was used the bottleneck layer of our U-Net architecture, but was not added in our CNN-CRF setup.

Experiments
To demonstrate the improvements made by adversarial training relative to state-of-the-art methods, which do not use adversaries, we evaluate our methods on three standard datasets for for depth estimation: NYU Depth v2 [51], Make3D [48], and KITTI [12]. We also perform an ablation study for comparative analysis with and without adversarial loss.
NYUv2. NYUv2 is one of the largest RGB-D datasets for indoor scene reconstruction, with over 120K unique pairs of RGB and depth images acquired from 464 scenes with a Microsoft Kinect [51]. We worked with a 1449 aligned subset of images from NYUv2, with 795 pairs for training and 654 pairs for testing of resolution 640 × 320. During training, we downsampled the images to 386 × 288, and performed random horizontal flips with random crops of size 256 × 256. We report our scores on a pre-definend test and train split created by Eigen. [10].
Make3D. The Make3D Range Image Dataset contains image pairs of outdoor scenes (1704 × 2272) and ground truth laser depths (55 × 305), with 400 pairs for training and 134 images for testing. During training, we resized the images to 400×300, and performed similar random horizontal flips with random crops of 256 × 256 crop. On this dataset, we report C1 and C2 errors (depth ranges for 0 − 80m and 0 − 70m respectively) using the same model.
KITTI. The KITTI Vision Dataset contains image pairs of outdoor scenes (375 × 1241) and raw LiDaR scans for 61 scenes, ranging from "residential" to "city" scenes. We trained and tested with the 0-80 depth range for 32 scenes and 29 scenes respectively. In both splits, we preprocesed the images by resizing them to be 256 × 256.
Evaluation Metrics. Following previous works [26,57,29,31], we considered the following performance metrics for accurate depth estimation: In these series of comparisons, we evaluate the proposed adversarial depth estimation networks with their nonadversarial counterparts. We observed a decrease in relative error and increase in accuracy when an adversarial loss was added. In the U-Net vs. adversarial U-Net comparison, despite enforcing strong spatial consistency between the convolution and upsampling layers with long skip connections, we achieved relative errors of 0.114, 0.0646, and 0.061 on NYUv2, Make3D and KITTI respectively, which improves over the current state-of-the-art relative error by Xu et al. [57]. In addition, Adversarial U-Net also improves over accuracy on these three benchmarks, which suggests that the addition of adversarial training helped U-Net learn depth cues and more context-aware features that preserved structural details of the original image. Qualitatively, we can see how regular U-Net produced blurry results on the NYUv2 and KITTI datasets, however, after adding adversarial training, the network produced sharper edge details for objects in both the foreground and background. In contrast, the Adversarial CNN-CRF only marginally improved in relative error and accuracy with a threshold of 0.125 on NYUv2, with accuracy decreasing with a threshold of 0.125 3 . The low accuracy in the CNN-CRF can be attributed to how using a L L1 loss directly optimizes for the relative error rather than accuracy, which penalizes greater deviations in perpixel predictions from the ground truth. In addition, the relatively low accuracy of adversarial CNN-CRF may be due to the small training set used to train CNN-CRF and the fact that the loss was computed on the super-pixel level rather than the entire image.

Conclusions
In this paper, we demonstrate the effectiveness of adversarial training for monocular depth estimation from a single image across two kinds of neural network architectures: encoder-decoder style U-Net and joint CNN-CRFs. Our method approaches the depth estimation problem by incorporating an adversarial loss which captures non-local information as compared to local per-pixel losses. Unlike more complex multi-scale, deep architectures used for capturing global interactions for understanding local and nonlocal context, our approach is relatively more simple and robust. The global information is incorporated by a discriminator which aims to discriminate patches of an estimated depth prediction as real or fake. In our findings, we show how adversarial training can improve depth predictions as compared to state-of-the-art methods. This improvement is particularly pronounced for U-Net which performs weakly by itself, but outperforms state-of-the-art when adversarial loss is used.