Paper commentary
Towards Robust Monocular Depth Estimation: Mixing Datasets for Zero-shot Cross-dataset Transfer
Monocular depth models can be trained on mixed incompatible datasets
- Problem Depth datasets differ in sensors and annotations, so no single one covers diverse scenes well. Their annotations also disagree in scale and shift, so they cannot simply be pooled.
- Method The authors predict disparity and train with a scale- and shift-invariant loss, so incompatible annotations can be mixed. Mixing uses either equal shares per dataset or a Pareto-optimal rule.
- Results The full model reaches an average rank of 2.0 across six zero-shot test datasets, the best of the methods compared.
Why one depth dataset is not enough
Monocular depth estimation is an underconstrained problem, so models need large and varied training data, and collecting dense ground-truth depth at that scale is hard. Structured light, time-of-flight and laser sensors have limited range or operating conditions, and stereo collections are difficult to gather across many environments. Structure-from-motion reconstructions miss independently moving objects and leave gaps, so each source is biased in its own way.
The datasets also disagree in what their annotations mean: some give absolute metric depth, some give depth only up to a scale, and some give disparity only up to a scale and a global shift. Mixing such sources therefore requires an output space and a loss that do not depend on the unknown scale and shift of each annotation.
The study asks whether such incompatible data can be trained on jointly to improve generalization, and which rule should set the proportions in which the datasets are drawn. Generalization is measured with zero-shot cross-dataset transfer, where the model is evaluated on datasets it never saw during training and is not fine-tuned on them.
Aligning predictions to annotations
The model predicts a dense disparity map, and the loss is computed over the pixels of each image that have valid ground truth. The per-sample loss averages a per-pixel penalty over the M valid pixels, after prediction and ground truth have been brought to a common scale and shift.
The first alignment uses least squares: a scale and a shift are fitted so that the prediction best matches the ground truth, and the fit has a closed-form solution from the normal equations. Aligning the ground truth to the prediction in the same way would make the loss ambiguous, so only the prediction is transformed to the ground truth values in this variant.
This alignment with the squared penalty gives a scale- and shift-invariant mean squared error.
The robust variant does not fit a least-squares line; it centers each map by its median and divides by the mean absolute deviation from that median, for both prediction and ground truth. With this normalization, a penalty on absolute deviations gives a loss that outliers in the ground truth affect less than they affect the squared version.
Trimming residuals and matching gradients
The number of kept residuals, 0.8M, was chosen empirically on the ReDWeb dataset.
The gradient matching term compares the spatial gradients of the residual between prediction and ground truth across four scale levels, halving the resolution at each level. The final loss for each training set averages the scale- and shift-invariant term and adds this term with the weight alpha set to 0.5.
Eigen et al. use a scale-invariant loss in log-depth space, which does not account for a global disparity shift, and the ordinal loss of Chen et al. only uses sparse relative ordering. The normalized multiscale gradient loss of Wang et al. accounts for scale and shift through gradients, while the losses in this study act directly on ground-truth disparity values.
3D Movies as a training source
Stereo films offer a large source of stereo pairs captured under controlled conditions, which makes them a possible source of diverse dynamic scenes. The data has no metric depth, so only relative depth can be derived from it, in the same way as for ReDWeb and WSVD. Focal lengths, baselines and convergence angles are unknown and change within a film, and disparities can be both positive and negative because the screen depth is set in post-production.
The authors selected 23 movies that were shot with a physical stereo camera, cover a range of content and are available on Blu-ray, which allows high-resolution extraction. Frames were extracted at 1920x1080 and 24 fps, center-cropped to 1880x800 to remove black bars, and split into clips with a scene detection threshold of 0.1. Clips shorter than one second were discarded, the first and last chapters were dropped, and the training set was subsampled to 4 fps while the test and validation sets were subsampled to 1 fps.
Disparity is taken as the horizontal component of an optical flow computed from left to right and from right to left, since flow handles both positive and negative disparities. Pixels whose left-right disagreement exceeds 2 pixels are marked invalid, and sky pixels are set to the minimum disparity of the image after semantic segmentation.
Frames are rejected when more than 10% of pixels have a vertical disparity above 2 pixels, when the horizontal disparity range is below 10 pixels, or when fewer than 70% of pixels pass the consistency check. After this filtering the training set has 75074 frames, the validation set 3058 and the test set 788, drawn from 19 training movies and two each for validation and testing.
Two ways to mix datasets
The naive strategy fills each minibatch with equal shares from every dataset, so a minibatch of size B draws B divided by L samples from each of the L datasets, regardless of dataset size. Because this gives every dataset the same weight in the effective training set, large datasets are not allowed to dominate.
The second strategy treats the loss on each dataset as a separate objective and seeks an approximate Pareto optimum, a point where no dataset's loss can be lowered without raising another's. The model parameters are shared across all datasets, and the algorithm from earlier multi-task work is used to minimize the vector of losses.
Batch size is set to 8L, so a mix of three datasets uses a batch of 24, and an epoch is defined as processing 72,000 images rather than a full pass over each dataset. Training runs for 60 such epochs from the pretrained ReDWeb model.
Which loss gives the lowest validation error
Each loss was used to train a network on ReDWeb, and the networks were evaluated on held-out validation sets of ReDWeb, MegaDepth and 3D Movies. Errors are reported relative to the trimmed MAE loss combined with the gradient term, which serves as the reference.
The compared losses are the ordinal loss with 5,000 randomly sampled pairs, the scale-invariant log loss with gradient regularization, the normalized multiscale gradient loss, and several variants of the scale- and shift-invariant mean squared and absolute error. Among these, the trimmed MAE loss has the lowest validation error on all validation sets, and the four proposed losses are all shown to be better than the current losses in the figure.
The trimming ratio was set on ReDWeb, so the comparison uses that dataset to choose a setting that the validation sets then assess.
How the encoder changes depth accuracy
The baseline is a ResNet-50 multi-scale encoder following Xian et al., and the other encoders tested are ResNet-101, ResNeXt-101, DenseNet-161 and a ResNeXt-101 pretrained on weakly supervised data. All encoders were pretrained on ImageNet, and all models were fine-tuned on ReDWeb and evaluated on the validation sets.
The weakly-supervised ResNeXt-101 performs significantly better than the same encoder trained only on ImageNet.
Across encoders, ImageNet performance is a strong predictor of depth performance, and the best encoder gives up to 15% relative improvement over the baseline without task-specific changes. ResNeXt-101-WSL is used for all later experiments.
Single datasets versus mixing
Each single training set was used to fine-tune the model, and the relative performance is shown against the ReDWeb baseline. Each single dataset used alone yields a lower average than ReDWeb, so gains on compatible test sets are offset elsewhere.
MegaDepth and WSVD are much larger but show worse individual performance than ReDWeb, and the authors partly attribute this to redundant frames from video sources and to the stricter manual filtering of ReDWeb. Between WSVD and 3D Movies, the 3D Movies model generalizes better, which the authors attribute to the more controlled capture of the stereo pairs.
With naive mixing, the five mixtures score between 18.3 and 19.5 mean percent relative to ReDWeb, and adding a dataset does not always help, since MIX 2 is below MIX 1. The naive mixtures reach mean WHDR values between 12.62 and 13.62 on DIW and AbsRel values between 0.132 and 0.135 on ETH3D.
Combining all five datasets with Pareto-optimal mixing gives the best model, MIX 5.
Comparison with published depth methods
Each method's input size follows its own evaluation script, with reflection padding for the KITTI-trained methods and tiling for DORN.
The full model has an average rank of 2.0 and the smaller ResNet-50 variant has 2.7, ahead of the next method, the MegaDepth-trained model of Li and Snavely at 5.7. The smaller variant is equivalent to the network of Xian et al., so its result separates the effect of the training scheme from the effect of a larger encoder.
In relative terms, the smaller variant scores −16.0 percent on average and the Xian et al. model −65.1 percent against the full model. On the TUM subset chosen by Li et al., the full model is ahead of their Mannequin Challenge model.
Limitations and failure cases
Methods fine-tuned on one dataset, such as KITTI or NYU, perform very well there but much worse on the other test sets, because they carry strong priors about one environment.
The model has learned that lower image regions are usually closer to the camera, a bias that also appears in human annotations, where a 85.8% agreement rate was reported for the DIW annotators. On a rotated input the network fails to recover the ground plane, and the authors suggest rotation augmentation as a possible fix while noting that rotation invariance may not be wanted here.
Paintings, photos and mirrors are often read by their content rather than as flat surfaces, and strong edges can create false depth discontinuities. Thin structures can be missed, relative arrangement of disconnected objects can fail, and background regions tend to blur, which the authors link to input resolution and imperfect far-range ground truth.
The DAVIS video results are qualitative, were produced with no temporal information, and come from monocular footage without ground-truth depth.
Paper info
- Authors
- René Ranftl, Katrin Lasinger, David Hafner, Konrad Schindler, Vladlen Koltun
- Venue
- arXiv · Preprint
- First published
- 2019-7-2
- Added
- 2026-11-12
- Updated
- 2020-8-25
- Version
- v3
- arXiv
- 1907.01341
- Category
- cs.CV
- Original paper terms
- arXiv non-exclusive 1.0
- What we show
- Paper info and commentary
AI commentary is a separate explanation from the original paper and may contain errors. The original paper and figures follow each source's terms of use and any rights noted separately.
Quote from the paper
René Ranftl, Katrin Lasinger, David Hafner, Konrad Schindler, Vladlen Koltun (2019). Towards Robust Monocular Depth Estimation: Mixing Datasets for Zero-shot Cross-dataset Transfer. arXiv:1907.01341v3. https://arxiv.org/abs/1907.01341v3
BibTeX
@misc{ranftl2019towards,
title = {{Towards Robust Monocular Depth Estimation: Mixing Datasets for Zero-shot Cross-dataset Transfer}},
author = {René Ranftl and Katrin Lasinger and David Hafner and Konrad Schindler and Vladlen Koltun},
year = {2019},
eprint = {1907.01341},
archivePrefix = {arXiv},
url = {https://arxiv.org/abs/1907.01341v3}
}