Paper Notes: Online Invariance Selection for Local Feature Descriptors
This paper is a standout recent work from ETH, presented as an oral at ECCV 2020. It focuses on using a neural network to select the right invariance for local features on the fly. With very little computational overhead, the method can be applied to a wide range of detectors and descriptors, substantially improving matching performance in real-world scenes.
The main contributions are as follows:
-
A single network uses multitask learning to learn descriptors suited to different combinations of transformations.
-
The paper proposes a lightweight method for selecting invariant descriptors online using meta descriptors.
-
Both the multitask learning approach for variant descriptors and the online selection method for invariant descriptors can be applied to any handcrafted or learning-based descriptor, making the approach highly versatile.
1 Learning the best invariance for local descriptors
To show why choosing a descriptor with the right invariance matters, the authors give an example:

As shown above, SIFT performs well under pure rotation. When there is no rotation, however, Upright SIFT (with its dominant orientation fixed at (0, 1)) outperforms SIFT. Ideally, we would have a mechanism that automatically chooses which descriptor to use for matching. The results on the right show what happens when the algorithm makes that choice: it matches well in both cases. The paper also reports evaluation results on the HPatches dataset:

1.1 Disentangling invariance for local descriptors
Many factors can affect a descriptor’s matching performance. This paper focuses on the two with the greatest impact: rotation and illumination. Instead of trying to handle every case with a single descriptor, as earlier approaches did, the authors create four descriptors, one for each combination of invariance to these two factors:
| No. | rotation | illumination |
|---|---|---|
| 1 | variance | variance |
| 2 | invariance | variance |
| 3 | variance | invariance |
| 4 | invariance | invariance |
Network architecture
The network design builds on SuperPoint and makes several improvements. The overall architecture is shown below:

The shared CNN backbone generates semi-dense features, which are then fed into four heads, one for each of the four combinations described above.
Dataset preparation
The following images are needed:
I^A: anchor image, the original image selected from the database
I^V: variant image, transformed by a homography without rotation and with the same brightness as the original image
I^I: invariant image, with rotation and brightness changes relative to the original image
Training losses
The paper uses SIFT keypoints, though any keypoints can be used. The loss is defined as follows:
For the image pair I^a and I^b, the homography matrix between them is \mathcal{H}, and their corresponding points satisfy \mathbf{x}_{1 . . n}^{b}=\mathcal{H}\left(\mathbf{x}_{1 . . n}^{a}\right). We define a general form of the triplet loss below.
The descriptors extracted from the two images are \mathbf{d}_{1 . . n}^{a} and \mathbf{d}_{1 . . n}^{b}, respectively (both L2-normalized). The distance between them is defined as:
p_{i}=\operatorname{dist}\left(\mathbf{x}_{i}^{a}, \mathbf{x}_{i}^{b}\right)\tag{1}
The triplet loss also increases the distance between \mathbf{x}_i^a and its nearest negative sample \mathbf{x}_{n_b(i)}^b in I^b. The same applies in the other direction for \mathbf{x}_i^b. This term is therefore defined as:
n_{i}=\min \left(\operatorname{dist}\left(\mathbf{x}_{i}^{a}, \mathbf{x}_{n_{b}(i)}^{b}\right), \operatorname{dist}\left(\mathbf{x}_{i}^{b}, \mathbf{x}_{n_{a}(i)}^{a}\right)\right)\tag{2}
where is defined as follows:
n_{b}(i)=\arg \min _{j \in[1, n]}\left(\operatorname{dist}\left(\mathbf{x}_{i}^{a}, \mathbf{x}_{j}^{b}\right)\right) \text { s.t. }\left\|\mathbf{x}_{i}^{a}-\mathbf{x}_{j}^{b}\right\|_{2}>T\tag{3}
Given a margin M, the standard triplet margin loss is defined as:
L_{T}\left(I^{a}, I^{b}, \operatorname{dist}\right)=\frac{1}{n} \sum_{i=1}^{n} \max \left(M+\left(p_{i}\right)^{2}-\left(n_{i}\right)^{2}, 0\right)\tag{4}
In this paper, for the invariant descriptor, the loss L_{I} is a special case of L_{T} above, using the image pair I^A and I^I:
L_{I}=L_{T}\left(I^{A}, I^{I},\left\|\mathbf{d}^{A}-\mathbf{d}^{I}\right\|_{2}\right)\tag{5}
For the variant descriptor, the loss L_{V} is a single triplet loss that uses information extracted from all three images: I^A, I^V, and I^I. It is defined as follows:
L_{V}=\frac{1}{n} \sum_{i=1}^{n} \max \left(f M+\left\|\mathbf{d}_{i}^{A}-\mathbf{d}_{i}^{V}\right\|_{2}^{2}-\left\|\mathbf{d}_{i}^{A}-\mathbf{d}_{i}^{I}\right\|_{2}^{2}, 0\right)\tag{6}
Here, f is a factor that accounts for the difference between I^A and I^I. For rotation, f=\min \left(1, \frac{\theta_{I}}{\theta_{\max }}\right), where \theta_{I } is the absolute angle of rotation between I^A and I^I, and \theta_{\max } is a hyperparameter that specifies how large a rotation must be for the sample to count as negative. This parameter ensures that only larger rotations incur a penalty by increasing the loss margin as the rotation grows. Since we cannot quantify brightness differences in real images, we set f=1 when only the brightness changes.
The final loss averages the losses for the four combinations, using L_{V} for variant descriptors and L_{I} for invariant descriptors:
L_{l}=\frac{1}{|\mathcal{D}|} \sum_{d \in \mathcal{D}} L_{I / V}(d)\tag{7}1.2 Online selection of the best invariance
Once we’ve trained four different descriptors using the approach above, how do we decide which one to use when matching real-world images? The simplest approach is to match with each descriptor in turn and pick the match with the smallest distance. But this doesn’t make full use of the context or the four descriptors, so it may not be the best approach. The paper proposes a better online selection mechanism to improve matching.
Meta descriptors
First, we divide the image into a c \times c grid (the paper uses 3 \times 3). Within each grid cell, NetVLAD produces a cluster center for each descriptor type, which serves as its meta descriptor. This gives us four meta descriptors per cell, all of which are L2-normalized.
Next, we use soft selection instead of hard selection. The weights are computed from the meta descriptors, which summarize the descriptors in each cell. A softmax assigns a weight to each descriptor type, and the final distance is the weighted sum of the four descriptor distances.
\operatorname{dist}\left(\mathbf{x}^{a}, \mathbf{x}^{b}\right)=\sum_{i=1}^{4} \frac{\exp \left(\left(\mathbf{m}_{i}^{a}\right)^{\top} \cdot \mathbf{m}_{i}^{b}\right)}{\sum_{j=1}^{4} \exp \left(\left(\mathbf{m}_{j}^{a}\right)^{\top} \cdot \mathbf{m}_{j}^{b}\right)}\left\|\mathbf{d}_{i}^{a}-\mathbf{d}_{i}^{b}\right\|_{2}\tag{8}
Here, m has already been computed during the initial clustering and can be looked up using the corresponding grid cell’s location.
Training Loss
Weak supervision is sufficient to train the four NetVLAD layers; no direct supervision is needed. The same triplet loss described above is used, but with meta descriptors in place of descriptors.
L_m = L_T(I^A,I^I,\operatorname{dist})\tag{9}
The overall loss is a weighted sum of the two terms:
1.3 Training details
This section mainly covers the network architecture and loss parameters. We’ll skip it here; see the paper for details.
2 Experiments
The paper presents a fairly comprehensive set of experiments, with multiple rounds of evaluation using three metrics: Homography estimation, Precision, and Recall.
Ablation study
In this section, the authors make the following comparisons to demonstrate the effectiveness of Online Selection:

