HSCNet++: Hierarchical Scene Coordinate Classification and Regression for Visual Localization with Transformer

Shuzhe Wang, Zakaria Laskar, Iaroslav Melekhov, Xiaotian Li, Yi Zhao, Giorgos Tolias, Juho Kannala

Visual localization—the task of determining a camera's 6-DoF pose (position and orientation) from a single image—is fundamental to robotics, autonomous driving, and augmented reality. While traditional methods rely on matching local features against large 3D point clouds, Scene Coordinate Regression (SCR) has emerged as a promising alternative. SCR uses neural networks to map image pixels directly to 3D coordinates, offering a more compact representation. However, SCR methods often struggle with perceptual aliasing in large environments and the requirement for dense 3D ground truth data.

HSCNet++ addresses these challenges through a hierarchical, coarse-to-fine reasoning framework that leverages Transformers to resolve spatial ambiguities and a robust pseudo-labeling strategy for sparse datasets.

The Hierarchical Localization Pipeline

HSCNet++ partitions the 3D scene into a hierarchy of discrete regions and sub-regions. Instead of regressing a 3D coordinate directly, which can be highly ambiguous in repetitive environments, the network first classifies the pixel into a coarse region, then a finer sub-region, and finally regresses a 3D residual.

Overview of the HSCNet++ pipeline, showing the transition from a query image to hierarchical label prediction and final 6-DoF pose optimization.

This hierarchical approach effectively "zooms in" on the correct part of the scene, significantly reducing the search space for the final coordinate regression. Once the scene coordinates are predicted, a PnP-RANSAC algorithm is used to solve for the final 6-DoF pose.

Methodology and Architecture

The core of HSCNet++ is a multi-stage network that shares a dense feature encoder. The architecture is designed to inject global context from coarse predictions into finer layers using a Transformer-based conditioning mechanism.

Transformer-based Conditioning

While the original HSCNet used FiLM (Feature-wise Linear Modulation) for conditioning, HSCNet++ replaces this with a Transformer mechanism. This allows the model to better capture long-range spatial dependencies. Interestingly, the authors found that the hierarchical labels themselves act as a form of dynamic positional encoding, making traditional 2D positional encodings redundant or even detrimental.

Training vs. Inference

During training, the network uses ground truth (GT) labels to supervise the region and sub-region predictors. During inference, the predicted labels from the previous stage are used to condition the subsequent stages, ensuring the model remains consistent without needing ground truth at runtime.

Detailed architecture of HSCNet++ showing the training and inference paths, loss functions (Cross-Entropy and MSE), and the hierarchical prediction flow.

Handling Sparse Data

To scale to outdoor environments where dense 3D models are unavailable, HSCNet++ employs Label Propagation (LP). This technique spreads known 3D points to neighboring pixels. To mitigate the noise introduced by this process, the framework utilizes a Symmetric Cross-Entropy (SCE) loss and an angle-based re-projection error, ensuring robust learning even from imperfect "pseudo-labels."

Key Results and Scalability

HSCNet++ achieves state-of-the-art results across multiple benchmarks:

  • Indoor Accuracy: It reaches 88.7% accuracy on the 7-Scenes dataset and 99.4% on 12-Scenes.
  • Scalability: On the "Combined" indoor scenes (i7-Scenes), it improves accuracy by 5% over its predecessor, demonstrating superior performance in larger, more complex environments.
  • Efficiency: By pruning heavy convolutional layers and optimizing the architecture, the authors achieved a 43% reduction in memory footprint compared to the original HSCNet.
  • Outdoor Performance: On the Cambridge Landmarks dataset, the sparse training variant [HSCNet++(S)] outperforms many methods that require dense multi-view stereo (MVS) data.

Conclusion and Future Work

HSCNet++ represents a significant step forward for Scene Coordinate Regression, proving that hierarchical reasoning and Transformer-based context can overcome the limitations of traditional SCR methods. While it remains scene-specific—requiring retraining for new environments—its efficiency and robustness to sparse data make it a powerful tool for practical localization tasks. Future research aims to bridge the gap between the efficiency of SCR and the generalization capabilities of local feature-based pipelines.

Summary updated

BibTeX
@article{wang2024hscnet,
  author = {Shuzhe Wang and Zakaria Laskar and Iaroslav Melekhov and Xiaotian Li and Yi Zhao and Giorgos Tolias and Juho Kannala},
  title = {{HSCNet++: Hierarchical Scene Coordinate Classification and Regression for Visual Localization with Transformer}},
  journal = {Int. J. Comput. Vis.},
  year = {2024},
  doi = {10.1007/s11263-023-01982-9},
}
Figure