{'fraction_non_alphanumeric': 0.03400604397512939, 'fraction_numerical': 0.011810066344784466, 'mean_word_length': 4.711168418964491, 'pattern_counts': {'":': 0, '<': 2, '<?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': 3, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Instance-wise Depth and Motion Learning from Monocular Videos

We present an end-to-end joint training framework that explicitly models 6-DoF motion of multiple dynamic objects, ego-motion and depth in a monocular camera setup without supervision. The only annotation used in our pipeline is a video instance segmentation map that can be predicted by our new auto-annotation scheme. Our technical contributions are three-fold. First, we propose a differentiable forward rigid projection module that plays a key role in our instance-wise depth and motion learning. Second, we design an instance-wise photometric and geometric consistency loss that effectively decomposes background and moving object regions. Lastly, we introduce an instance-wise mini-batch re-arrangement scheme that does not require additional iterations in training. These proposed elements are validated in a detailed ablation study. Through extensive experiments conducted on the KITTI dataset, our framework is shown to outperform the state-of-the-art depth and motion estimation methods.


Introduction
Knowledge of the 3D environment structure and the motion of dynamic objects is essential for autonomous navigation [10,28]. The 3D structure is valuable because it implicitly models the relative position of the agent, and it is also utilized to improve the performance of the highlevel scene understanding such as detection and segmentation [17,29,1,16]. Besides scene structure, the 3D motion of the agent and traffic participants such as pedestrians and vehicles is also required for safe driving. The relative direction and speed between them are taken as the primary inputs for determining the next direction of travel.
Recent advances in deep neural networks (DNNs) have led to a surge of interest in depth prediction using monocular images [8,9] and stereo images [22,5], as well as in optical flow estimation [7,30,20]. These supervised methods require a large amount and broad variety of training data with ground-truth labels. Studies have shown significant progress in unsupervised learning of depth and ego-motion from unlabeled image sequences [39,12,32,21,26]. The joint optimization framework uses a network for predicting single-view depth and pose, and exploits view synthesis of images in the sequence as the supervisory signal. However, these works ignore or mask out regions of moving objects for pose and depth inference. In this work, rather than consider moving object regions as a nuisance [39,12,32,21,26], we utilize them as an important clue for estimating 3D object motions. This problem can be formulated as motion factorization of object motion and ego-motion. Factorizing object motion in monocular sequences is challenging problem, especially in complex urban environments that contain many dynamic objects. Moreover, deformable dynamic objects such as humans make the problem more difficult because of the greater inaccuracy in their correspondence [27].
To address this problem, we propose a novel framework that explicitly models 3D motions of dynamic objects and ego-motion together with scene depth in a monocular camera setting. Our unsupervised method relies solely on monocular video for training (without any ground-truth labels) and imposes a photo-consistency loss on warped frames from one time step to the next in a sequence. Given two consecutive frames from a video, the proposed neural network produces depth, 6-DoF motion of each moving object, and the egomotion between adjacent frames as shown in Fig. 1. In this process, we leverage the instance mask of each dynamic object, obtained from an off-the-shelf instance segmentation module.
Our main contributions are the following: Forward image warping Differentiable depth-based rendering (which we call inverse warping) was introduced in [39], where the target view I t is reconstructed by sampling pixels from a source view I s based on the target depth map D t and the relative pose T t→s . The warping procedure is effective in static scene areas, but the regions of moving objects cause warping artifacts because the 3D structure of the source image I s may become distorted after warping based on the target image's depth D t [4]. To build a geometrically plausible formulation, we introduce forward warping which maps the source image I s to the target viewpoint based on the source depth D s and the relative pose T s→t . There is a well-known remaining issue with forward warping that the output image may have holes. Thus, we propose the differentiable and hole-free forward warping module that works as a key component in our instance-wise depth and motion learning from monocular videos. The details are described in Sec. 3.2.
Instance-wise photometric and geometric consistency Existing works [3,15] have successfully estimated independent object motion with stereo cameras. Approaches based on stereo video can explicitly separate static and dynamic motion by using stereo offset and temporal information. On the other hand, estimation from monocular video captured in the dynamic real world, where both agents and objects are moving, suffers from motion ambiguity, as only temporal clues are available. To address this issue, we introduce instance-wise view synthesis and geometric consistency into the training loss. We first decompose the image into background and object (potentially moving) regions using a predicted instance mask. We then warp each component using the estimated single-view depth and camera poses to compute photometric consistency. We also impose a geometric consistency loss for each instance that constrains the estimated geometry from all input frames to be consistent. Sec. 3.3 presents our technical approach (our loss and network details) for inferring 3D object motion, ego-motion and depth.
Mini-batch arrangement Our work aims to recover instance-wise 6-DoF object motion regardless of how many instances the scene contains. To accomplish this efficiently, we propose an instance-wise mini-batch arrangement technique that organizes mini-batches with respect to the total number of instances to avoid iterative training.
KITTI video instance segmentation dataset We introduce an auto-annotation scheme to generate a video instance segmentation dataset, which is expected to contribute to various areas of self-driving research. The role is this method is similar to that of [34], but we design a new framework that tailored to driving scenarios. Details are described in Sec. 3.4.
State-of-the-art performance Our unsupervised monocular depth and pose estimation is validated with a performance evaluation, presented in Sec. 4, which shows that our jointly learned system outperforms earlier approaches.
Our codes, models, and video instance segmentation dataset will be made publicly available.

Related Works
Unsupervised depth and ego-motion learning Several works [39,12,32,21,26] have studied the inference of depth and ego-motion from monocular sequences. Zhou et al. [39] introduce an unsupervised learning framework for depth and ego-motion by maximizing photometric consistency across monocular videos during training. Godard et al. [12] offer an approach replacing the use of explicit depth data during training with easier-to-obtain binocular stereo footage. It trains a network by searching for the correspondence in a rectified stereo pair that requires only a one-dimensional search. Wang et al. [32] show that Direct Visual Odometry (DVO) can be used to estimate the camera pose between frames and the inverse depth normalization leads to a better local minimum. Mahjourian et al. [21] combine 3D geometric constraints using Iterative Closest Point (ICP) with a photometric consistency loss. Ranjan et al. [26] propose a competitive collaboration framework that facilitates the coordinated training of multiple specialized neural networks to solve joint problems. Recently, there have been two works [2,6] that achieve state-of-the-art performance on depth and egomotion estimation using geometric constraints.
Learning motion of moving objects Recently, the joint optimization of dynamic object motion along with the depth and ego-motion [4,3] has gained interest as a new research topic. Casser et al. [4] present an unsupervised image-todepth framework that models the motion of moving objects and cameras. The main idea is to introduce geometric structure in the learning process, by modeling the scene and the individual objects; camera ego-motion and object motions are learned from monocular videos as input. Cao et al. [3] propose a self-supervised framework with a given 2D bounding box to learn scene structure and object 3D motion  from stereo videos. They factor the scene representation into independently moving objects with geometric reasoning. However, this work is based on a stereo camera setup and computes the 3D motion vector of each instance using simple mean filtering.

Video instance segmentation
The task of video instance segmentation (VIS) is to simultaneously conduct detection, segmentation and tracking of instances in videos. Yang et al. [34] first extend the image instance segmentation problem to the video domain. To facilitate research on this new task, they present a large-scale dataset and a new tracking branch to Mask R-CNN to jointly perform the detection, segmentation and tracking tasks simultaneously.

Methodology
We introduce an end-to-end joint training framework for instance-wise depth and motion learning from monocular videos without supervision. Figure 2 illustrates an overview of the complete pipeline. The core of our method is a novel forward rigid projection module to align the depth map from adjacent frames and an instance-wise training loss. In this section, we introduce the forward projective geometry and the networks for each type of output: DepthNet, Ego-PoseNet, and Obj-PoseNet. Further, we describe our novel loss functions and how they are designed for backpropagation in decomposing the background and moving object regions.

Method Overview
Baseline Given two consecutive RGB images (I 1 , I 2 ) ∈ R H×W ×3 , sampled from an unlabeled video, we first predict their respective depth maps (D 1 , D 2 ) via our presented DepthNet D θ : R H×W ×3 → R H×W with trainable parameters θ. By concatenating two sequential images as an input, our proposed Ego-PoseNet E φ : R 2×H×W ×3 → R 6 , with trainable parameters φ, estimates the six-dimensional SE(3) relative transformation vectors (P 1→2 , P 2→1 ). With the predicted depth, relative ego-motion, and a given camera intrinsic matrix K ∈ R 3×3 , we can synthesize an adjacent image in the sequence using an inverse warping operation F iw (I i , D j , P j→i , K) →Î i→j , whereÎ i→j is the reconstructed image by warping the reference frame I i [39,13]. As a supervisory signal, an image reconstruction loss, L rec = ||I j −Î i→j || 1 , is imposed to optimize the parameters, θ and φ.
Instance-wise learning The baseline method has a limitation that it cannot handle dynamic scenes containing moving objects. Our goal is to learn depth and ego-motion, as well as object motions, using monocular videos by constraining them with instance-wise geometric consistencies. We propose an Obj-PoseNet O ψ : R N ×H×W ×3 → R 6 with trainable parameters ψ and N number of instances, which is specialized to estimating individual object motions. We annotate a novel video instance segmentation dataset to utilize it as an individual object mask while training the ego-motion and object motions. The details of the video instance segmentation Figure 3: Warping discrepancy occurs for inverse projection of moving objects.
dataset will be described in Sec. 3.4. Given two consecutive binary instance masks (M i 1 , M i 2 ) ∈ {0, 1} H×W ×n corresponding to (I 1 , I 2 ), n-instances are annotated and matched between the frames. First, in the case of camera ego-motion, potentially moving objects are masked out and only the background region is fed to Ego-PoseNet. Secondly, the n-binary instance masks are multiplied to the input images and fed to Obj-PoseNet. For both networks, motions of the k th element are represented as P i=k 1→2 , where k = 0 means camera ego-motion from frame I 1 to I 2 . The details of the motion models will be described in the following subsections.
Training objectives The previous works [21,2,6] imposed geometric constraints between frames, but they are limited to rigid projections. Regions containing moving objects cannot be constrained with this term and are treated as outlier regions with regard to geometric consistency. In this paper, we propose instance-wise geometric consistency. We leverage instance masks to impose geometric consistency region-by-region. Following instance-wise learning, our overall objective function can be defined as follows: where (L r , L g ) are the reconstruction and geometric consistency losses applied on each instance region including the background, L s stands for the depth smoothness loss, and (L t , L h ) are the object translation and height constraint losses. {λ r , λ g , λ s , λ t , λ h } is the set of loss weights. We train the models in both forward (I 1 → I 2 ) and backward (I 2 → I 1 ) directions to maximally use the self-supervisory signals. In the following subsections, we introduce how to constrain the instance-wise consistencies.

Forward Projective Geometry
A fully differentiable warping function enables learning of structure-from-motion tasks. This operation is first proposed by spatial transformer networks (STN) [13]. Previous works for learning depth and ego-motion from unlabeled videos so far follow this grid sampling module to synthesize adjacent views. To synthesizeÎ 1→2 from I 1 , the homogeneous coordinates, p 2 , of a pixel in the I 2 are projected to p 1 as follows: As expressed in the equation, this operation computesÎ 1→2 by taking the value of the homogeneous coordinates p 1 from the inverse rigid projection using P i=0 2→1 and D 2 (p 2 ). As a result, the coordinates p 1 are not valid if p 2 lies on an object that moves between I 1 and I 2 . Therefore, the inverse warping operation is not suitable for removing the effects of ego-motion in dynamic scenes. Figure 3 describes the point discrepancy while geometric warping with the rigid structure assumption. As shown in Figure 4, the inverse warping distorts the appearance of moving objects.
In order to synthesize the novel view (from I 1 toÎ 1→2 ) properly when there exist moving objects, we propose forward projective geometry F f w (I i , D i , P i→j , K) →Î i→j as follows: Unlike inverse projection in Eq. (2), this warping process cannot be sampled by the STN since the projection is in the forward direction (inverse of grid sampling). In order to make this operation fully differentiable, we first use sparse tensor coding to index the homogeneous coordinates p 2 , of a pixel in the I 2 . Invalid coordinates (exiting the view where p 2 / ∈ {(x, y)|0 ≤ x < W, 0 ≤ y < H}) of the sparse tensor are masked out. We then convert this sparse tensor to be dense by taking the nearest neighbor value of the source pixel. However, this process has a limitation that there exist irregular holes due to the sparse tensor coding. Since we need to feed those forward projected images into the neural networks in the next step, the size of the holes should be minimized. To fill these holes as much as possible, we preupsample the depth map D ↑ 1 (p 1 ) of the reference frame. If the depth map is upsampled by a factor of α, the camera intrinsics matrix is also upsampled as follows: where (f x , f y ) are focal lengths along the xand y-axis. Figure 5 shows the effect of pre-upsampling reference depth while forward warping. With an upsampling factor of α = 2 during forward projection, the holes in the warped valid masks are filled properly. In the following subsection, we describe the steps of how to synthesize novel views with inverse and forward projection in each instance region.

Instance-wise View Synthesis and Geometric Consistency
Instance-wise reconstruction Each step of the instancewise view synthesis is described in Figure 2. To synthesize a novel view in an instance-wise manner, we first decompose the image region into background and object (potentially moving) regions. With given instance masks (M i 1 , M i 2 ), the background mask along frames (I 1 , I 2 ) is generated as ).
(5) The background mask is element-wise multiplied ( , Hadamard product) to the input frames (I 1 , I 2 ), and then concatenated along the channel axis, which is an input to the Ego-PoseNet. The camera ego-motion is computed as To learn the object motions, we first apply the forward warping, F f w (·), to generate ego-motion-eliminated warped im-ages and masks as follows: where both equations are applied in the backward direction as well by changing the subscripts 1 and 2 . Now we can generate forward-projected instance images asÎ f w,i=k For every object instance in the image, Obj-PoseNet predicts the k th object motion as where both object motions are composed of six-dimensional SE(3) translation and rotation vectors. We merge all instance regions to synthesize the novel view. In this step, we utilize inverse warping, F iw (·). First, the background region is reconstructed aŝ where the gradients are propagated with respect to θ and φ. Second, the inverse-warped k th instance region is represented aŝ where the gradients are propagated with respect to θ and ψ. Finally, our instance-wise fully reconstructed novel view is formulated aŝ Note that the above three equations are applied in either the forward or backward directions by switching the subscripts Instance-wise mini-batch re-arrangement While training Obj-PoseNet, the number of instance images may change after each iteration. In order to avoid inefficient iterative training, we fix the maximum number of instances per image (sampled in order of instance size) and intermediately re-arrange the mini-batches with respect to the total number of instances in the mini-batch. For example, if the mini-batch has four frames and each frame has {3, 1, 0, 2}number of instances, then the re-arranged mini-batch size is 3 + 1 + 0 + 2 = 6. The scale of the gradients while training Obj-PoseNet is normalized according to the total number of instances per mini-batch.
Instance mask propagation Through the process of forward and inverse warping, the instance mask is also propagated to contain the information of instance position and pixel validity. In the case of the k th instance mask M i = k 1 , the forward and inverse warped mask is expressed as follows: Note that the forward warped maskM f w,i=k 1→2 has holes due to the sparse tensor coding. To keep the binary format and avoid interpolation near the holes while inverse warping, we round up the fractional values after each warping operation. The final valid instance mask is expressed as follows: Instance-wise geometric consistency We impose the geometric consistency loss for each region of an instance. Following the work by Bian et al. [2], we constrain the geometric consistency during inverse warping. With the predicted depth map and warped instance mask, D 1 can be spatially aligned to the frame D 2 by inverse warping, represented as M i=0 D iw 1→2 respectively for background and instance regions. In addition, D 2 can be scale-consistently transformed to the frame D 1 , represented as M i=0 D tr 1→2 respectively for background and instance regions. Based on this instancewise operation, we compute the unified depth inconsistency map as: where each line is applied to either the background or an instance region, and both are applied in either the forward and backward directions by changing the subscripts 1 and 2 . Note that the above depth inconsistency maps are spatially aligned to the frame D 2 . Therefore, we can integrate the depth inconsistency maps from the background and instance regions as follows: Training loss In order to handle occluded, view-exiting, and valid instance regions, we leverage Eq. (23) and Eq. (17).
We generate a weight mask as 1 − D dif f 1→2 and this is multiplied to the valid instance maskM 1→2 . Finally, our weighted valid mask is formulated as: The reconstruction loss L r is expressed as follows: where x is the location of each pixel, SSIM (·) is the structural similarity index [33], and γ is set to 0.8 based on crossvalidation. The geometric consistency loss L g is expressed as follows: To mitigate spatial fluctuation, we incorporate a smoothness term to regularize the predicted depth map. We apply the edge-aware smoothness loss proposed by Ranjan et al. [26], which is described as: Note that the above loss functions are imposed for both forward and backward directions by switching the subscripts 1 and 2 .
Since the dataset has low proportion of moving objects, the motions of objects tend to learn to converge to zero. The same issue has been raised in the previous study [4]. To supervise the approximate amount of object's movement, we constrain the motion of the object with a translation prior. We compute this translation prior, t p , by subtracting the mean estimation of the object's 3D points in the forward warped frame into that of the target frame's 3D object points. This represents the mean estimated 3D vector of the object's motion. The object translation constraint loss is defined as follows: where t i=k and t i=k p are predicted object translation from Obj-PoseNet and the translation prior on the k th instance mask. Although we have designed the instance-wise geometric consistency, there still exists a trivial case of the infinite depth of the moving object, which has the same motion as the camera motion, especially the vehicles in front. To mitigate this issue, we adopt the object height constraint loss proposed by the previous study [4], which is described as: where D is the mean estimated depth, and (p i=k h , h i=k ) are learnable height prior and pixel height of the k th instance. The final loss is a weighted summation of those five losses defined as Eq. (1).

Auto-annotation of Video Instance Segmentation Dataset
We introduce an auto-annotation scheme to generate a video instance segmentation dataset from the existing KITTI autonomous driving dataset [11]. To this end, we adopt an off-the-shelf instance segmentation model, PANet [19], and an optical flow estimation model, PWC-Net [30]. Figure 6 shows an example case between two consecutive frames. We first compute the instance segmentation for every image frame, and calculate the Intersection over Union (IoU) score table among instances in each frame. The occluded and disoccluded regions are handled by bidirectional flow consensus proposed in UnFlow [23]. If the maximal IoU in the adjacent frame is above a threshold, then the instance is assumed as matched. Our KITTI video instance segmentation dataset (KITTI-VIS) will be publicly available.

Experiments
We evaluate the performance of our frameworks and compare with previous unsupervised methods on single view depth and visual odometry tasks. We train and test our method on KITTI [11] for benchmarking.

Implementation Details
Network details For DepthNet, we use DispResNet [26] based on ResNet-50 with an encoder-decoder structure. The network can generate multi-scale outputs (six different scales), but the single-scale training converges faster and produces better performance (based on the Abs Rel error metrics). The structures of Ego-PoseNet and Obj-PoseNet are the same, but the weights are not shared. They consist of seven convolutional layers and regress the relative pose as three Euler angles and three translation vectors.
Training Our system is implemented in PyTorch [25]. We train our neural networks using the ADAM optimizer [14] with β 1 = 0.9 and β 2 = 0.999 on 4×Nvidia RTX 2080 GPUs. The training image resolution is set to 832 × 256 and the video data is augmented with random scaling, cropping, and horizontal flipping. We set the mini-batch size to 4 and train the networks over 200 epochs with 1,000 randomly sampled batches in each epoch. The initial learning rate is set to 10 −4 and is decreased by half every 50 epochs. The loss weights are set to λ r = 1.0, λ g = 0.5, λ s = 0.05, λ t = 0.1, and λ h = 0.001. While training, we take three consecutive frames as input to train our joint networks. Our three-frame cyclic training is described in Figure 7. Dynamic scenes are hard to handle with rigid projective geometry in a one-shot manner. We utilize an intermediate frame which enables decomposition of ego-motion-driven global view synthesis and residual view synthesis by object motions. From this, several warping directions can be proposed. The arrows in Figure 7 represent the warping direction of RGB images and depth maps. We tried to optimize Obj-PoseNet by warping to

Ablation Study
To validate the effect of our forward projective geometry and instance-wise geometric consistency term, we conduct an ablation study that compares to the baseline method. As shown in Table 1, our forward projection works effectively and leads to convergence of DepthNet. It shows that each proposed module improves the quality of depth maps and the best performance is achieved with all proposed components. We observe that Obj-PoseNet did not converge without forward projection with the instance-wise geometric loss, so the performance of DepthNet was not improved. In other words, optimized Obj-PoseNet helps to boost the performance of DepthNet. DepthNet and Obj-PoseNet complement each other. We note that the significant performance improvement comes from the instance-wise geometric loss incorporated with forward projection.

Monocular Depth Estimation
Test setup Following the test setup proposed for SfM-Learner [39], we train and test our models with the Eigen split [8] of the KITTI dataset. We compare the performance of the proposed method with recent state-of-the-art works [6,4,2,26] for unsupervised single-view depth estimation.
Results analysis We show qualitative results on singleview depth estimation in Figure 8. The compared methods are CC [26] and SC-SfM [2], which have the same network structure (ResNet-based) for depth map prediction. Ours produces better depth representations on moving objects than the previous methods. As the previous studies do not consider dynamics of objects when finding pixel correspondences, their results of training on object distance could be either farther or closer than the actual distance. This is a traditional limitation for the task of self-supervised learning of depth from monocular videos, however our networks self-disentangle moving and static object regions by our instance-wise losses. Table 2 shows the results on the KITTI Eigen split test, where the proposed method achieves state-of-the-art performance in the single view depth prediction task with unsupervised training. The advantage is evident of using instance masks and constraining the instance-wise photometric and geometric consistencies. Note that we do not need instance masks in the test phase for DepthNet.

Visual Odometry Estimation
Test setup We evaluate the performance of our Ego-PoseNet on the KITTI visual odometry dataset. Following the evaluation setup of SfM-Learner [39], we use the sequences 00-08 for training, and sequences 09 and 10 for tests. In our case, since the potentially moving object masks are fed together with the image sequences while training Ego-PoseNet, we test the performance of visual odometry under two conditions: with and without instance masks. Table 3 shows the results on the KITTI visual odometry test. We measure the Absolute Trajectory Error (ATE) and achieve state-of-the-art performance. Although we do not use the instance mask, the result of sequence 10 produces favorable performance. This is because the scene does not have many potentially moving objects, e.g., vehicles and pedestrians, so the result is not affected much by using or not using instance masks.

Conclusion
In this work, we proposed a novel framework that predicts 6-DoF motion of multiple dynamic objects, ego-motion and depth with monocular image sequences. Leveraging video instance segmentation, we design an end-to-end joint training pipeline in an unsupervised manner. There are four main contribution of our work: (1) an auto-annotation scheme for video instance segmentation, (2) differentiable forward image warping, (3) instance-wise view-synthesis and geometric consistency loss, (4) mini-batch re-arrangement. We show that our method outperforms the existing methods that estimates object motion, ego-motion and depth. We also show that each proposed module plays a role in improving the performance of our framework.