Reinforced Feature Points: Optimizing Feature Detection and Description for a High-Level Task

Aritra Bhowmik, Stefan Gumhold, Carsten Rother, Eric Brachmann

Introduction

Finding and matching sparse 2D feature points across images has been a long-standing problem in computer vision . Feature detection algorithms enable the creation of vivid 3D models from image collections , building maps for robotic agents , recognizing places and precise locations as well as recognizing objects . Naturally, the design of feature detection and description algorithms, subsumed as feature detection in the following, has received tremendous attention in computer vision research since its early days. Although invented three decades ago, the seminal SIFT algorithm remains the gold standard feature detection pipeline to this day.

With the recent advent of powerful machine learning tools, some authors replace classical, feature-based vision pipelines by neural networks . However, independent studies suggest that these learned pipelines have not yet reached the accuracy of their classical counterparts , due to limited generalization abilities. Alternatively, one prominent strain of current research aims to keep the concept of sparse feature detection but replaces hand-crafted designs like SIFT with data-driven, learned representations. Initial works largely focused on learning to compare image patches to yield expressive feature descriptors . Fewer works attempt to learn feature detection or a complete architecture for feature detection and description .

Training of these methods is usually driven by optimizing low-level matching scores inspired by metric learning with the necessity to define ground truth correspondences between patches or images. When evaluated on low-level matching benchmarks like H-Patches , such methods regularly achieve highly superior scores compared to a SIFT baseline. H-Patches defines sets of matching image patches that undergo severe illumination and viewpoint changes. However, the increased accuracy in such matching tasks does not necessarily translate to increased accuracy in high-level vision pipelines. For example, we show that the state-of-the-art learned SuperPoint detector , while highly superior to SIFT on H-Patches , does not reach SIFT’s capabilities when estimating an essential matrix for an image pair. Similar observations were reported in earlier studies, where the supposedly superior learned LIFT detector failed to produce richer reconstructions than SIFT in a structure-from-motion pipeline .

Some authors took notice of the discrepancy between low-level training and high-level performance, and developed training protocols that mimic properties of high-level vision pipelines. Lua et al. perform hard negative mining of training patches in a way that simulates the problem of self-similarity when matching at the image level. Revaud et al. train a detector to find few but reliable key points. Similarly Cieslewski et al. learn to find key points with high probability of being inliers in robust model fitting.

In this work, we take a more radical approach. Instead of hand-crafting a training procedure that emulates aspects of high-level vision pipelines, we embed the feature detector in a complete vision pipeline during training. Particularly, our pipeline addresses the task of relative pose estimation, a central component in camera re-localization, structure-from-motion or SLAM. The pipeline incorporates key point selection, descriptor matching and robust model fitting. We do not need to pre-define ground truth correspondences, dispensing with the need for hard-negative mining. Furthermore, we do not need to speculate whether it is more beneficial to find many matches or few, reliable matches. All these aspects are solely guided by the task loss, i.e. by minimizing the relative pose error between two images.

Key point selection and descriptor matching are discrete operations which cannot be directly differentiated. However, since many feature detectors predict key point locations as heat maps, we can reformulate key point selection as a sampling operation. Similarly, we lift feature matching to a distribution where the probability of a match stems from its descriptor distance. This allows us to apply principles from reinforcement learning to directly optimize a high-level task loss. Particularly, all operations after the feature matching stage, e.g. robust model fitting, do not need to be differentiable since they only provide a reward signal for learning. In summary, our training methodology puts little restrictions on the feature detection architecture or the vision task to be optimized for.

We demonstrate our approach using the SuperPoint detector , which regularly ranks among top methods in independent evaluations . We train SuperPoint for the task of relative pose estimation by robust fitting of the essential matrix. For this task, our training procedure closes the gap between SuperPoint and a state-of-the-art SIFT-based pipeline, see Fig. 1 for a comparison of results.

A new training methodology which allows for learning a feature detector and descriptor, embedded in a complete vision pipeline, to optimize its performance for a high-level vision task.

