{'fraction_non_alphanumeric': 0.036272826595910725, 'fraction_numerical': 0.018042765724988294, 'mean_word_length': 4.782671480144404, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Learning and aggregating deep local descriptors for instance-level recognition

We propose an efficient method to learn deep local descriptors for instance-level recognition. The training only requires examples of positive and negative image pairs and is performed as metric learning of sum-pooled global image descriptors. At inference, the local descriptors are provided by the activations of internal components of the network. We demonstrate why such an approach learns local descriptors that work well for image similarity estimation with classical efficient match kernel methods. The experimental validation studies the trade-off between performance and memory requirements of the state-of-the-art image search approach based on match kernels. Compared to existing local descriptors, the proposed ones perform better in two instance-level recognition tasks and keep memory requirements lower. We experimentally show that global descriptors are not effective enough at large scale and that local descriptors are essential. We achieve state-of-the-art performance, in some cases even with a backbone network as small as ResNet18.


Introduction
Instance-level recognition tasks are dealing with a very large number of classes and relatively small intra-class variability. Typically, even instance-level classification tasks are cast as instance-level search in combination with nearest neighbor classifiers. The first instance-level search approach to achieve good performance, i.e. Video Google [42], is based on local features and the Bag-of-Words (BoW) representation. Representing images as collections of vector-quantized descriptors of local features allows for efficient spatial verification [32], which turns out to be a key ingredient in search for small objects. Follow-up approaches improve the BoW paradigm either with finer quantization and better matching schemes [20,44,2] or with compact global descriptors generated through aggregation [22,1]. Good performance is achieved even without spatial verification.
The advent of deep networks made it easy to generate and train global image descriptors. A variety of approaches exist [14,35,3,28,50,16] that differ in the training data, in the loss function, or in the global pooling operation. However, the performance of global descriptors deteriorates for very large collections of images. Noh et al. [29] are the first to exploit the flexibility of global descriptor training in order to obtain local features and descriptors, called DELF, for the task of instance-level recognition. DELF descriptors are later shown [34] to achieve top performance when combined with the state-of-the-art image search approach, i.e. the Aggregated Selective Match Kernel (ASMK) [44]. Compared to compact global descriptors, this comes with higher memory requirements and search time cost. In contrast to other learned local feature detectors [13] that use keypoint-level supervision and non-maxima suppression, DELF features are not precisely localized and suffer from redundancy since deep network activations are typically spatially correlated.
In this work 1 , we propose a local feature detector and descriptor based on a deep network. It is trained through metric learning of a global descriptor with image-level annotation. We design the architecture and the loss function so that the local features and their descriptors are suitable for matching with ASMK, see Figure 1. ASMK is known to deliver good performance even without spatial verification, i.e. precise feature localization is not crucial, and it deals well with repeated or bursty features. Therefore, the common drawbacks of existing deep local features for instance-level recognition are overcome. Unlike classical local features that attempt to offer precise localization to extract reliable descriptors, multiple nearby locations can give rise to a similar descriptor in our training; multiple similar responses are not suppressed, but averaged.
The main contribution of this work is the proposed combination of deep feature detector and descriptor with ASMK matching, which outperforms existing global and local descriptors on two instance-level recognition tasks, i.e. classification and search, in the domain of landmarks. Our ablation study shows that the proposed components reduce the memory required by ASMK. The learned local descriptors outperform by far deep global descriptors as well as other deep local descriptors combined with ASMK. Finally, we provide insight into why the image-level optimization is relevant for local-descriptors and ASMK matching.

Related work
We review the related work in learning global or local descriptors for instancelevel matching task and local descriptors for registration tasks.
Global descriptors. A common approach to obtain global image descriptors with deep fully-convolutional neural networks is to perform global pooling on 3D feature maps. This approach is applied to activations generated by pretrained networks [4,45,23] or end-to-end learned networks [35,14,15]. One of the first examples is SPoC descriptor by Babenko and Lempitsky [4] that is generated by simple global sum-pooling. Weighted sum-pooling is performed in CroW by Kalantidis et al. [23], where the weights are given by the magnitude of the activation vectors at each spatial location of the feature map. Such a 2D map of weights, seen as an attention map, is related to our approach as discussed in Section 4.2. Inspired by classical embeddings, Arandjelović et al. [3] extend the VLAD [22] descriptor to NetVLAD. Its contextually re-weighted counterpart, proposed by Kim and Frahm [24], introduces a learned attention map which is generated by a small network.
Local features and descriptors for instance-level recognition. Numerous classical approaches that are based on hand-crafted local features [27,25] and descriptors [26,8] exist in the literature of instance-level search [42,32,44,51,30]. Inspired by classical feature detection, Simeoni et al. [41] perform MSER [25] detection on activation maps. The features detected at one feature channel are used as tentative correspondences, hence no descriptors are required; the approach is applicable to any network and does not require learning. Learning of attentive deep local features (DELF) is introduced in the work of Noh et al. [29]. A global descriptor is derived from a network that learns to attend on feature map positions. The global descriptor is optimized with category-level labels and classification loss. At test time, locations with the strongest attention scores are selected while the descriptors are the activation vectors at the selected locations. This approach is highly relevant to ours. We therefore provide a number of different ablation experiments to reveal the key differences. A recent variant shows that it is possible to jointly learn DELF-like descriptors and global descriptors with a single model [11]. A similar achievement appears in the work of Yang et al. [49] with a scope that goes beyond instance-level recognition and covers image registration too.
Local features and descriptors for registration. A richer line of work exists in learning local feature detection and description for image registration where denser point correspondences are required. As in the previous tasks, some methods do not require any learning and are applicable on any pre-trained network. This is the case of the work Benbihi et al. [9] where activation magnitudes are back-propagated to the input image and local-maxima are detected. Learning is performed with or without labeling at the local level in a number of different approaches [38,13,12,7,10,47]. A large number of features is typically required for good performance. This line of research differentiates from our work; our focus is on large-scale instance-level recognition where memory requirements matter.

Background
In this section, the binarized versions of Selective Match Kernel (SMK) and its extension, the Aggregated Selective Match Kernel (ASMK) [44] 2 , are reviewed as the necessary background. This paper exploits the ASMK indexing and retrieval.
In SMK, an image is represented by a set X = {x ∈ R d } of n = |X | ddimensional local descriptors. The descriptors are quantized by k-means quantizer q : R d → C ⊂ R d , where C = {c 1 , . . . , c k } is a codebook comprising |C| vectors (visual words). Descriptor x is assigned to its nearest visual word q(x). We denote by X c = {x ∈ X : q(x) = c} the subset of descriptors in X that are assigned to visual word c, and by C X the set of all visual words that appear in X . Descriptor x is mapped to a binary vector through function b : is the residual vector w.r.t. the nearest visual word and sign is the element-wise sign function.
The SMK similarity of two images, represented by X and Y respectively, is estimated by cross-matching all pairs of local descriptors with match kernel where [·] is the Iverson bracket, γ(X ) is a scalar normalization that ensures unit self-similarity 3 , i.e. S SMK (X , X ) = 1. Function k : where τ ∈ [0, 1] is a threshold parameter. Only descriptor pairs that are assigned to the same visual word contribute to the image similarity in (1). In practice, not all pairs need to be enumerated and image similarity is equivalently given by where cross-matching is only performed within common visual words. ASMK first aggregates the local descriptors assigned to the same visual word into a single binary vector. This is performed by This is computationally and memory-wise more efficient than SMK. In practice, it is known to perform better due to handling the burstiness phenomenon [18]. Efficient search is performed by using an inverted-file indexing structure.
Simplifications. Compared to the original approach [44], we drop IDF weighting, pre-binarization random projections, and median-value thresholding, as these are found unnecessary.

Method
Learning local descriptors with ASMK in an end-to-end manner is challenging and impractical due to the use of large visual codebooks and the hard-assignment of descriptors to visual words. In this section, we first describe a simple framework to generate global descriptors that can be optimized with image-level labels and provide an insight into why this is relevant to optimizing the local representation too. Then, we extend the framework by additional components and discuss their relation to prior work.

Derivation of the architecture
In the following, let us assume a deep Fully Convolutional Network (FCN), denoted by function f : R w×h×3 → R W ×H×D , that maps an input image I to a 3D tensor of activations f (I). The FCN is used as an extractor of dense deep local descriptors. The 3D activation tensor can be equivalently seen as a set U = {u ∈ R D } of W × H D-dimensional local descriptors 4 . Each local descriptor is associated to a keypoint, also called local feature, that is equivalent to the receptive field, or a fraction of it, of the corresponding activations.
Let us consider global image descriptors constructed by global sum-pooling, known as SPoC [4]. Pairwise image similarity is estimated by the inner product of the corresponding 2 -normalized SPoC descriptors. This can be equivalently seen as an efficient match kernel. Let U = f (I) and V = f (J) be sets of dense feature descriptors in images I and J, respectively. Image similarity is given by where γ(U) = 1/|| u∈U u||. The optimization of the network parameters is cast as metric learning. The interpretation of global descriptor matching in (6) as local descriptor cross-matching in (5) provides some useful insight. Local descriptor similarity  is estimated by u v = ||u|| · ||v|| · cos(u, v). Optimizing SPoC with image-level labels and contrastive loss implicitly optimizes the following four cases. First, local descriptors of background features, or image regions, are pushed to have small magnitude, i.e. small ||u||, so that their contribution in cross-matching is minimal. Similarly, local descriptors of foreground features are pushed to have large magnitude. Additionally, local descriptors of truly-corresponding features, i.e. image locations depicting the same object or object part, are pushed closer in the representation space, so that their inner product is maximized. Finally, local descriptors of non-corresponding features are pushed apart, so that their inner product is minimized. Therefore, optimizing global descriptors is a good surrogate to optimize local descriptors that are used to measure similarity via efficient match kernels, such as in ASMK. Importantly, this is possible with image-level labels and no local correspondences are required for training. In the following, we introduce additional components to the presented model, that are designed to amplify these properties.
Feature strength and attention. The feature strength, or importance, is estimated as the 2 norm of the feature descriptor u by the attention function w(u) = ||u||. During training, the feature strength is used to weigh the contribution of each feature descriptor in cross-matching. This way, the impact of the weak features is limited during the training, which is motivated by only the strongest features being selected in the test time. The attention function is fixed, without any parameters to be learned.
Local smoothing. Large activation values tend to appear in multiple channels of the activation tensor on foreground features [41]. Moreover, these activa-tions tend not to be spatially well aligned. We propose to spatially smooth the activations by average pooling in an M ×M neighborhood. The result is denoted byŪ = h(f (I)) orŪ = h(U). Our experiments show that it is beneficial for the aggregation operation performed in ASMK. It is a fixed function, without any further parameters to be learned, and parameter M is a design choice.
Mean subtraction. Commonly used FCNs (all that are used in this work) generate non-negative activation tensors since a Rectified Linear Unit (ReLU) constitutes the last layer. Therefore, the inner product for all local descriptor pairs in cross-matching is non-negative and contributes to the image similarity. Mean descriptor subtraction is known to capture negative evidence [19] and allows to better disambiguate non-matching descriptors.
Descriptor whitening. Local descriptor dimensions are de-correlated by a linear whitening transformation; PCA-whitening improves the discriminability of both local [6] and global descriptors [36]. For efficiency, dimensionality reduction is performed jointly with the whitening. Formally, we group mean subtraction, whitening, and dimensionality reduction into function o : Function o(·) is implemented by 1 × 1 convolution with bias. In practice, we initialize P and m according to the result of PCA whitening on a set of local descriptors from the training set and keep them fixed during the training.
Learning. LetV = h(V) andv ∈V denote the activation vector after local average pooling h(·) at the same spatial location as v ∈ V. Similarly forŪ and u. The image similarity that is being optimized during learning is expressed as A metric learning approach is used to train the network. In particular, contrastive loss is minimized: Test-time architecture. The architecture in test time is slightly modified; no global descriptor is generated. The n strongest descriptors o(ū) for u ∈ U are kept according to the importance given by w(u). These are used as the local descriptor set X in ASMK. Multi-scale extraction is performed by resizing the input image at multiple resolutions. Local features from all resolutions are merged and ranked jointly according to strength. Selection of the strongest features is performed in the merged set. Multi-scale extraction is performed only during testing, and not during training. The training and testing architectures are summarized in Figure 2, while examples of detected features are shown in Figure 3.

Relation to prior work
The proposed method has connections to different approaches in the literature which are discussed in this section. The work closest to ours, in terms of training of the local detector and descriptor, is DELF [29]. Following our notation, DELF generates local feature descriptors Zĥôŵ(U), whereĥ(.) is identity, i.e. no local smoothing,ô(.) is identity, i.e. no mean subtraction, whitening, and dimensionality reduction, andŵ(.) is a learned attention function. In particular, w : R D → R + is a 2 layer convolutional network with 1 × 1 convolutions whose parameters are learned during the training. Dimensionality reduction of the descriptor space in DELF is performed as post-processing and is not a part of the optimization. 5 In terms of optimization, DELF performs the training in a classification manner with cross entropy loss. We show experimentally, that when combined with ASMK, the proposed descriptors are superior to DELF.
Fixed attention. Function w(·) is previously used to weigh activations and generate global descriptor, in particular by CroW [23]. It is also used in concurrent work for deep local features by Yang et al. [49]. The same attention function is used by Iscen et al. [17] for feature detection on top of dense SIFT descriptors without any learning. In our case, during learning, background or domain irrelevant descriptors are pushed to have low 2 norm in order to contribute less. The corresponding features are consequently not detected during test time.
Learned attention. Further example of learned attention, apart from DELF, is the contextual re-weighting that is performed to construct global descriptors in the work of Kim and Frahm [24]. The attention function is similar to DELF but with larger spatial kernel; a contextual neighborhood is used. A comparison between learned and fixed attention is included in the experimental ablations in Section 5.
Whitening. A common approach to whitening is to apply it as the last step in the pipeline, as post-processing. A similar approach to ours -applying the PCA whitening during training and learning it end-to-end -is followed by Gordo et al. [14] in the context of processing and aggregating regional descriptors to construct global descriptors. Comparison between "in-network" and postprocessing whitening-reduction is included in Section 5.

Experiments
We first review the datasets used for training, validation, and testing. Then, we discuss the implementation details for training and for testing with ASMK. Finally, we present our results on two instance-level tasks, namely recognition and search in the domain of landmarks and buildings.

Datasets
Training. The training dataset SfM120k [35] is used. It is the outcome of Stucture-from-Motion (SfM) [40] with 551 3D models for training. Matching pairs (anchor-positive) are formed by images with visual overlap (same 3D model). Non-matching pairs (anchor-negative) come from different 3D models.
Validation. We use the remaining 162 3D models of SfM120k to construct a challenging validation set reflecting the target task; this is different than the validation in [35]. We randomly choose 5 images per 3D model as queries. Then, for each query, images of the same 3D model with enough (more than 3), but not too many (at most 10), common 3D points with the query are marked as positive images to be retrieved. This avoids dominating the evaluation measure by a large number of easy examples. The remaining images of the same 3D model are excluded from evaluation for the specific query [32]. Skipping queries with an empty list of positive images results in 719 queries and 12,441 database images in total. Evaluation on the validation set is performed by instance-level search and performance is measured by mean Average Precision (mAP).
Evaluation on instance-level search. We use ROxford [32] and RParis [33] to evaluate search performance in the revisited benchmark [34]. They consist of 70 queries each, and 4993 and 6322 database images, respectively, and 1 million distractors called R1M. We measure mAP on the Medium and Hard setups.
Evaluation on instance-level classification. We use instance-level classification as another task on which to evaluate the performance of the learned local descriptors. We perform search with ASMK and use k-nearest-neighbors classifiers for class predictions. The Google Landmarks Dataset -version 2 (GLD 2 ) [48] is used. It consists of 4,132,914 train/database images with known class labels, and 117,577 test/query images which either correspond to the database landmarks, to other landmarks, or to non-landmark images. The query images are split into testing (private) and validation (public) sets with 76,627 and 40,950 images, respectively. Performance is measured by micro Average Precision (µAP) [31], also known as Global Average Precision (GAP), on the testing split. Note that we do not perform any learning on this dataset. We additionally create a mini version of GLD 2 to use for ablation experiments. It includes 1,000 query images, that are sampled from the testing split, and 10,0000 database images with labels, where the images come from 50 landmarks in total. We denote it by Tiny-GLD 2 .
Classification is performed by accumulating the N top-ranked images per class. Prediction is given by the top-ranked class and the corresponding confidence is equal to the accumulated similarity. We use three variants, i.e. N = 1 (CLS1), N = 10 (CLS2), and N = 10 with accumulation of square-rooted similarity multiplied by a class weight (CLS3). The class weight is equal to the logarithm of the number of classes divided by the class frequency to down-weigh frequent classes.

Implementation details
Network architecture. We perform experiments with a backbone FCN ResNet18 and ResNet50, initialized by pre-training on ImageNet [39]. Descriptor dimensionality D is equal to 512 and 2048, respectively. We additionally experiment by removing the last block, i.e. "conv5 x", where D becomes 256 and 1024, respectively. We set d = 128 and M = 3 to perform 3 × 3 average pooling for local smoothing.
Training. We use a batch size of 5 tuples, where a tuple consists of 7 images -an anchor, a positive, and 5 negatives. Training images are restricted to a maximum resolution of 1,024 pixels. For each epoch, we randomly choose 2,000 anchor-positive pairs. The pool of candidate negatives contains 20,000 randomly chosen images, and hard-negative mining is performed before every epoch. We adopt the above choices from the work of Radenovic et al. [35], whose public implementation 6 we use to implement our method. To initialize P and m, we use local descriptors from 5,000 training images extracted at a single scale. We use Adam optimizer with weight decay equal to 10 −4 . The learning rate and margin µ are tuned, per variant, according to the performance on the validation set, by trying values 10 −6 , 5 · 10 −6 , 10 −5 , 5 · 10 −5 for learning rate and 0.5 to 0.9 with step 0.05 for margin µ. Margin µ is set equal to 0.8 for the proposed method, and learning rate equal to 5·10 −6 and 10 −5 for ResNet18 and ResNet50 without the last block, respectively, according to the tuning process. Training is performed for 20 epochs and 1 epoch takes about 22 minutes for ResNet50 without the last block on a single NVIDIA Tesla V100 GPU with 32GB of DRAM. Training with cross entropy loss for ablations is performed with a batch size equal to 64 for 10 epochs. We repeat the training of each model and report mean and standard deviation over 5 runs. In large scale experiments, we evaluate a single model, the one with median performance on the validation set.
Validation. Validation performance is measured with ASMK-based search on the validation set. We measure validation performance every 5 epochs during training and the best performing model is kept.
Testing. We use ASMK to perform testing and to evaluate the performance of the learned local descriptors. The default ASMK configuation is as follows. We set threshold τ = 0, d = 128, and use a codebook of κ = 65536 visual words, which is learned on local descriptors from 20,000 training images extracted at a single scale. Images are resized to have maximum resolution of 1024 pixels and multi-scale extraction is performed by re-scaling with factors 0.25, 0.353, 0.5, 0.707, 1.0, 1.414, 2.0. Assignment to multiple, in particular 5, visual words is performed for the query images. The strongest n = 1000 local descriptors are   n (400,600,800,1000,1200,1400). Components used by DELF are denoted withˆ, while ours without. : random initialization of m and P (learned during training). Mean and standard deviation over 5 runs.
kept. The default configuration is used unless otherwise stated. The inverted file is compressed by delta coding.

Ablation experiments
We denote ResNet18 and ResNet50 by R18 and R50, and their versions with the last block skipped by − R18 and − R50, respectively. The local smoothing, whitening with reduction, and the fixed attention are denoted by subscripts h, o and w, respectively. The proposed method is denoted by R18 how when the backbone network is ResNet18. Following the same convention, the original DELF architecture is denoted by − R50ĥôŵ, where the dimensionality reduction is not part of the network but is performed by PCA whitening as post-processing. Figure 4 shows the performance on the validation set versus the average number of binary vectors indexed by ASMK for the database images. We perform an ablation by excluding the proposed components and by using different backbone networks. Local smoothing results in larger amount of aggregation in ASMK (red vs pink) and reduces the memory requirements, which are linear in |C X |. It additionally improves the performance when the last ResNet block is removed and feature maps have two times larger resolution (green vs magenta). Initializing and fixing h(·) with the result of PCA whitening is a beneficial choice too (orange vs pink). ResNet50 gives a good performance boost compared to ResNet18 (blue vs red), while removing the last block is able to reach higher performance at the cost of larger memory requirements (brown vs blue). More ablation experiments are shown in Table 1. Fixed attention is better than learned attention (3 vs 4). Metric learning with the contrastive loss delivers significantly better performance than cross entropy loss, in a classification manner, as done by Noh et al. [29] (4 vs 5). This is a confirmation of results that appear in the literature of instance-level recognition [14,46].
In Figure 5, we present the evolution of the model during training. We evaluate the performance of the optimized global descriptor for nearest neighbor search with multi-scale global descriptors, i.e. aggregation of global descriptors extracted at multiple image resolutions (same set of 7 resolutions as for the local descriptors). We additionally evaluate performance of the corresponding local descriptors with ASMK. The descriptor that is directly optimized in the loss performs worse than the internal local descriptors. In the following we use two backbone networks -R18, which is fast with low memory footprint, and − R50, which achieves better results at the cost of slower extraction and more memory.

Large-scale instance-level search
The performance comparison on ROxford and RParis is presented in Table 2. We do our best to evaluate the best available variants or models of the stateof-the-art approaches. The proposed local descriptors and DELF descriptors are evaluated with identical implementation and configuration of ASMK. The   Table 2. Performance comparison with global and local descriptors for instance-level search on ROxford (RO) and RParis (RP). Memory is reported for R1M. Methods marked by † are evaluated by us using the public models for descriptor extraction. The method marked by ‡ is evaluated by us using the public descriptors [34]. GEMw is a public model that includes a "whitening" (FC) layer. Dimensionality reduction is denoted by and descriptor concatenation by +. PQ8 and PQ1 denote PQ quantization using 8D and 1D sub-spaces, respectively.
proposed descriptors outperform all approaches by a large margin at large scale; global descriptors perform well enough at small scale, but at large scale, local representation is essential. Even with a backbone network as small as ResNet18, we achieve the second best performance (ranked after our method with ResNet50) on all cases of ROxford and at the hard setup of RParis +R1M. Compared to DELF, our descriptors, named HOW, perform better for less memory.
Teichmann et al. [43] achieve average performance (mean all in Table 2) equal to 56.0 and 57.3 without and with spatial verification, respectively. They use additional supervision, i.e. manually created bounding boxes for 94,000 images, which we do not. The concurrent work of Cao et al. [11] achieves average performance equal to 58.3 but requires 485 GB of RAM, and slightly lower performance with 22.6 GB of RAM for binarized descriptors.
In an effort to further compress the memory requirements of competing global descriptors, we evaluate the best variant with dimensionality reduction and with Product Quantization (PQ) [21]. We further improve their performance by concatenating the two best performing ones. Among all these variants, the proposed approach appears to be a good solution in the performance-memory trade-off.
Storing less vectors in ASMK affects memory but also speed. A query of average statistics computes the hamming distance for about 1.2 · 10 6 (average  Table 3. Performance comparison on instance-level recognition (GLD2). µAP is reported for classification with 3 different k-nn classifiers. Existing methods are evaluated by us using the public models. Global descriptors are combined with simple nearest neighbor search, and local descriptors are combined with ASMK-based retrieval.
number of vectors stored per inverted list multiplied by average |C X |) 128D binary vector pairs in the case of − R18 with our method at large scale. The same number for − R50 is 3.2 · 10 6 . Search on ROxford +R1M takes on average 0.75 seconds on a single threaded Python non-optimized CPU implementation.

Large-scale instance-level classification
Performance comparison on GLD 2 is presented in Table 3. We extract DELF keeping at most top 1,000 local descriptors and reduce dimensionality to 128. The proposed local descriptors and DELF descriptors are evaluated with identical configuration of ASMK. Our method outperforms all other methods with memory requirements that are even lower than raw 2048D global descriptors. DELF, R18 how , and − R50 how , end up with 347, 252, and 423 vectors to store per image on average, respectively. Due to the strength threshold, DELF extracted 504 local descriptors per image on average which is significantly less than for images of R1M. Multiple visual word assignment is not performed in this experiment, for any of the methods, to reduce the computational cost of search.

Conclusions
An architecture for extracting deep local features is designed to be combined with ASMK matching. The proposed method consistently outperforms other methods on a number of standard benchmarks, even if a less powerful backbone network is used. Through an extensive ablation study, we show that the SoA performance is achieved by the synergy of the proposed local feature detector with ASMK. We show that methods based on local features outperform global descriptors in large scale problems, and also that the proposed method outperforms other local feature detectors combined with ASMK. We demonstrate why the proposed architecture, despite being trained with image-level supervision only, is effective in learning image similarity based on local features. Acknowledgements. The authors would like to thank Yannis Kalantidis for valuable discussions. This work was supported by MSMT LL1901 ERC-CZ grant. Tomas Jenicek was supported by CTU student grant SGS20/171/OHK3/3T/13.