The variants are defined as follows:
-
Best of the 4 matches using all four descriptor types, then selects the type with the smallest distance;
-
Greedy matches each keypoint separately using all four descriptor types and finds the closest match for each type;
-
Hard assignment uses no weights. Instead, it uses the meta descriptor to select a single fixed descriptor type.
-
No tiling and 5×5 indicate whether the image is left untiled or divided into a 5×5 grid.
-
Single desc still uses the same network to train four descriptors, but concatenates them into a single descriptor and trains across all lighting and rotation conditions.
Overall, the results show that the strategy proposed in the paper is effective, with each step contributing to the performance gains.
Descriptor evaluation on HPatches
The experiments on the HPatches dataset are shown below:

Evaluation in challenging and cross-modal situations
To capture greater variations in lighting and viewpoint, the authors augmented the day-night image matching dataset to create a more challenging dataset, Rotated Day-Night Image Matching (RDNIM). The download links are below:
Polybox:
https://www.polybox.ethz.ch/index.php/s/P89YkZyOfdhmdPN
Baidu Netdisk:
Link: https://pan.baidu.com/s/1TFWWpUqGjC3u_0mms9Lunw Access code: jjnf
The following results were obtained on this more challenging dataset (the latest results shown below are from GitHub):
Comparison to the state of the art on the RDNIM dataset, using SuperPoint keypoints for all methods:
| Day reference | Night reference | |||||
|---|---|---|---|---|---|---|
| Homography estimation | Precision | Recall | Homography estimation | Precision | Recall | |
| Root SIFT | 0.121 | 0.188 | 0.112 | 0.141 | 0.238 | 0.164 |
| HardNet | 0.199 | 0.232 | 0.194 | 0.262 | 0.366 | 0.323 |
| SOSNet | 0.178 | 0.228 | 0.203 | 0.211 | 0.297 | 0.269 |
| SuperPoint | 0.146 | 0.195 | 0.178 | 0.182 | 0.264 | 0.255 |
| D2-Net | 0.094 | 0.195 | 0.117 | 0.145 | 0.259 | 0.182 |
| R2D2 | 0.170 | 0.175 | 0.162 | 0.196 | 0.237 | 0.216 |
| GIFT | 0.187 | 0.152 | 0.133 | 0.241 | 0.236 | 0.209 |
| LISRD (ours) | 0.253 | 0.402 | 0.440 | 0.297 | 0.484 | 0.519 |
The results reported in the paper are slightly different:


Application to localization in challenging conditions
Results on the Aachen Day-Night dataset:

Personal takeaways
This is a great idea. Instead of training a universal descriptor (which, when you think about it, can hardly be both discriminative and robust), the authors train a set of descriptors for the main conditions and adapt them online to the actual scene. That online adaptation makes all the difference.
It also suggests that rather than pooling all the samples to train a single universal network, we might be better off designing outputs for different scenarios and then selecting among them online for matching.
References
Paper
Source code
https://github.com/rpautrat/LISRD