We apply our method to a state-of-the-art architecture, Superpoint , and train it for the task of relative pose estimation.

After training, SuperPoint reaches, and slightly exceeds, the accuracy of SIFT which previously achieved best results for this task.

Related Work

Of all hand-crafted feature detectors, SIFT stands out for its long lasting success. SIFT finds key point locations as a difference-of-Gaussian filter response in the scale space of an image, and describes features using histograms of oriented gradients . Arandjelovic and Zisserman improve the matching accuracy of SIFT by normalizing its descriptor, also called RootSIFT. Other hand-crafted feature detectors improve efficiency for real-time applications while sacrificing as little accuracy as possible .

MatchNet is an early example of learning to compare image patches using a patch similarity network. The reliance on a network as a similarity measure prevents the use of efficient nearest neighbor search schemes. L2-Net , and subsequent works, instead learn patch descriptors to be compared using the Euclidean distance. Balntas et al. demonstrated the advantage of using a triplet loss for descriptor learning over losses defined on pairs of patches only. A triplet combines two matching and one non-matching patch, and the triplet loss optimizes relative distances within a triplet. HardNet employs a “hardest-in-batch” strategy when assembling triplets for training, i.e. for each matching patch pair, they search for the most similar non-matching patch within a mini-batch. GeoDesc constructs mini-batches for training that contain visually similar but non-matching patch pairs to mimic the problem of self-similarity when matching two images. SOSNet uses second order similarity regularization to enforce a structure of the descriptor space that leads to well separated clusters of similar patches.

Learning feature detection has also started to attract attention recently. ELF shows that feature detection can be implemented using gradient tracing within a pre-trained neural network. Key.Net combines hand-crafted and learned filters to avoid overfitting. The detector is trained using a repeatability objective, i.e. finding the same points in two related images, synthetically created by homography warping. SIPs learns to predict a pixel-wise probability map of inlier locations as key points, inlier being a correspondence which can be continuously tracked throughout an image sequence by an off-the-shelf feature tracker.

LIFT was the first, complete learning-based architecture for feature detection and description. It rebuilds the main processing steps of SIFT with neural networks, and is trained using sets of matching and non-matching image patches extracted from structure-from-motion datasets. DELF learns detection and description for image retrieval, where coarse key point locations emerge by training an attention layer on top of a dense descriptor tensor. D2-Net implements feature detection and description by searching for local maxima in the filter response map of a pre-trained CNN. R2D2 proposes a learning scheme for identifying feature locations that can be matched uniquely among images, avoiding repetitive patterns.

All mentioned learning-based works design training schemes that emulate difficult conditions for a feature detector when employed for a vision task. Our work is the first to directly embed feature detection and description in a complete vision pipeline for training where all real-world challenges occur, naturally. On a similar note, KeypointNet describes a differentiable pipeline that automatically discovers category-level key points for the task of relative pose estimation. However, does not consider feature description nor matching. In recent years, Brachmann et al. described a differentiable version of RANSAC (DSAC) to learn a camera localization pipeline end-to-end. Similar to DSAC, we derive our training objective from policy gradient . However, by formulating feature detection and matching via sampling we do not require gradients of RANSAC, and hence we do not utilize DSAC.

We realize our approach using the SuperPoint architecture, a fully convolutional CNN for feature detection and description, pre-trained on synthetic and homography-warped real images. In principle, our training scheme can be applied to architectures other than SuperPoint, like LIFT or R2D2 , and also to separate networks for feature detection and description.

Method

