Abstract
Standard training protocols for optical flow and stereo depth estimation often treat all pixels with equal importance, failing to account for varying learning difficulties and the presence of occlusions. This paper proposes two novel loss functions: Difficulty Balancing (DB) and Occlusion Avoiding (OA). DB loss focuses the model's attention on "hard" pixels based on current prediction errors, while OA loss utilizes cycle consistency to intelligently weight occluded regions. Experimental results on KITTI and Sintel benchmarks show that these uncertainty-aware losses lead to significant performance gains across multiple state-of-the-art architectures.
Introduction
In computer vision, optical flow and stereo depth estimation are fundamental tasks that rely on feature matching between images. Optical flow tracks pixel movement between video frames, while stereo depth calculates distances from binocular image pairs. Traditionally, these models are trained using a uniform loss function, penalizing errors equally regardless of the local image context.
However, this "one-size-fits-all" approach overlooks two critical challenges:
- Varying Difficulty: Regions with low texture or complex lighting are inherently harder to match than well-defined features.
- Occlusions: Pixels that appear in one frame but are hidden in the next lack a true match. Forcing a model to find a correspondence for occluded pixels often leads to overfitting and degraded performance.
Methodology
The researchers introduce an uncertainty-aware training strategy composed of two primary components: Difficulty Balancing (DB) and Occlusion Avoiding (OA).
Difficulty Balancing (DB) Loss
The DB loss serves as an error-based confidence measure. By assigning higher weights to pixels where the model's current prediction deviates significantly from the ground truth, it forces the network to prioritize learning from challenging samples. This approach builds upon the principles of Regression Focal Loss (RFL) to act as a spatial attention mechanism.
Occlusion Avoiding (OA) Loss
To handle occlusions, the OA loss employs a "cycle consistency" check. The model predicts motion both forward (Frame 1 to 2) and backward (Frame 2 to 1). If a pixel's forward-backward trajectory does not return to its origin, it is flagged as likely occluded. Rather than discarding these pixels—which would prevent the model from learning to infer motion in occluded areas—the OA loss reduces their weight to a minimum threshold. This guides the network to rely more on matchable regions while still maintaining some learning signal for occlusions.
For optical flow, a multiplicative combination of these losses proved most effective. In stereo depth, a "Mask-Sum" approach—applying a hard mask to the DB loss in occluded regions—yielded superior results.
Experiments and Results
The proposed methods were evaluated using state-of-the-art architectures, including RAFT, FlowFormer, and RAFT-Stereo, across several high-stakes benchmarks:
- Optical Flow: Evaluated on Sintel and KITTI 2012/2015 after training on FlyingChairs and FlyingThings3D.
- Stereo Depth: Evaluated on ETH3D, Middlebury, Sintel, and KITTI after training on SceneFlow.
Key Results
The improvements were consistent across all tested models and datasets. For instance, on the KITTI dataset, the RAFT baseline's End-Point Error (EPE) decreased from 5.04 to 4.50 when using the combined DB+OA loss. On the ETH3D benchmark for stereo depth, the error rate (pixels with >0.5px error) dropped from 7.04% to 5.07%.
Qualitatively, models trained with these losses exhibit sharper object boundaries and better preservation of thin structures, such as poles or cables, compared to standard baselines.
Discussion
A key insight of this work is the "Goldilocks" strategy for occlusions: neither ignoring them nor treating them normally. By keeping occluded pixels in the training loop with reduced weights, the model learns to "hallucinate" motion or depth reasonably without the high errors dominating the gradient. Furthermore, the multiplicative synergy between DB and OA is crucial; since occluded pixels naturally have high errors, DB would normally increase their weight, while OA seeks to decrease it. Multiplying the confidence maps effectively balances these opposing signals.
Conclusion and Future Work
While the proposed losses significantly improve accuracy, they introduce some training overhead due to the required backward pass for OA loss calculation. Additionally, the method's effectiveness depends on tuning hyperparameters ($\alpha$ and $\beta$) that control the focus on difficult pixels. Future research could explore extending this uncertainty-aware framework to other pixel-wise tasks such as semantic segmentation or image matting.
Summary updated