HF-Net

Sarlin 2019 · Paper

One-line summary — Coarse-to-fine hierarchical localization: global retrieval narrows the search to candidate places, local feature matching then yields a precise 6-DoF pose — with HF-Net computing both feature types in a single CNN forward pass.

Problem

Robust and accurate visual localization is fundamental for autonomous driving, mobile robotics, and AR, but remains hard at large scale and under strong appearance change (day-night, seasons). Direct 2D-3D matching methods (Active Search, CSL) are accurate but become ambiguous and slow as models grow and appearance changes; image-retrieval methods are robust but only give a pose up to the database discretization. Hand-crafted features (SIFT) limit robustness, learned dense features are intractable on mobile — and computing a retrieval network plus a local-feature network separately is redundant, since both start from the same low-level image cues.

Method & architecture

Hierarchical localization pipeline (following Sarlin 2018, upgraded with learned features):

  1. Prior retrieval: match the query’s global descriptor against database images; the k-nearest neighbors are candidate locations.
  2. Covisibility clustering: group prior frames into places — connected components of the covisibility graph linking database images to the SfM model’s 3D points.
  3. Local matching: per place, match query 2D keypoints to the place’s 3D points and estimate a 6-DoF pose with PnP + RANSAC, stopping at the first valid pose. A modified ratio test only rejects a match if the two nearest neighbors belong to different 3D points, keeping matches in highly covisible areas.

The strongest variant, NV+SP, uses NetVLAD for retrieval and SuperPoint for local features; SfM models are re-triangulated with SuperPoint keypoints via COLMAP under ground-truth reference poses.

HF-Net. To make this run on mobile, a single MobileNetV2 encoder (depth multiplier 0.75) feeds three heads: keypoint scores and dense local descriptors (SuperPoint’s parameter-free decoding, branching at layer 7 where spatial resolution is still high) and a NetVLAD global-descriptor head at layer 18 — local features are lower-level than image-wide ones, so the split points differ.

Multi-task distillation. Ground-truth local correspondences and globally diverse imagery don’t coexist in any dataset, so HF-Net is instead trained to copy three teachers — NetVLAD (t1t_1, global), SuperPoint (t2t_2 descriptors, t3t_3 keypoints) — with self-balancing loss weights w1,2,3w_{1,2,3} (Kendall et al.):

L=ew1dsgdt1g22+ew2dsldt2l22+2ew3CrossEntropy(ps,pt3)+iwiL=e^{-w_{1}}\|\mathbf{d}^{g}_{s}-\mathbf{d}^{g}_{t_{1}}\|_{2}^{2}+e^{-w_{2}}\|\mathbf{d}^{l}_{s}-\mathbf{d}^{l}_{t_{2}}\|_{2}^{2}+2e^{-w_{3}}\,\mathrm{CrossEntropy}(\mathbf{p}_{s},\mathbf{p}_{t_{3}})+\sum_{i}w_{i}

where dg,dl\mathbf{d}^{g},\mathbf{d}^{l} are global/local descriptors and p\mathbf{p} keypoint scores. Training uses 185k Google Landmarks day-time images plus 37k night/dawn Berkeley Deep Drive images (night data proved critical for night retrieval), with photometric augmentation but teacher targets predicted on clean images.

Results

Why it matters for SLAM

The coarse-to-fine paradigm HF-Net established is now the universal design for relocalization and loop-closure verification in SLAM: essentially every modern system retrieves places with a global descriptor and confirms them with local feature matching. Its companion toolbox hloc became the standard visual localization pipeline used in competitions and research, and the same recipe powers large-scale AR localization services.