As an example of a high-level vision task, we estimate the relative transformation T=(R,t)T=(R,\mathbf{t}), with rotation RR and translation t\mathbf{t}, between two images II and I′I^{\prime}. We solve the task using sparse feature matching. We determine 2D key points xi\mathbf{x}_{i} indexed by ii, and compute a descriptor vector d(xi)\mathbf{d}(\mathbf{x}_{i}) for each key point. Using nearest neighbor matching in descriptor space, we establish a set of tentative correspondences mij=(xi,xj′)\mathbf{m}_{ij}=(\mathbf{x}_{i},\mathbf{x}^{\prime}_{j}) between images II and I′I^{\prime}. We solve for the relative pose based on these tentative correspondences by robust fitting of the essential matrix . We apply a robust estimator like RANSAC with a 5-point solver to find the essential matrix which maximises the inlier count among all correspondences. An inlier is defined as a correspondence with a distance to the closest epipolar line below a threshold . Decomposition of the essential matrix yields an estimate of the relative transformation T^\hat{T}.

We implement feature detection using two networks: a detection network and a description network. In practice, we use a joint architecture, SuperPoint, where most weights are shared between detection and description. The main goal of this work is to optimize the learnable parameters w\mathbf{w} of both networks such that their accuracy for the vision task is enhanced. For our application, the networks should predict key points and descriptors such that the relative pose error between two images is minimized. Key point selection and feature matching are discrete, non-differentiable operations. Therefore, we cannot directly propagate gradients of our estimated transformation T^\hat{T} back to update the network weights, as in standard supervised learning. Components of our vision pipeline, like the robust estimator (e.g. RANSAC ) or the minimal solver (e.g. the 5-point solver ) might also be non-differentiable. To optimize the neural network parameters for our task, we apply principles from reinforcement learning . We formulate feature detection and matching as probabilistic actions where the probability of taking an action, i.e. selecting a key point, or matching two features, depends on the output of the neural networks. During training, we sample different instantiations of key points and their matchings based on the probability distributions predicted by the neural networks. We observe how well these key points and their matching perform in the vision task, and adjust network parameters w\mathbf{w} such that an outcome with low loss becomes more probable. We show an overview of our approach in Fig. 2.

In the following, we firstly describe how to reformulate key point selection and feature matching as probabilistic actions. Thereafter, we formulate our learning objective, and how to efficiently approximate it using sampling.

We assume that the detection network predicts a key point heat map f(I;w)f(I;\mathbf{w}) for an input image, as is common in many architectures . Feature locations are usually selected from f(I;w)f(I;\mathbf{w}) by taking all local maxima combined with local non-max suppression.

To make key point selection probabilistic, we instead interpret the heat map as a probability distribution over key point locations f(I;w)=P(x;w)f(I;\mathbf{w})=P(\mathbf{x};\mathbf{w}) parameterized by the network parameters w\mathbf{w}. We define a set of NN key points for image II as X={xi}\mathcal{X}=\{\mathbf{x}_{i}\} sampled independently according to

see also Fig. 2, bottom left. Similarly, we define X′\mathcal{X}^{\prime} for image I′I^{\prime}. We give the joint probability of sampling key points independently in each image as

2 Probabilistic Feature Matching

We assume that a second description network predicts a feature descriptor d(x;w)\mathbf{d}(\mathbf{x};\mathbf{w}) for a given key point x\mathbf{x}. To simplify notation, we use w\mathbf{w} to denote the learnable parameters associated with feature detection and description. We define a feature match as a pairing of one key point from image II and image I′I^{\prime}, respectively: mij=(xi,xj′)\mathbf{m}_{ij}=(\mathbf{x}_{i},\mathbf{x}^{\prime}_{j}). We give the probability of a match between two key points xi\mathbf{x}_{i} and xj′\mathbf{x}^{\prime}_{j} as a function of their descriptor distance,

Note that the matching probability is conditioned on the sets of key points which we selected in an earlier step. The matching distribution is normalized using all possible matches mkk′=(xk,xk′′)\mathbf{m}_{kk^{\prime}}=(\mathbf{x}_{k},\mathbf{x}^{\prime}_{k^{\prime}}) with xk∈X\mathbf{x}_{k}\in\mathcal{X} and xk′′∈X′\mathbf{x}^{\prime}_{k^{\prime}}\in\mathcal{X}^{\prime}. The matching distribution assigns a low probability to a match, if the associated key points have very different descriptors. To increase the probability of a (good) match during training, the network has to reduce the associated descriptor distance relative to all other matches for the image pair.

