SlowGuess/NeurIPS_2023_OCR huggingface dataset:
Yihong Sun
yihong@cs.cornell.edu
Bharath Hariharan
bharathh@cs.cornell.edu
Unsupervised monocular depth estimation techniques have demonstrated encouraging results but typically assume that the scene is static. These techniques suffer when trained on dynamical scenes, where apparent object motion can equally be explained by hypothesizing the object's independent motion, or by altering its depth. This ambiguity causes depth estimators to predict erroneous depth for moving objects. To resolve this issue, we introduce Dynamo-Depth, an unifying approach that disambiguates dynamical motion by jointly learning monocular depth, 3D independent flow field, and motion segmentation from unlabeled monocular videos. Specifically, we offer our key insight that a good initial estimation of motion segmentation is sufficient for jointly learning depth and independent motion despite the fundamental underlying ambiguity. Our proposed method achieves state-of-the-art performance on monocular depth estimation on Waymo Open [34] and nuScenes [3] Dataset with significant improvement in the depth of moving objects. Code and additional results are available at https://dynamo-depth.github.io.
Embodied agents acting in the real world need to perceive both the 3D scene around them as well as how objects around them might behave. For instance, a self-driving car executing a lane change will need to know where the nearby cars are and how fast they are moving. Instead of relying on expensive sensors such as LiDAR to estimate this structure, a promising alternative is to use commodity cameras. This has motivated a long line of work on monocular depth estimation using neural networks.
While neural networks can learn to estimate depth, the dominant training approach requires expensive 3D sensors in the training phase. This limits the amount of training data we can capture, resulting in downstream generalization challenges. One would prefer to train these depth estimators without supervision, for e.g., using unlabeled videos captured from a driving car. This is possible to do if the videos are produced by a camera moving in a static scene, since the apparent motion (i.e., optical flow) of each pixel is then inversely proportional to the depth of the pixel. This provides a useful supervisory signal for learning depth estimation and has been used effectively in the past [48, 36].
However, for unsupervised approaches to learn depth, dynamic scenes with moving objects pose a challenge. Here, the apparent pixels motion on the image plane is a combined effect of camera ego-motion (or rigid scene motion) and the independent motion of objects in the scene. Methods that ignore the presence of moving objects and treat the scene as static will then learn erroneous depth, where the depths of moving objects are altered to match their observed motion, as shown in Figure 1 (b). Past works have tried to overcome this issue by having another module predict independent object motion [31, 24, 15], but the presence of multiple equivalent solutions makes training difficult: even with sophisticated regularizers, the training can converge to the degenerate solution of either predicting the whole scene as static with incorrect depth, or predicting the entire scene as moving on a flat canvas. This results in depth error on moving objects at least 4 times as large as the error on static
(a) Input Frames
(b) Monocular Depth
(d) Monocular Depth
(e) Rigid Flow
(f) Independent Flow
Figure 1: Visualization of erroneous cases of infinite object depth and floating objects that arise from the static scene constraint. The motion of the black SUVs and white van are explained via (b) incorrect depth predictions to generate (c) the correct rigid flow for reconstruction under the static scene constraint. In contrast, Dynamo-Depth predicts (d) correct monocular depth by explicitly disentangling (f) the 3D independent flow field from (e) the camera ego-motion induced rigid flow.
background even for state-of-the-art methods. Since navigating safely around moving objects is a primary challenge in self-driving, poor depth estimation of moving objects is particularly problematic.
In this paper, we propose a new architecture and training formulation for this unsupervised learning problem that substantially improves depth accuracy for moving objects. Our key insight is that we need a good initial estimate for which pixels are independently moving (a "motion mask"). With this motion mask at hand, one can easily train depth estimation using the static pixels, and account for independent motion to correctly estimate the depth of the moving objects. However, the challenge is obtaining this motion mask in the first place: how do we identify which pixels are independently moving? First, we introduce two separate network modules that predict complete 3D scene flow and camera ego-motion. The difference between these can then be used to identify the moving objects. Second, we introduce a novel initialization scheme that stops depth training early to prevent the depth estimator from learning erroneous depth for the moving objects. This allows the motion estimation networks to learn the correct scene flow. In sum, we make the following contributions:
1. We propose a new approach, Dynamo-Depth, for learning depth estimation for dynamic scenes solely from unlabeled videos. In addition to monocular depth, Dynamo-Depth also predicts camera ego-motion, 3D independent flow, and motion segmentation.
2. We propose a new architecture that identifies independent object motion via the difference between the rigid flow field induced by camera ego-motion and a complete scene flow field to facilitate learning and regularization.
3. We propose a novel motion initialization technique that learns an early estimation of motion segmentation to explicitly resolve the ambiguity and disentangle independent motion from camera ego-motion (Figure 1). This allows the entire architecture to learn end-to-end without any additional supervision from auxiliary model predictions or ground-truth labels.
4. We evaluate on both nuScenes [3] and Waymo Open [34] and demonstrate not only state-of-the-art performance in terms of overall depth accuracy and error, but also show large improvements on moving objects by up to  $62\%$  relative gain in accuracy and  $68\%$  relative reduction in error, while achieving up to  $71.8\%$  in F1 score in motion segmentation without any supervision.
2.1 Unsupervised Monocular Depth Estimation
The framework for jointly learning monocular depth and ego-motion from unlabeled consecutive frames was first explored in [48, 36], where the objective was posed as a novel-view synthesis problem. Here, the monocular depth estimated from the target frame is coupled with the predicted ego-motion
to warp the reference frame to be photometrically consistent with the target frame. Following these works, 3D geometric consistency [28] and depth prediction consistency [1] were imposed across consecutive frames to further constrain the unsupervised learning objective. Furthermore, discrete volumes [19], uncertainty estimation [30], optical flow based pose estimation [47], minimal projection loss with auto-masking [10], and multiple input frames during inference [40, 25] were also proposed to improve depth predictions and mitigate influence of occlusion and relative stationary pixels.
Unsupervised Scene Flow. In addition to predicting depth from a single frame, a closely related task of scene flow estimation - obtaining both the 3D structure and 3D motion from two temporally consecutive images - can also be learned by leveraging the same novel-view reconstruction objective. When trained on sequences of stereo-frames, scene flow can be estimated from both stereo [18, 41] and monocular [16, 17] inputs during inference. Additionally, DRAFT [13] learned from monocular sequences only by utilizing synthetic data and multiple consecutive frames during inference.
2.2 Mitigating Static Scene Constraint
In essence, the reconstruction objective encourages pixels to be predicted at an appropriate distance away to explain its apparent motion on the image plane, when coupled with the predicted ego-motion. This assumes that all pixel motion can be sufficiently modeled by depth and camera ego-motion alone, which implies an underlying static scene. However, since dynamical objects are common in the wild, such static scene assumption is often violated. To disambiguate independent motion, recent works were proposed to leverage stereo-view information [38, 26, 11], additional input modalities [45, 8], synthetic data [13], supervised segmentation task [21], and auxiliary monocular depth network [33]. Extending from these methods, additional works proposed to mitigate the negative effects by modeling the behavior of dynamical objects without the use of additional modalities and labels.
Modeling Independent Motion via Optical Flow. Although an explainability mask [48] can be used to ignore the independently moving regions, recent works exploited the jointly learned optical flow to refine the depth prediction under non-rigid scene settings. This includes predicting a residual optical flow [43, 35] to account for dynamical objects and enforcing forward-backward flow consistency [49] to discount dynamical regions. EPC++ [27] directly modeled the dynamical objects by integrating its depth, ego-motion, and optical flow predictions. Additionally, CC [31] proposed a coordinated learning framework for joint depth and optical flow estimation assisted by a segmentation branch.
Modeling Independent Motion via 3D Non-Rigid Flow Field. Instead of modeling dynamical objects via 2D optical flow, additional works proposed to explicitly model their 3D independent flow field to encourage accurate depth learning for dynamical objects. To facilitate independent motion learning, various methods [4, 12, 22, 23, 2, 32] leveraged semantic priors from off-the-shelf pretrained detection or segmentation models to estimate regions that are "possibly moving." Additionally, Dyna-DepthFormer [46] used multi-frame information to compute the depth map, while iteratively refining the residual 3D flow field via a jointly trained motion network. Finally, Li et al. [24] proposed to jointly learn monocular depth, ego-motion, and residual flow field via a sparsity loss and RM-Depth [15] improved upon it via an outlier-aware regularization loss. Unlike [24, 15] where the residual/independent flow is predicted directly, we propose to model the 3D independent flow field via the complete scene flow, which facilitates training and effectively enforces sparsity.
3 Motivation and background
When a camera moves in a rigid scene, the apparent motion of image pixels is entirely explained by (a) their 3D position relative to the camera, and (b) the motion of the camera. This fact is used by unsupervised techniques that learn to predict depth from unlabeled videos captured as a camera moves through the scene (as in driving footage). Concretely, one network predicts depth from a target frame and another predicts the motion of the camera from the source frame to the target frame. The two predictions are then used to reconstruct a target frame from the source frame, and a reconstruction loss would serve as the primary training objective.
What happens if there are moving objects in the scene? Clearly, depth and camera-motion are not sufficient to explain the apparent image motion of these objects, resulting in a high reconstruction loss for these dynamical regions. In principle, the motion of these objects are unpredictable from a single frame, and so even though the network sees a high loss for these objects, the best it can do is to
fit the average case of a static object. As such, in principle, moving objects should not be a concern for learning-based techniques. However, in practical driving scenes, there is a large class of moving objects for which the network can in fact minimize the reconstruction loss by predicting an incorrect depth estimate. We describe this class below.
Epipolar ambiguity in driving scenes:
Consider the simple case of a pinhole camera moving forward along the  $Z$  axis (i.e., along its viewing direction). This is in fact the common case of a car driving down the road. In this case, the image location  $(x,y)$  and corresponding optical flow  $(\dot{x},\dot{y})$  for a 3D point  $(X,Y,Z)$  in the world would be:
$$
x = \frac {X}{Z}, \quad y = \frac {Y}{Z}, \quad \dot {x} = \frac {- X \dot {Z}}{Z ^ {2}} = - \frac {\dot {Z}}{Z} x, \quad \dot {y} = \frac {- Y \dot {Z}}{Z ^ {2}} = - \frac {\dot {Z}}{Z} y \tag {1}
$$
Consider what happens when this 3D point is on an object moving collinear to the camera (e.g., cars in front of the ego-car, or oncoming traffic). In this case, there are two contributions to  $\dot{Z}$ : the camera motion and the independent motion of the object. Thus, given ego-motion, one can produce the same optical flow by adding the appropriate amount of independent motion to  $\dot{Z}$ , or changing the depth  $Z$ . For example, an object can appear to move faster if it is either closer and static (i.e.,  $Z$  is smaller) or it is farther and moving towards the camera (i.e.,  $\dot{Z}$  is larger). This is a special case of epipolar ambiguity [42]. This implies that it is possible to model independent motion under the static scene constraint using an erroneous depth estimation. Unfortunately, there are statistical regularities that enable such erroneous learning.
Statistical regularities:
In self-driving scenes, there is often enough information in object appearance to predict its motion even from a single frame. The high capacity monocular depth network can learn to recover this information, and then alter its depth prediction to better reconstruct the target frame. For instance, in Figure 1 (b) the depth network may have learnt to recognize the backs of cars on the same or nearby lanes. In the training data, cars seen from the back often travel in the same direction with similar speed as the ego car, and thus have a very small optical flow in consecutive frames. The depth network therefore predicts that the car should be very far away; thus correctly predicting its optical flow, but incorrectly predicting its depth. A similar effect happens when the white van is recognized in its frontal view on the opposite lane, and the depth network predicts it to be closer to the ego-car. This allows the depth network to model the statistically-likely higher optical flow as a result of the object moving towards the camera. Furthermore, the speed of the object can also be roughly estimated from object identity (pedestrian  $<$  cyclist  $<$  car) and background context (residential  $<$  city  $<$  highway). Therefore, by recognizing the statistical regularities that give away object motion, the depth model can model the behavior of dynamical objects by predicting incorrect depth values to minimize the reconstruction objective.
This suggests that simply training a depth network on dynamic scenes is not a good solution, and an alternative framework is needed. However, we do note that learning these statistical regularities about object motion is much harder than learning the depth of the static background, since the background is a lot more consistent in its optical flow across videos and frames. Thus, we observe that this kind of overfitting to dynamical objects only happens later in training; a fact we use below.
Following past works, we formulate the learning objective as a novel-view synthesis where the target frame is reconstructed from the source frame. As shown in Section 3, modeling the rigid flow induced by camera motion alone is not sufficient for modeling the behavior of dynamical objects and causes performance degradation for moving objects. We address this by learning a separate 3D flow field that captures the independent motion of dynamical objects.
The proposed architecture (Figure 2) contains two components that collaborate together to explain the apparent pixels motion on the image plane. Section 4.1.1 details the rigid motion networks that model
Figure 2: Overview of the proposed Dynamo-Depth. The target frame  $I_{t}$  is reconstructed from source frame  $I_{s}$  by composing the 3D rigid flow  $F_{R}$  (predicted via Depth  $\mathcal{D}$  & Pose  $\mathcal{P}$ ) and 3D independent flow  $F_{I}$  (predicted via Complete Flow  $\mathcal{C}$  & Motion Mask  $\mathcal{M}$ ).<sup>1</sup>
the 3D rigid flow field (motion induced by camera while assuming a static scene), which includes the depth network  $\mathcal{D}$  and ego-motion pose network  $\mathcal{P}$ . Section 4.1.2 details the independent motion networks that model the 3D independent flow field (motion of dynamical objects), which includes the complete flow network  $\mathcal{C}$  and motion mask network  $\mathcal{M}$ .
4.1.1 Rigid Motion Networks: Depth  $\mathcal{D}$  & Pose  $\mathcal{P}$
Given a source frame  $I_{s}$  and a target frame  $I_{t}$ , we compute the 3D rigid flow induced by camera motion,  $F_{R}(p_{t})$ , for each target pixel  $p_{t}$  as follows. We first obtain the monocular depth map  $d_{t}$  by passing  $I_{t}$  to the depth network  $\mathcal{D}$  (Eq. 2). We pass  $I_{s}$  and  $I_{t}$  to the ego-motion pose network  $\mathcal{P}$  to obtain the relative camera pose  $T_{t\rightarrow s}$  (rotation and translation) (Eq. 3). We then use the depth and inverse camera intrinsics  $K^{-1}$  to back-project every target pixel  $p_{t}$  to compute its 3D location  $P_{t}$  and transform  $P_{t}$  into its corresponding 3D location,  $\hat{P}_s$ , in the source frame via  $T_{t\rightarrow s}$ . (Eq. 4). The "rigid flow" induced by camera motion is then simply  $F_{R}(p_{t}) = \hat{P}_{s} - P_{t}$ .<sup>2</sup>
$$
\mathcal {D}: \mathbb {R} ^ {H \times W \times 3} \rightarrow \mathbb {R} ^ {H \times W} \quad d _ {t} = \mathcal {D} (I _ {t}) \tag {2}
$$
$$
\mathcal {P}: \mathbb {R} ^ {H \times W \times 3} \times \mathbb {R} ^ {H \times W \times 3} \rightarrow \mathbb {R} ^ {3 \times 4} \quad T _ {t \rightarrow s} = \mathcal {P} \left(I _ {t}, I _ {s}\right) \tag {3}
$$
$$
P _ {t} = \boldsymbol {d} _ {t} \left(p _ {t}\right) K ^ {- 1} \overrightarrow {p _ {t}}, \quad \hat {P} _ {s} = \boldsymbol {T} _ {t \rightarrow s} \overrightarrow {P _ {t}}, \quad \boldsymbol {F} _ {\boldsymbol {R}} \left(p _ {t}\right) = \hat {P} _ {s} - P _ {t} \in \mathbb {R} ^ {3} \tag {4}
$$
4.1.2 Independent Motion Networks: Complete Flow  $\mathcal{C}$  & Motion Mask  $\mathcal{M}$
In addition to the rigid flow  $F_{R}$ , we also wish to model object motion via the 3D independent flow, denoted as  $\pmb{F}_{I}$ . With independent motion explicitly modeled by  $\pmb{F}_{I}$ , we reformulate  $\hat{P}_s$  as  $\hat{P}_s = (F_I(p_t) + F_R(p_t) + P_t)$  to integrate the contribution of the independent flow vector  $\pmb{F}_{I}(p_{t})$ . However, directly estimating  $\pmb{F}_{I}$  via a network turns out to be difficult for two reasons:
(a) Learning. During training, the network will need to fill in the missing independent motion vector that is appropriate for the current separately predicted monocular depth and ego-motion for a correct reconstruction: a "moving target" during training. Furthermore, it is intuitively much more difficult to learn and predict independent motion directly when the apparent motion in the input frames consists of both rigid and independent motion entangled together, especially in the ambiguous scenarios illustrated in Section 3.
(b) Regularization. Adding to this complexity,  $F_{I}(p_{t})$  should be non-zero if and only if the pixel  $I_{t}(p_{t})$  is independently moving. One could regularize this network to encourage sparsity, but early on when depth and ego-motion predictions are noisy, a high sparsity term would encourage this
$^{1}F_{C}, F_{R}, F_{I}$  and  $F_{I} + F_{R}$  are all 3D flow fields visualized as optical flow on the image plane.
$\vec{2} \rightarrow$  denotes the conversion from Cartesian to homogeneous coordinate.
network to turn off entirely. At the other end of the spectrum, a weak sparsity regularization allows independent flow  $\pmb{F}_{I}$  to be active on static regions of the scene, which would "explain away" the rigid motion  $\pmb{F}_{R}(p_{t})$  when computing  $\hat{P}_s$  and corrupt the learning signal for depth estimation. Also, conventional sparsity regularization on  $\pmb{F}_{I}$  (e.g.,  $L_{1/2}$  sparsity loss [24]) would dampen the magnitude of predicted motion, which reduces  $\pmb{F}_{I}$ 's capacity to model fast or far-away moving objects.
To address these issues, we propose to decompose the prediction of independent flow  $F_{I}(p_{t})$  in two: (1) predicting whether pixel  $I_{t}(p_{t})$  is independently moving and (2) predicting how it is moving. For (1), we model the probability of independent motion as a binary motion segmentation task where motion mask network  $\mathcal{M}$  takes the consecutive frames  $I_{t}$  and  $I_{s}$  and predict a per-pixel motion mask  $M$  as shown in Eq. 5. For (2), instead of directly predicting the independent motion, we predict the complete scene flow  $F_{C}(p_{t})$  via a complete flow network  $\mathcal{C}$  as shown in Eq. 6.
$$
\mathcal {M}: \mathbb {R} ^ {H \times W \times 3} \times \mathbb {R} ^ {H \times W \times 3} \rightarrow \mathbb {R} ^ {H \times W} \quad M = \sigma (\mathcal {M} (I _ {t}, I _ {s})) \tag {5}
$$
$$
\mathcal {C}: \mathbb {R} ^ {H \times W \times 3} \times \mathbb {R} ^ {H \times W \times 3} \rightarrow \mathbb {R} ^ {H \times W \times 3} \quad F _ {C} = \mathcal {C} \left(I _ {t}, I _ {s}\right) \tag {6}
$$
From these predictions, we formulate the independent flow field as  $\pmb{F}_{I} = \pmb{M} \cdot (\pmb{F}_{C} - \pmb{F}_{R})$ , i.e., the residual flow between  $\pmb{F}_{C}$  and  $\pmb{F}_{R}$  gated by the motion mask  $M$ . Intuitively, computing  $\hat{P}_s = (F_I(p_t) + F_R(p_t) + P_t)$  can be thought of as combining the contribution of the complete flow  $F_{C}(p_{t})$  and rigid flow  $F_{R}(p_{t})$  as a weighted average via  $M(p_{t})$  (Eq. 8).
$$
\boldsymbol {F} _ {I} = \boldsymbol {M} \cdot \left(\boldsymbol {F} _ {C} - \boldsymbol {F} _ {R}\right) \tag {7}
$$
$$
\hat {P} _ {s} = \boldsymbol {F} _ {\boldsymbol {I}} \left(p _ {t}\right) + \boldsymbol {F} _ {\boldsymbol {R}} \left(p _ {t}\right) + P _ {t} = \boldsymbol {M} \left(p _ {t}\right) \cdot \boldsymbol {F} _ {\boldsymbol {C}} \left(p _ {t}\right) + \left(1 - \boldsymbol {M} \left(p _ {t}\right)\right) \cdot \boldsymbol {F} _ {\boldsymbol {R}} \left(p _ {t}\right) + P _ {t} \tag {8}
$$
This formulation directly resolves the two aforementioned issues. For (a),  $\mathcal{C}$  has a simpler learning objective of modeling the full scene flow with per-pixel predictions, i.e.  $\hat{P}_s = F_C(p_t) + P_t$ . For (b), the sparsity regularization can be applied to  $M$  alone without any impact to the learning of  $\mathcal{C}$  and its ability to learn the complete scene flow.
Finally, we compute the reconstruction  $\hat{I}_t(p_t)$  by sampling  $I_s$  at the corresponding pixel coordinate  $\hat{p}_s$  via  $\overrightarrow{p}_s \equiv K\hat{P}_s$  for every target pixel  $p_t$ .
4.2 Loss Function
We present the overall loss function in Eq. 9. The photometric loss  $L_{recon}$  in Eq. 10 serves as the main learning objective, which evaluates the reconstruction  $\hat{I}_t$  via SSIM [39] and L1 weighted by  $\alpha$ .
$$
L = L _ {r e c o n} + L _ {s} + \gamma_ {c} L _ {c} + \gamma_ {m} L _ {m} + \gamma_ {g} L _ {g} \tag {9}
$$
$$
L _ {\text {r e c o n}} = \frac {\alpha}{2} \left(1 - \operatorname {S S I M} \left(\boldsymbol {I} _ {t}, \hat {\boldsymbol {I}} _ {t}\right)\right) + (1 - \alpha) \| \boldsymbol {I} _ {t} - \hat {\boldsymbol {I}} _ {t} \| _ {1} \tag {10}
$$
The smoothness loss  $L_{s}$  in Eq. 11 regularizes the smoothness of the predicted depth map  $d_{t}$ , complete flow  $F_{C}$ , and motion mask  $M$ . The edge-aware smoothness loss  $l_{s}(z,I) = |\delta_{x}z|\exp (-|\delta_{x}I|) + |\delta_{y}z||\exp (-|\delta_{y}I|)$  is weaker around pixels with high color variation. We also use the mean-normalized inverse depth  $d_{t}^{*}$  to discourage shrinking of the estimated depth [37].