Abstract
DSAC (Differentiable SAmple Consensus) introduces a method to integrate the classic RANSAC algorithm into deep learning pipelines by treating hypothesis selection as a probabilistic process. This enables end-to-end optimization of neural networks for tasks like 6D camera localization, allowing gradients to flow through the entire system and directly minimize final pose error.
Introduction
Camera localization is a fundamental task in computer vision, often following a "predict locally, fit globally" paradigm. While deep learning has significantly advanced local feature extraction, the global fitting stage—typically handled by RANSAC (Random Sample Consensus)—has traditionally remained a non-differentiable "black box." This paper, presented at CVPR 2017, introduces DSAC, a framework that bridges this gap by making the hypothesis selection process differentiable.
The Challenge of Non-Differentiable RANSAC
In a typical camera localization pipeline, a neural network predicts 3D scene coordinates for 2D image pixels. A robust estimator like RANSAC then finds the camera pose that best explains these correspondences. However, RANSAC's core operation—selecting the "best" hypothesis via an argmax—is non-differentiable. This prevents gradients from flowing back from the final pose error to the coordinate prediction network, forcing researchers to train components in isolation using surrogate losses, which is often suboptimal.
Methodology: Making RANSAC Differentiable
The authors propose two primary strategies to overcome the non-differentiability of the hypothesis selection process:
- SoftAM (Soft argmax): This approach replaces the hard selection with a weighted average of all hypotheses based on their scores. While differentiable, it transforms RANSAC from a robust selection mechanism into a robust averaging one, which can be overly sensitive to outliers.
- DSAC (Probabilistic Selection): This is the core contribution. Instead of a deterministic choice, selection is treated as a stochastic process where a hypothesis is sampled from a softmax distribution of scores. By minimizing the expected loss and employing the "log-derivative trick" (common in reinforcement learning), the authors enable gradient calculation through the discrete selection step.
The DSAC Pipeline
The complete DSAC pipeline consists of several integrated components:
- Coordinate CNN (w): Predicts 3D scene coordinates for image patches.
- Hypothesis Generation: Uses the PnP algorithm to generate multiple camera pose hypotheses from sampled point sets.
- Score CNN (v): A second network that evaluates the quality of each pose hypothesis by analyzing the distribution of reprojection errors.
- DSAC Selection: Probabilistically selects a final pose for refinement and loss calculation.
Experimental Results and Insights
The method was evaluated on the 7-Scenes dataset, a challenging indoor benchmark. Using only RGB data, DSAC achieved state-of-the-art performance, reaching a precision of 58.0% (poses within 5cm and 5°), a 3.3% improvement over previous hybrid methods. The median pose error was reduced to 4.1cm and 1.1°.
Key insights from the study include:
- Selection vs. Averaging: Probabilistic selection (DSAC) proved significantly more robust than soft averaging (SoftAM). SoftAM tended to overfit by trying to optimize the average of all hypotheses, whereas DSAC learned to minimize the probability of selecting outliers.
- End-to-End Advantage: Training the entire system using the final pose error as a loss function significantly outperformed training components with surrogate losses (e.g., coordinate accuracy).
- Learned Consensus: The Score CNN successfully learned to evaluate consensus based on error distributions, surpassing traditional hand-crafted inlier counting methods.
Conclusion and Future Directions
DSAC demonstrates that robust geometric fitting can be successfully integrated into deep learning architectures. While the training process requires careful initialization and is computationally intensive due to stochastic noise and refinement steps, it opens the door for end-to-end optimization in various geometric tasks such as SLAM and Structure from Motion (SfM).
Summary updated