We define a complete set of MM matches M={mij}\mathcal{M}=\{\mathbf{m}_{ij}\} between II and I′I^{\prime} sampled independently according to

3 Learning Objective

We learn network parameters w\mathbf{w} in a supervised fashion, i.e. we assume to have training data of the form (I,I′,T∗)(I,I^{\prime},{T}^{*}) with ground truth transformation T∗{T}^{*}. Note that we do not need ground truth key point locations X\mathcal{X} or ground truth image correspondences M\mathcal{M}.

Our training objective aims at reducing the expected task loss when sampling key points and matches according to the probability distributions parameterized by the learnable parameters w\mathbf{w}:

Calculating the expectation and its gradients exactly would necessitate summing over all possible key point sets, and all possible matchings, which is clearly infeasible. To make the calculation tractable, we assume that the network is already initialized, and makes sensible predictions that we aim at optimizing further for our task. In practice, we take an off-the-shelf architecture, like SuperPoint , which was trained on a low-level matching task. For such an initialized network, we observe the following properties:

Heat maps predicted by the feature detector are sparse. The probability of selecting a key point is zero at almost all image pixels (see Fig. 2 bottom, left). Therefore, only few image locations have an impact on the expectation.

Matches among unrelated key points have a large descriptor distance. Such matches have a probability close to zero, and no impact on the expectation.

Observation 1) means, we can just sample from the key point heat map, and ignore other image locations. Observation 2) means that for the key points we selected, we do not have to realise a complete matching of all key points in X\mathcal{X} to all key points in X′\mathcal{X}^{\prime}. Instead, we rely on a k-nearest-neighbour matching with some small kk. All nearest neighbours beyond kk likely have large descriptor distances, and hence near zero probability. In practice, we found no advantage in using a k>1k>1 which means we can do a normal nearest neighbour matching during training when calculating P(M∣X,X′;w)P(\mathcal{M}|\mathcal{X},\mathcal{X}^{\prime};\mathbf{w}) (see Fig. 2 bottom, right).

We update the learnable parameters w\mathbf{w} according to the gradients of Eq. 5, following the classic REINFORCE algorithm of Williams:

Experiments

We train the SuperPoint architecture for the task of relative pose estimation, and report our main results in Sec. 4.1. Furthermore, we analyse the impact of reinforcing SuperPoint for relative pose estimation on a low-level matching benchmark (Sec. 4.2), and in a structure-from-motion task (Sec. 4.3).

SuperPoint is a fully-convolutional neural network which processes full-sized images. The network has two output heads: one produces a heat map from which key points can be picked, and the other head produces 256-dimensional descriptors as a dense descriptor field over the image. The descriptor output of SuperPoint fits well into our training methodology, as we can look up descriptors for arbitrary image locations without doing repeated forward passes of the network. Both output heads share a common encoder which processes the image and reduces its dimensionality, while the output heads act as decoders. We use the network weights provided by the authors as an initialization.

Task Description.

We calculate the relative camera pose between a pair of images by robust fitting of the essential matrix. We show an overview of the processing pipeline in Fig. 2. The feature detector produces a set of tentative image correspondences. We estimate the essential matrix using the 5-point algorithm in conjunction with a robust estimator. For the robust estimator, we conducted experiments with a standard RANSAC estimator, as well as with the recent NG-RANSAC . NG-RANSAC uses a neural network to suppress outlier correspondences, and to guide RANSAC sampling towards promising candidates for the essential matrix. As a learning-based robust estimator, NG-RANSAC is particularly interesting in our setup, since we can refine it in conjunction with SuperPoint during end-to-end training.

Datasets.

To facilitate comparison to other methods, we follow the evaluation protocol of Yi et al. for relative pose estimation. They evaluate using a collection of 7 outdoor and 16 indoor datasets from various sources . One outdoor scene and one indoor scene serve as training data, the remaining 21 scenes serve as test set. All datasets come with co-visibility information for the selection of suitable image pairs, and ground truth poses.

Training Procedure.

To approximate the expected task loss L(w)\mathcal{L}(\mathbf{w}) and its gradients in Eq. 5 and Eq. 6, we draw key points nX=3n_{\mathcal{X}}=3 times, and, for each set of key points, we draw nM=3n_{\mathcal{M}}=3 sets of matches. Therefore, for each training iteration, we run the vision pipeline 99 times, which takes 1.5s to 2.1s on a single Tesla K80 GPU, depending on the termination of the robust estimator. We train using the Adam optimizer and a learning rate of 10−710^{-7} for 150k iterations which takes approximately 60 hours. Our training code is based on PyTorch for SuperPoint integration and learning, and on OpenCV for estimating the relative pose. We will make our source code publicly available to ensure reproducibility of our approach.

Test Procedure.

For testing, we revert to a deterministic procedure for feature detection, instead of doing sampling. We select the strongest 2000 key points from the detector heat map using local non-max suppression. We remove very weak key point with a heat map value below 0.000150.00015. We do a nearest neighbor matching of the corresponding feature descriptors, and keep all matches of mutual nearest neighbors. We adhere to this procedure for SuperPoint before and after our training, to ensure comparability of the results.

Discussion.

We report test accuracy in accordance to Yi et al. , who calculate the pose error as the maximum of rotation and translation angular error. For each dataset, the area under the cumulative error curve (AUC) is calculated and the mean AUC for outdoor and indoor datasets are reported separately.

Firstly, we train and test our pipeline using a standard RANSAC estimator for essential matrix fitting, see Fig. 3 a). We compare to a state-of-the-art SIFT-based pipeline, which uses RootSIFT descriptor normalization . For RootSIFT, we apply Lowe’s ratio criterion to filter matches where the distance ratio of the nearest and second nearest neighbor is above 0.8. We also compare to the LIFT feature detector , with and without the learned inlier classification scheme of Yi et al. (denoted InClass). Finally, we compare the results of SuperPoint before and after our proposed training (denoted Reinforced SP).

Reinforced SuperPoint exceeds the accuracy of SuperPoint across all thresholds, proving that our training scheme indeed optimizes the performance of SuperPoint for relative pose estimation. The effect is particularly strong for outdoor environments. For indoors, the training effect is weaker, because large texture-less areas make these scenes difficult for sparse feature detection, in principle. SuperPoint exceeds the accuracy of LIFT by a large extent, but does not reach the accuracy of RootSIFT. We found that the excellent accuracy of RootSIFT is largely due to the effectiveness of Lowe’s ratio filter for removing unreliable SIFT matches. We tried the ratio filter also for SuperPoint, but we found no ratio threshold value that would consistently improve accuracy across all datasets.

To implement a similarly effective outlier filter for SuperPoint, we substitute the RANSAC estimator in our vision pipeline with the recent learning-based NG-RANSAC estimator. We train NG-RANSAC for SuperPoint using the public code of Brachmann and Rother , and with the initial weights for SuperPoint by Detone et al. . With NG-RANSAC as a robust estimator, SuperPoint almost reaches the accuracy of RootSIFT, see Fig. 3, b). Finally, we embed both, SuperPoint and NG-RANSAC in our vision pipeline, and train them jointly and end-to-end. After our training schema, Reinforced SuperPoint matches and slightly exceeds the accuracy of RootSIFT. Fig. 3, c) shows an ablation study where we either update only NG-RANSAC, only SuperPoint or both during end-to-end training. While the main improvement comes from updating SuperPoint, updating NG-RANSAC as well allows the robust estimator to adapt to the changing matching statistics of SuperPoint throughout the training process.

Analysis.

We visualize the effect of our training procedure on the outputs of SuperPoint in Fig. 4. For the key point heat maps, we observe two major effects. Firstly, many key points seem to be discarded, especially for repetitive patterns that would result in ambiguous matches. Secondly, some key points are kept, but their position is adjusted, presumably to achieve a lower relative pose error. For the descriptor distribution, we see a tendency of reducing the descriptor distance for correct matches, and increasing the descriptor distance for wrong matches. Quantitative analysis confirms these observations, see Table 1. While the number of key points reduces after end-to-end training, the overall matching quality increases, measured as the ratio of estimated inliers, and ratio of ground truth inliers.

2 Low-Level Matching Accuracy

We investigate the effect of our training scheme on low-level matching scores. Therefore, we analyse the performance of Reinforced SuperPoint, trained for relative pose estimation (see previous section), on the H-Patches benchmark. The benchmark consists of 116 test sequences showing images under increasing viewpoint and illumination changes. We adhere to the evaluation protocol of Dusmanu et al. . That is, we find key points and matches between image pairs of a sequence, accepting only matches of mutual nearest neighbours between two images. We calculate the reprojection error of each match using the ground truth homography. We measure the average percentage of correct matches for thresholds ranging from 1px to 10px for the reprojection error. We compare to a RootSIFT baseline with a hessian affine detector (denoted HA+RootSIFT) and several learned detectors, namely HardNet++ with learned affine normalization (denoted HANet+HN++), LF-Net , DELF and D2-Net . The original SuperPoint beats all competitors in terms of AUC when combining illumination and viewpoint sequences. In particular, SuperPoint significantly exceeds the matching accuracy of RootSIFT on H-Patches, although RootSIFT outperforms SuperPoint in the task of relative pose estimation. This confirms that low-level matching accuracy does not necessarily translate to accuracy in a high-level vision task, see our earlier discussion. As for Reinforced SuperPoint, we observe an increased matching accuracy compared to SuperPoint, due to having fewer but more reliable and precise key points.

3 Structure-from-Motion

We evaluate the performance of Reinforced SuperPoint, trained for relative pose estimation, in a structure-from-motion (SfM) task. We follow the protocol of the SfM benchmark of Schönberger et al. . We select three of the smaller scenes from the benchmark, and extract key points and matches using SuperPoint and Reinforced SuperPoint. We create a sparse SfM reconstruction using COLMAP , and report the number of reconstructed 3D points, the average track length of features (indicating feature stability across views), and the average reprojection error (indicating key point precision). We report our results in Table 2, and confirm the findings of our previous experiments. While the number of key points reduces, the matching quality increases, as measured by track length and reprojection error. For reference, we also show results for DSP-SIFT the best of all SIFT variants on the benchmark , and GeoDesc , a learned descriptor which achieves state-of-the-art results on the benchmark. Note that SuperPoint only provides pixel-accurate key point locations, compared to the sub-pixel accuracy of DSP-SIFT and GeoDesc. Hence, the reprojection error of SuperPoint is higher.

Conclusion

We have presented a new methodology for end-to-end training of feature detection and description which includes key point selection, feature matching and robust model estimation. We applied our approach to the task of relative pose estimation between two images. We observe that our end-to-end training increases the pose estimation accuracy of a state-of-the-art feature detector by removing unreliable key points, and refining the locations of remaining key points. We require a good initialization of the network, which might have a limiting effect in training. In particular, we observe that the network rarely discovers new key points. Key point locations with very low initial probability will never be selected, and cannot be reinforced. In future work, we could combine our training schema with importance sampling, for biased sampling of interesting locations.

This project has received funding from the European Social Fund (ESF) and Free State of Saxony under SePIA grant 100299506, DFG Cluster of Excellence CeTI (EXC2050/1 Project ID 390696704), DFG grant 389792660 as part of TRR 248, the European Research Council (ERC) under the European Union’s Horizon 2020 research and innovation programme (grant agreement No 647769), and DFG grant COVMAP: Intelligente Karten mittels gemeinsamer GPS- und Videodatenanalyse (RO 4804/2-1). The computations were performed on an HPC Cluster at the Center for Information Services and High Performance Computing (ZIH) at TU Dresden.

References