Where to Focus: Query Adaptive Matching for Instance Retrieval Using Convolutional Feature Maps

Instance retrieval requires one to search for images that contain a particular object within a large corpus. Recent studies show that using image features generated by pooling convolutional layer feature maps (CFMs) of a pretrained convolutional neural network (CNN) leads to promising performance for this task. However, due to the global pooling strategy adopted in those works, the generated image feature is less robust to image clutter and tends to be contaminated by the irrelevant image patterns. In this article, we alleviate this drawback by proposing a novel reranking algorithm using CFMs to refine the retrieval result obtained by existing methods. Our key idea, called query adaptive matching (QAM), is to first represent the CFMs of each image by a set of base regions which can be freely combined into larger regions-of-interest. Then the similarity between the query and a candidate image is measured by the best similarity score that can be attained by comparing the query feature and the feature pooled from a combined region. We show that the above procedure can be cast as an optimization problem and it can be solved efficiently with an off-the-shelf solver. Besides this general framework, we also propose two practical ways to create the base regions. One is based on the property of the CFM and the other one is based on a multi-scale spatial pyramid scheme. Through extensive experiments, we show that our reranking approaches bring substantial performance improvement and by applying them we can outperform the state of the art on several instance retrieval benchmarks.


page 3

page 4

page 7

page 9


Bags of Local Convolutional Features for Scalable Instance Search

This work proposes a simple instance retrieval pipeline based on encodin...

The Treasure beneath Convolutional Layers: Cross-convolutional-layer Pooling for Image Classification

A number of recent studies have shown that a Deep Convolutional Neural N...

What Is the Best Practice for CNNs Applied to Visual Instance Retrieval?

Previous work has shown that feature maps of deep convolutional neural n...

Represent, Compare, and Learn: A Similarity-Aware Framework for Class-Agnostic Counting

Class-agnostic counting (CAC) aims to count all instances in a query ima...

Fashion Retrieval via Graph Reasoning Networks on a Similarity Pyramid

Matching clothing images from customers and online shopping stores has r...

Hierarchical Object Detection with Deep Reinforcement Learning

We present a method for performing hierarchical object detection in imag...

Visualizing Deep Similarity Networks

For convolutional neural network models that optimize an image embedding...

I Introduction

Instance retrieval is the task of finding a particular instance from a large image corpus. In practice, instance retrieval has two major challenges: 1) the large visual appearance deformations due to the object’s different positions, poses and illumination when being captured; and 2) various distractors from the natural and less contextual backgrounds. In the past decade, a lot of work uses local invariant descriptors [19] to handle instance retrieval, including methods that use large visual codebooks [28, 22, 10, 20, 30] and methods that use compact representations [21, 11, 3, 12]. Although promising performance has been reported on some constrained datasets [22, 23, 9, 1] for these methods, in a more realistic and challenging scenario where the target objects are with cluttered backgrounds, instance-level retrieval still remains a challenging problem [34].

Recent studies show the visual descriptors produced by aggregating the convolutional feature maps (CFMs) from convolutional neural networks (CNNs) achieve state-of-the-art performance for image retrieval

[25, 4, 31, 14]

. Comparing to the conventional local descriptors, these deep learned features capture more semantic information since a CNN is usually trained on large labeled image datasets

[26]. Most existing methods aggregate the CFMs into a compact global representation for an image, where the query-to-image similarity is evaluated on the image level. How to use these deep convolutional features to distinguish the target object from distractors in cluttered backgrounds is still challenging.

In this paper, we follow the direction of CNN-based methods and propose a novel reranking algorithm, namely query adaptive matching (QAM), using CFMs to address the image clutter problem during instance retrieval. The key idea of our method is that instead of relying on a global image representation, we represent each dataset image by a set of base regions. In further, we allow these base regions to freely merge into larger regions. Image features are then extracted from the combined region rather than the whole image. Moreover, we parameterize the regions that can be created via combining the base region and represent the combined feature as a function of a set of parameters. Thus, adjusting these parameters will be equivalent to choosing the region-of-interest to focus for a candidate image. Our method will cast the parameter selection issue as an optimization problem under the objective of maximizing the similarity between the query and the feature obtained from the combined region. The optimal parameters are expected to generate a focus region that mostly covers the object-of-interest.

To implement this idea, we also propose two ways of generating base regions. One is based on the property of the CFM and the other one is based on the multi-scale spatial pyramid. By conducting experiments on the various instance retrieval benchmarks, we show that the proposed QAM reranking, together with the two base region generation approaches can achieve promising results which outperform the state of the art. Besides that, we also discuss several practical issues of using CFMs for instance retrieval, including the choice of deep CNN models and the convolutional layers.

Ii Related Work

Ii-a Non-CNN Based Retrieval

In the past decade, instance retrieval is mainly handled by the methods using local invariant descriptors, such as SIFT [19]. Previous work can be roughly divided into two categories: 1) methods that encode local descriptors into large visual codebooks and sparse representations, namely the Bag-of-Words (BoW) [28, 22, 10, 20, 30]; and 2) methods that aggregate local descriptors into dense and compact features [21, 11, 3, 12]. Due to the loss of spatial information and the degradation of discriminative power of the descriptor after visual word quantization, BoW models are usually followed by some post-processing steps, e.g., spatial verification [22] or query expansion [6], in order to eliminate false positive results. In practice, BoW models adopt an inverted index for efficient search, but the number of images that can be indexed is limited by the search time and index size [11]

. A different strategy is to aggregate the local descriptors into compact representations, e.g., compressed Fisher Vector

[21], VLAD [11, 3] and T-embedding with democratic aggregation [12]. However, recent studies [33, 24, 5, 25, 4, 31, 14]

show that the neuron activations extracted from CNN serve as good image representations, which surpass conventional features in low dimensionality settings.

Ii-B CNN Based Retrieval

CNNs are widely used in computer vision since the success of “AlexNet”

[15] in large-scale image classification [26]. Recent studies [33, 24, 5] show that the neuron activations of CNNs can be used as generic features for image retrieval, where the features are from the fully-connected layers. However, these layers are trained on labeled objects to facilitate image classification and hence might not generalize to some instance types. These methods usually require fine-tuning the CNN on the target (or visually similar) datasets [33, 5] to obtain satisfactory retrieval performance.

Besides of the fully-connected layers, there is an emerging trend [25, 4, 31, 14] toward using the activations of the convolutional layers, named as convolutional feature maps (CFMs), as image features which shows superior performance. Specifically, Razavian et al. [25] propose to segment the image into multiple square patches and extract patch descriptors using CNN. During searching, they cross-match all the patches to obtain the best match results. Obviously, this method cannot handle large-scale datasets due to the high computational cost. Babenko et al. [4] propose a simple but effective CFMs aggregation method based on sum-pooling, which generates compact global representations (256 dimensions) for retrieval. But their performance still lags behind the traditional methods. Tolias et al. [31] propose an aggregation method which first decomposes the CFMs into multiple regions at different scales and then aggregates them via sum-pooling. This method also generates compact representations and outperforms [4]

in most cases. Besides that, the authors also propose a new reranking method based on integral max-pooling of CFMs which can roughly locate the target objects. Their retrieval framework achieves comparable or even better performance compared to traditional methods. We use a retrieval pipeline similar to that in

[31], but we propose a different reranking algorithm which can detect the discriminative regions of the target object more flexibly and precisely, and therefore achieves better retrieval performance.

Iii Instance Retrieval using CFMs

As mentioned in previous sections, recent studies [25, 4, 31, 14] have shown that using CFMs as image features achieves promising performance in instance retrieval and our work will follow this direction. Before elaborating our methods, this section will give a brief discussion on CFMs, their properties and their use for instance retrieval. These discussions provide the motivation and inspiration of our methods.

Fig. 1: The structure of convolutional feature maps. We feed an image to a pretrained CNN and extract the CFMs from a certain layer, which are consisted of feature maps with size . The neuron activations at each location across all feature maps are composed into a local descriptor (e.g., at location ).

Iii-a Preliminary

The CFMs generated by a convolutional layer can be arranged in a tensor of the size

(see Fig. 1), where and denote the height and width of each feature map, and denotes the number of feature maps (or channels) in that layer. Due to the local connectivity of each filter, the activations at the same spatial location across all feature maps can be composed into a -dimensional local descriptor for a certain image region, where the region size equals to the size of the filter’s receptive field. This local feature is formally denoted as in this paper and the subscript indicates the -th location in the CFMs. In total, there are such locations in the CFMs. The above arrangement is demonstrated in Fig. 1. The major advantage of CFMs over the fully-connected layers’ activations is that it retains the spatial information of local image patterns [18, 17] and it is essentially more similar to the traditional hand-engineered local features. In fact, the CFMs from one convolutional layer can be viewed as an array of local features sampled from a dense sampling grid.

Throughout this paper, we use the following notations. Let be the CFMs extracted from the

-th layer (after applying the ReLU). It can be equivalently represented as a set of local descriptors

. In the following sections, we use three example images selected from different object types in INSTRE dataset [34] for illustration purpose (see Fig. 2).

Fig. 2: Examples from three different object types in INSTRE dataset [34]: stereoscopic object, planar object and architecture (from left to right). The objects of interest are annotated with yellow bounding boxes.

Iii-B Understanding CFMs

Due to the parameter sharing design of the convolutional layer [16], a feature map of a convolutional layer can be viewed as the detection scores obtained by applying a detector, the filter of a convolutional layer namely, on spatial locations and the activation value at the -th location of a CFM characterizes the detector response at the same location. With this analogy, we can obtain an intuitive understanding of a CFM by visualizing it, that is, the highly activated locations suggest that around them it contains the visual patterns depicted in the convolutional layer filter. Fig. 3 gives such an illustration. In Fig. 3, the feature maps with the top five average activation scores are selected for visualization. Also, comparison of the activation patterns from different convolutional layers is provided in Fig. 3. From it we can make the following two observations:

  • A CFM only has high activations on few locations with the presence of certain visual patterns. This suggests that the convolutional filter can be highly selective to certain visual patterns and as a result the CFM can become sparse.

  • The early convolutional layer of a CNN tends to capture some primary visual patterns, e.g. edges along certain directions or dots while the late convolutional layer is usually selective to visual patterns that corresponding to a shape or an object part, e.g. the circular shape or a wheel region.

Fig. 3: The feature maps of the first example image in Fig. 2 extracted from VGG19 [27]. The top five feature maps with the largest average activation score in different layers are selected. Each row contains feature maps from a certain layer (conv3_4, conv4_4, and conv5_4 respectively).

Iii-C CFMs Aggregation for Instance Retrieval

To perform instance retrieval, an image needs to be represented by a feature vector or a set of feature vectors. To this end, the CFMs can be aggregated through some pooling strategies which have been explored in several recent works [25, 4, 31, 14]. Most of these works adopt a global pooling strategy, that is, local features from all locations in the CFMs will be aggregated together. In the simplest case, we can adopt the following pooling operations:


In other words, the aggregated image representation is obtained by first sum-pooling all the local features and then perform the -normalization. In practise, the -normalization has been found to be important and without it the retrieval performance will decrease significantly.

Despite being simple and effective, the global pooling strategy has the drawback of being less robust to the cluttered image background. This is because for instance retrieval the query can be only a cropped object. Thus in a candidate image the object-of-interest may only take up a part of the image whereas global pooling aggregates visual patterns from the whole image area. To alleviate this, one solution is to perform pooling on multiple regions of the image (or equivalently its corresponding CFMs) and create multiple pooled features to represent the image. Then a query will match against all those pooled features and the best matching score will be utilized as the similarity between the query and the image. However, this solution raises the issue of how to choose those regions. On the one hand the number of regions cannot be too large due to the storage bottleneck of a retrieval system. On the other hand the space of all possible sub-regions can be extremely large, especially considering that the object can take any shape and as a result the object shape can be much more complex than a bounding box. Thus, it is very challenging to design a region generation strategy for the multi-region pooling idea.

Iv Query Adaptive CFMs Matching Reranking

This paper adopts the multi-region pooling strategy discussed in Sec. III-C and proposes an elegant solution to explore a large number of possible regions while keeping the storage for the pooled regions low. Our method first generates a small number of base regions which can be (softly) merged into larger regions. Thus the total number of regions that can be represented by the combination of base regions is very large. For a query image, we compare it against all possible region combinations and pick the best matching score as the query-to-image similarity. At the first glance, the above procedure can be prohibitively expensive. However, if we use a set of parameters to control the merging operation, the pooled feature of the combining region can be formulated as a function of those parameters. The above matching process can be cast as an optimization problem, that is, optimal parameters are sought for maximizing the similarity measure between the pooled feature and the query image feature. The optimal objective value represents the best possible matching score between a combined region and the query image. Certainly, this idea can be slower than direct image feature comparison and thus in this paper we use it as a reranking method and apply it only to a shortlist of images retrieved by an existing approach. In the following subsections, we will elaborate the formulation and implementation details of this idea.

Iv-a Query Adaptive Matching

Formally, our method assumes a set of base image regions have been extracted for each image by a base region generation method, e.g. the ones will be introduced in Sec. IV-B1 and Sec. IV-B2. Let’s denote the sum-pooling feature of the CFMs in each of the base region as and the normalized sum-pooling feature obtained by merging a set of base regions can be represented as111In practice, can be generated via other pooling methods, e.g. max-pooling, and we still use Eq. 2 to combine features from multiple to-be-merged regions. This treatment makes our method more general applicable.:


where is a binary indicator and if its value equals to 1 its corresponding region will be added into the merged region. In practice, we can also relax its value to a positive real value which implies a soft merge operation. The similarity between the query image and merged feature can be then represented by their inner product . As seen, this similarity is a function of and our aim is to find the best similarity score that can be achieved by softly merging the base regions. Then this best match score will be used to rerank the shortlist. The search for the optimal can be written as the following optimization problem:


For notation simplification, Eq. 3 can be expressed in a more compact way:


where and . For , solving Eq. 4 is equivalent to solving:


We further constrain to avoid the arbitrary scaling of and thus ensure that the optimization problem has the unique solution. The final optimization problem is as follows:


Eq. 6 is a quadratic programming (QP) problem which can be solved efficiently by existing optimization packages. We use the inverse of this optimal value, which equals to the objective value in Eq. 3, as the image similarity score.

Iv-B Base Region Generation

The above method applies to base regions generated in any possible ways. In this work, we particularly focus on two approaches to create such base regions.

Iv-B1 Feature Map Pooling (FMP)

Our first way of generating base regions is inspired by the observation made in Sec. III-B. As discussed in Sec. III-B, the activated region of a CFM at a late convolutional layer usually represents an object part. The union of them can then cover the whole image or at least those regions with meaningful visual patterns. Thus, the activated region of each CFM in a convolutional layer can be directly utilized as a base region. Specifically, given a set of CFMs , we define the set of non-zero elements’ locations in the -th feature map as a base region, that is, . The pooled feature for this base region is then calculated as:


In our implementation, we also have -normalized to compensate the region size discrepancy. We call this base region generation method as Feature Map Pooling, or FMP in short. With FMP, the will be transformed into region descriptors which may be corresponding to different object parts, as shown in Fig. 4.

Fig. 4: Illustration of Feature Map Pooling. For each feature map, the local descriptors within activated regions (warmer parts) are aggregated. Essentially, each feature map is treated as a binary mask to select which local descriptors should be aggregated.

Once a convolutional layer of a pretrained CNN is chosen, the number of base regions will equal the number of feature maps or channels in that convolutional layer. However, for a given image, the activated regions for many CFMs can be highly overlapped. Thus it would be a waste of computation if we use all the base regions generated from the CFMs. To reduce the computational cost, in this paper we merge base regions as follows. We first represent each base region by their corresponding pooled feature . If two CFMs have similar activated regions, their corresponding pooled feature will be similar. Thus we run a clustering method,

-means clustering or spectral clustering

[32], to group pooled features into clusters. The base regions whose pooled features are grouped together will then be merged into one base region. In our experiment, this merging operation reduces the number of base regions from 512 to around 30 and thus significantly reduces the computational cost.

Iv-B2 Overlapped Spatial Pyramid Pooling (OSPP)

Another way to generate base regions is to directly sample some rectangle regions from the image. Tolias et al. [31] propose an region sampling method to sample regions at different scales and different locations. In our work, we adopt similar strategy to generate the base regions. More specifically, as shown in Fig. 5, we sample square regions at different scales. Given an image’s CFMs , we uniformly sample regions of width at the -th level. Also, the regions are sampled to allows around 40% overlap between consecutive regions.

Note that even using a similar sampling strategy, our approach is different from the work in[31]. The latter one pools the features generated from each sampled region together to obtain a single global-level image representation while our method uses sampled regions as base regions which are fed into the proposed query adaptive matching algorithm.

Fig. 5: Illustration of region sampling at different scales from [31]. We show the top-left region of each scale (gray colored region) and its neighboring regions towards each direction (dotted borders). The center of each region is denoted with a cross.

Iv-C Retrieval Pipeline

Finally, to achieve the best performance with our method, we adopt the following pipeline to perform retrieval.

  • Initial Retrieval. In offline pre-processing, the CFMs are extracted for all database images via pretrained CNNs. The global image representations are computed by an existing aggregation method (e.g., SPoC [4], R-MAC [31] or CroW [14]). During online searching, we extract the same feature for query image and evaluate the similarities between the query and all the database images by calculating the feature similarity, e.g., inner product, to obtain an initial ranking list.

  • Reranking. A short list consisting of the top N candidates from the initial ranking list is selected for reranking. Base region descriptors are extracted offline and now they are used to represent each candidate images. We solve Eq. 6 and obtain the similarity score between the query and a candidate image for reranking.

  • Query Expansion (QE). Finally, we select the top five images after reranking as in [31] and aggregate their global representations with the query feature by average pooling. We use the aggregated feature as a new query and perform the retrieval again to obtain the final ranking list.

V Experiments

V-a Experiment Settings

V-A1 Datasets

We evaluate our methods on the following datasets:

  • Oxford5k [22] contains 5,062 images corresponding to 11 Oxford landmarks. There are five possible queries for each landmark, and 55 queries in total. This dataset can be combined with the 100,071 distractors from Flickr100k [22] for large-scale retrieval evaluation. We denote the combined dataset as Oxford105k.

  • Paris6k [23] is similar to Oxford5k but consists of 6,412 images corresponding to 12 Paris landmarks. It can also be mixed with the Flickr100k, Paris106k namely, for large-scale retrieval evaluation.

  • Sculptures6k [1] has 6,340 smooth sculpture images, which are different from the previous two landmark datasets. The whole corpus is divided equally into training and testing datasets. Since our focus is generic instance retrieval, we evaluate our methods without using any training images for CNN learning or fine-tuning. There are 70 queries in total.

  • INSTRE [34] includes 23,070 images from 200 objects and one million distractor images. These objects can be categorized into three classes: architectures (buildings and sculptures), planar objects (designs, paintings and planar surface) and daily stereoscopic objects (toys and irregularly-shaped products). This dataset is challenging since there are diverse variations for each object and most of the objects are with cluttered and less contextual backgrounds. All the annotated images (23,070 in total) from the 200 objects are used as queries for performance evaluation purpose.

The query bounding boxes are provided on all the datasets and are used for cropping out the target objects during retrieval. The evaluation metric is mean average precision (mAP) for all the datasets.

V-A2 CFMs Extraction

We use VGG19 [27]

provided by Caffe

[13] and extract the CFMs from the last convolutional layer (conv5_4) because previous studies [4, 31, 14]

show that this layer achieves the best performance. Moreover, the original image sizes are kept for both database images and queries during feature extraction. However, for the large images (whose areas are greater than

) and the small images (whose shorter sides are smaller than 256), we resize them accordingly but keep their original aspect ratios. All the input images are zero-centered by RGB mean pixel subtraction [8].

V-A3 Global Feature Generation

We evaluate two state-of-the-art CFMs aggregation methods: the sum-pooled convolutional features (SPoC) without center prior [4] and the regional maximum activation of convolutions (R-MAC) [31]. We use the optimal settings reported in [4] and [31]. Both SPoC and R-MAC require PCA-whitening and the parameters of PCA are learned on hold-out images for all datasets [4]. Specifically, when performing retrieval on Oxford5k we learn the parameters on the images from Paris6, and vice versa. For Sculptures6k and INSTRE, we learn the parameters on Flickr100k. In the following experiments, we use the inner product as similarity measurement during retrieval for both SPoC and R-MAC. All the experiments are conducted on a Linux server with 40 3.0GHz CPU cores and 256GB memories.

V-B Performance of QAM Reranking

We first report the initial retrieval results of the aforementioned global representations in Tab. I, which serve as the baselines of the proposed method. Note that the mAPs of SPoC reported here are higher than those reported in [4] (e.g., the mAPs are increased from 0.531 to 0.666 on Oxford5k, and 0.501 to 0.606 on Oxford105k). This is due to the implementation differences: 1) in our implementation the image is not resized to square shape as in [4] when being fed into a CNN for feature extraction; 2) the original dimensionality of the representation is kept during the PCA-whitening step. From the table we can see R-MAC outperforms SPoC on all the datasets except on Sculptures6k. Therefore, we use R-MAC for initial retrieval when evaluating the performance of our proposed QAM reranking.

DIM. Ox5k Ox105k Pa6k Pa106k Sc6k INSTRE
SPoC 512 0.685 0.622 0.798 0.704 0.517 0.306
R-MAC 512 0.695 0.644 0.838 0.763 0.490 0.415
TABLE I: The mAPs of VGG19 with SPoC and R-MAC. “DIM.” denotes the feature dimensionality.

V-B1 QAM with FMP

QAM is based on the query feature and the region descriptors of a candidate image. To obtain , the query’s CFMs are sum-pooled and -normalized. For database images, we follow the procedure described in Sec. IV-B1 to obtain their region descriptors. The results are shown in Tab. II. Here we choose R-MAC for initial retrieval, the results of which serve as the baseline of our reranking method. From the results we see improvement of the reranking over the initial retrieval on all the datasets.

To demonstrate the effectiveness of QAM with FMP more intuitively, we visualize some merged feature maps after QAM in Fig. 6. We use the three example instances in Fig. 2 as queries and visualize the top 10 ranked candidates after reranking. Recall that the objective of QAM is to find the optimal merging of base regions of candidate images which maximizes the similarity to the query feature. After solving the matching problem in Eq. 6, we obtain the optimal aggregation weighting . We multiply the -th feature map by its corresponding weighting score , and then sum up all the feature maps to form a merged map. The locations with large values (the warm areas) are selected by QAM as the discriminative parts w.r.t the query, and the locations with zero values (the blue areas) tend to correspond to the irrelevant background which are ignored by the QAM. As seen, QAM detects the discriminative components of the target object and simultaneously suppresses the distractors. Another advantage of QAM with FMP is that it can select object parts in irregular shapes which can largely benefit feature aggregation.

Fig. 6: Visualization of merged feature maps after QAM. The three example images in Fig. 2 are used as queries. The first row in each group displays the top 10 ranked images after QAM reranking with FMP, and the second row shows their merged feature maps.

As mentioned in Sec. IV-B1, FMP generates 512 base regions for each database image among which some are overlapped. To reduce computational cost, our treatment is to perform spectral clustering to pre-merge the regions offline and the number of clusters correspond to the number of regions after this merging. To obtain a trade-off between reranking performance and retrieval efficiency we test the performance of FMP under different number of clusters in Tab II. As can be seen, initially increasing the number of clusters leads to better performance. One interesting discovery is that when , the performance is comparable to or even better than that obtained without clustering. And after , the results remain stable when continuously increasing . Based on this observation, we fix in the following experiments. With this pre-merging step, we downsize the FMP features from to .

Ox5k 0.695 0.709 0.689 0.706 0.710 0.709
Pa6k 0.838 0.844 0.844 0.844 0.845 0.845
Sc6k 0.490 0.515 0.512 0.513 0.514 0.515
Ox105k 0.644 0.658 - - 0.662 -
Pa106k 0.763 0.774 - - 0.774 -
INSTRE 0.415 0.436 - - 0.446 -
TABLE II: The mAPs before and after reranking with FMP. “BEF.” means the R-MAC results (in Tab. I) before QAM reranking. “AFT.” reports the reranking performance of original FMP descriptors before merging, and the following columns report the performance of compressed FMP descriptors with different cluster numbers. Note that we stop testing on large datasets (bottom row).

V-B2 QAM with OSPP

In this subsection, we evaluate the QAM reranking with the other base region generation strategy overlapped spatial pyramid pooling (OSPP). When reranking with OSPP, the query’s CFMs are aggregated via R-MAC and for candidate database images, we follow the procedure described in Sec. IV-B2 to generate their region descriptors. The number of scales is set to 3 () for both query and candidates which is the same as in [31]. The reranking results are show in Tab. III. As can be seen, the reranking with OSPP consistently outperforms the initial retrieval on all the datasets, which demonstrates the effectiveness of the proposed reranking method.

Moreover, we draw a comparison between the two proposed reranking methods in Tab. III. Based on different region generation mechanisms, these two reranking methods have different advantages. For FMP, it can generate base regions that correspond to object parts of irregular shapes which are more flexible than regular shapes such as rectangles. For OSPP, it considers the multi-scale information which makes the matching more robust. Thus, we see these two reranking strategies have different performances on the datasets. But generally, their performance are comparable and both outperform the R-MAC based initial retrieval.

V-B3 Computational Cost of QAM Reranking

Since efficiency is an important aspect of instance retrieval, in this subsection, we evaluate both the storage cost and computational cost of the proposed reranking strategies. Specifically, we report the average cost of performing one similarity matching. The results are shown in Tab. IV. For FMP based reranking, we use clustering to merge the region number of a database image from 512 to 25 offline which significantly reduces the memory footprints and the computational cost of QAM. For OSPP, the number of regions of a database image is 23 on average. The results demonstrate that both QAM strategies can be performed efficiently, about 15 ms, under tractable memory footprints. Since the reranking is conducted on the top 100 shortlist of initial retrieval, it costs about 1.6s for each query.

Ox5k Pa6k Sc6k INSTRE
BEF. 0.695 0.838 0.490 0.415
OSPP 0.736 0.842 0.505 0.436
FMP 0.710 0.845 0.514 0.446
TABLE III: The mAPs of QAM reranking with OSPP. “BEF.” means the R-MAC results (in Tab. I) before QAM reranking. The cluster number is for FMP.
FMP 51KB 0.016
OSPP 47KB 0.014
TABLE IV: The computational cost per image on average for FMP and OSPP, including the feature dimensionality (DIM.), the memory footprints (MEM.) and the similarity computation time (TIME, in seconds).
Remark DIM. Ox5k Ox105k Pa6k Pa106k Sc6k INSTRE
Jégou and Zisserman [12] SIFT 512 0.528 0.461 - - - -
Babenko et al. [5] CNN 512 0.557 0.522 - - - -
Razavian et al. [25] CNN 256 0.533 0.489 0.670 - 0.377 -
SPoC* [4] CNN 512 0.685 0.622 0.798 0.704 0.517 0.306
R-MAC* [31] CNN 512 0.695 0.644 0.838 0.763 0.490 0.415
Jégou et al. [10] BoW - 0.747 - - - - 0.268222This result is reported in [34]
Chum et al. [6] BoW - 0.827 0.767 0.805 0.710 - -
Mikulík et al. [20] BoW - 0.849 0.795 0.824 0.773 - -
Arandjelovic and Zisserman [1] BoB - - - - - 0.502 -
Tolias et al. [31] CNN - 0.773 0.732 0.865 0.798 - -
Ours CNN - 0.781 0.747 0.874 0.828 0.608 0.592
TABLE V: Comparison with Existing Methods. We report results for different retrieval methods with/without (bottom/top) post-processing. The “Remark” column shows the feature type used by each method. “DIM.” is the feature dimensionality. Methods with “*” are reported using our own implementations.

V-C Comparison With Existing Work

Our complete retrieval pipeline consists of three steps: initial retrieval with R-MAC, QAM reranking with FMP, and QE in the end (see Sec. IV-C). Here we compare our complete retrieval method to the state of the art in Tab. V.

The results are divided into two parts, with the above part being the retrieval methods using different compact representations but involving no post-processing, e.g., reranking, spatial verification, or QE, and the other part corresponding to methods that use post-processing strategies.

From the first part we observe that when aggregated to comparable dimensionalities, CNN based representations can have better retrieval performance than SIFT based compact representations and among the CNN representations, R-MAC performs best since it considers both the multi-scale information and weak spatial information.

The second part of Tab. V reports methods with post-processing. Jégou et al. [10] improves the traditional BoW model with hamming embedding and weak geometric consistency constraints, but the result of this method on INSTRE reported in [34] is far from satisfactory. Our method achieves the best performance on all datasets except for Oxford5k and Oxford105k, where the well developed BoW models [6, 20] are still better. Higher mAPs (more than 0.9) on Oxford5k and Paris6k are reported in [2] and [35]. But since their methods learn the visual codebooks on the original datasets and hence are highly tailored, the results are not directly comparable. Compared to [1] in which specialized representations, namely Bag-of-Boundaries (BoB), for smooth object are proposed, our method outperforms it by 10% and has better generalization ability as well. Our main focus is on comparing to the latest work in [31] since their representation is based on CFMs and we have similar retrieval pipelines. The most notable difference between their method and ours lies in the reranking strategy. For fair comparison, we use similar initial retrieval as [31]. From the results we can see our method consistently has superior performance. Another point worth mentioning is that, as far as we know, our method achieves the best performance on the INSTRE dataset among the reported results which shows the robustness of our reranking method on dataset with cluttered backgrounds.

Finally we show the search time of different components of the retrieval pipelines for each query and the memory consumption of the whole retrieval framework on different dataset sizes in Tab. VI.

TIME (seconds) MEM.
INIT. QAM QE tot. R-MAC FMP tot.
5K 0.001 1.161 - 1.163 10MB 256MB 266MB
100K 0.017 1.160 1.194 200MB 5.1GB 5.3GB
1M 0.127 1.374 1.628 2GB 51.2GB 53.2GB
TABLE VI: The searching time (TIME) and memory footprints (MEM.) on different dataset sizes (5k, 100k, 1M). The search time per query includes initial search (INIT., excluding query feature extraction), reranking (QAM) and query expansion (QE, the same as initial search). The memory footprints required by all database images include global features (R-MAC) and multi-region features (FMP). The total amount of costs are summarized in the “tot.” columns.

V-D Performance with Deeper Networks

Recent works discover that deeper neural networks can lead to significant improvement on tasks like image classification and object detection. Here we explore two of these deeper networks on instance retrieval. One is GoogLeNet [29]

which is a 22-layer network incorporating the “Inception” modules and the other one is a recently proposed 152-layer convolutional neural network

[7], named deep residual net (ResNet152).

V-D1 Feature Patterns

To intuitively understand the CFMs of these two networks, we first visualize the feature patterns of the CFMs of these two networks. Specifically, for each layer’s CFMs, we calculate the -norm for all the local descriptors () and normalize them by the maximum norm value in this layer. The heat maps of these norm values indicate the activation degree of different image parts. From the better explored AlexNet or VGG net we know that generally the CFMs of lower layers correspond to some primary patterns like edges, and CFMs of higher layers capture some object-related semantics. And the heat maps tend to be spatially sparse. Here we observe some difference for the CFMs of GoogLeNet and ResNet152, the visualizations of which on the first example image from Fig. 2 are shown in Fig. 7.

For GoogLeNet, the structures of the objects persist in CFMs from Inception 4a to 4e layer where the activated patterns are sparse and correspond to some meaningful object parts but the structure information tends to be lost in higher layers (5a and 5b). For ResNet152, the sparse property does not hold in lower layers (conv1 to res4) but persist in higher layers (res5a-res5c). Since the activated pattern plays an important role in CFMs aggregation, we attempt to unveil some relationship between the retrieval performance of CFMs and their corresponding feature patterns.

Fig. 7: The heat map of local descriptors’ -norms from GoogLeNet’s Inception layers (top) and ResNet152’s residual layers (bottom). Below are the layers’ names and their depths (e.g., “4a (9)” means the “Inception 3a” layer and its depth is 9 in GoogLeNet). The layers’ names are consistent with the network structures defined in their Caffe “.prototxt” files.

V-D2 Choosing the Right Layer

Here we evaluate the retrieval performance of CFMs from different layers using different global aggregation methods (Sec. V-A3). For GoogLeNet, we select the last six Inception modules (Inception 4b to Inception 5b) for testing. Fig. 8 shows the retrieval performance of different layers. As we can see, initially the mAPs on all datasets are improved from lower to higher layers (from 4b to 4e), but the last two Inception layers (5a and 5b) have inferior performance. The reason of the performance degradation may lie in our aformentioned analysis that the spatial structure and sparsity are weakened in the two higher layers. On Paris6k and Sculptures6k, GoogLeNet is outperformed by VGG19 and on Oxford5k GoogleNet performs better.

For ResNet152, we select the last five residual modules (res4b34 to res5c) for testing as shown in Fig. 9. From this figure we observe that generally higher layers perform better and the best performed setting of ResNet152, i.e., res5b with R-MAC, can signifiantly outperform VGG19. However, the improvements are bought at the price of more memory and computational cost: the dimensionality of ResNet152’s best performed layer, res5b, is 2,048, which is four times higher than that in VGG19.

Fig. 8: The mAPs of GoogLeNet’s different layers on Oxford5k, Paris6k and Sculptures6k (from left to right). The “VGG19 + SPoC” and “VGG19 + R-MAC” are the baseline results of VGG19 in Tab. I. The horizontal axis gives the layers’ names and their feature dimensionalities after aggregation (e.g., “4b (512)” means the “Inception 4b” layer and the dimensionality of its aggregated feature is 512).
Fig. 9: The mAPs of ResNet152’s different layers on Oxford5k, Paris6k and Sculptures6k (from left to right). Similar to Fig. 8, below are the layers’ names and their dimensionalities (e.g., “res4b34 (1024)” means the “residual 4b34” layer and the dimensionality of its aggregated feature is 1024).

V-D3 Final Integration

Finally, we test our methods with CFMs from the res5b layer of ResNet152. The whole retrieval pipeline is still the same: initial retrieval with R-MAC, followed by QAM re-ranking with OSPP, and finally QE. Note that OSPP is applied here instead of FMP because it takes too much time to downsize the FMP features from to via clustering for each image. The results are shown in Tab. VII. We can see the ResNet152 can significantly outperform VGG19 on all the datasets. The results demonstrate the effectiveness of deeper network in instance retrieval. However, these improvements are brought at the price of more memory and computational cost.

Ox5k Ox105k Pa6k Pa106k Sc6k INSTRE
VGG19 0.781 0.747 0.874 0.828 0.608 0.592
ResNet152 0.828 0.814 0.893 0.858 0.712 0.670
TABLE VII: The mAPs of our retrieval framework with different CFMs of different networks.

Vi Conclusion

In this work, we propose a reranking algorithm, namely query adaptive matching, for instance retrieval using convolutional feature maps. The key idea is to represent a candidate database image by a set of base regions and generate a target object focused representation resorting to the similarity to the query image. We formulate the similarity matching as well as the region merging process as an optimization problem which can be solved efficiently. Apart from this general framework, we propose two practical ways to generate the base regions. The experiments on several instance retrieval datasets demonstrate the effectiveness of the proposed reranking method.


  • [1] R. Arandjelovic and A. Zisserman. Smooth object retrieval using a bag of boundaries. In ICCV, 2011.
  • [2] R. Arandjelovic and A. Zisserman. Three things everyone should know to improve object retrieval. In CVPR, 2012.
  • [3] R. Arandjelovic and A. Zisserman. All about VLAD. In CVPR, 2013.
  • [4] A. Babenko and V. S. Lempitsky. Aggregating deep convolutional features for image retrieval. In ICCV, 2015.
  • [5] A. Babenko, A. Slesarev, A. Chigorin, and V. S. Lempitsky. Neural codes for image retrieval. In ECCV, 2014.
  • [6] O. Chum, A. Mikulík, M. Perdoch, and J. Matas. Total recall II: query expansion revisited. In CVPR, 2011.
  • [7] K. He, X. Zhang, S. Ren, and J. Sun. Deep residual learning for image recognition. In CVPR, 2016.
  • [8] F. N. Iandola, M. W. Moskewicz, S. Karayev, R. B. Girshick, T. Darrell, and K. Keutzer. Densenet: Implementing efficient convnet descriptor pyramids. CoRR, abs/1404.1869, 2014.
  • [9] H. Jégou, M. Douze, and C. Schmid. Hamming embedding and weak geometric consistency for large scale image search. In ECCV, 2008.
  • [10] H. Jégou, M. Douze, and C. Schmid. Improving bag-of-features for large scale image search. IJCV, 2010.
  • [11] H. Jégou, F. Perronnin, M. Douze, J. Sánchez, P. Pérez, and C. Schmid. Aggregating local image descriptors into compact codes. TPAMI, 2012.
  • [12] H. Jégou and A. Zisserman. Triangulation embedding and democratic aggregation for image search. In CVPR, 2014.
  • [13] Y. Jia, E. Shelhamer, J. Donahue, S. Karayev, J. Long, R. B. Girshick, S. Guadarrama, and T. Darrell. Caffe: Convolutional architecture for fast feature embedding. In MM, 2014.
  • [14] Y. Kalantidis, C. Mellina, and S. Osindero. Cross-dimensional weighting for aggregated deep convolutional features. CoRR, abs/1512.04065, 2015.
  • [15] A. Krizhevsky, I. Sutskever, and G. E. Hinton. Imagenet classification with deep convolutional neural networks. In NIPS, 2012.
  • [16] Y. LeCun, B. E. Boser, J. S. Denker, D. Henderson, R. E. Howard, W. E. Hubbard, and L. D. Jackel. Backpropagation applied to handwritten zip code recognition. NECO, 1989.
  • [17] L. Liu, C. Shen, and A. van den Hengel. The treasure beneath convolutional layers: Cross-convolutional-layer pooling for image classification. In CVPR, 2015.
  • [18] J. Long, N. Zhang, and T. Darrell. Do convnets learn correspondence? In NIPS, 2014.
  • [19] D. G. Lowe. Distinctive image features from scale-invariant keypoints. IJCV, 2004.
  • [20] A. Mikulík, M. Perdoch, O. Chum, and J. Matas. Learning vocabularies over a fine quantization. IJCV, 2013.
  • [21] F. Perronnin, Y. Liu, J. Sánchez, and H. Poirier. Large-scale image retrieval with compressed fisher vectors. In CVPR, 2010.
  • [22] J. Philbin, O. Chum, M. Isard, J. Sivic, and A. Zisserman. Object retrieval with large vocabularies and fast spatial matching. In CVPR, 2007.
  • [23] J. Philbin, O. Chum, M. Isard, J. Sivic, and A. Zisserman. Lost in quantization: Improving particular object retrieval in large scale image databases. In CVPR, 2008.
  • [24] A. S. Razavian, H. Azizpour, J. Sullivan, and S. Carlsson. CNN features off-the-shelf: An astounding baseline for recognition. In CVPRW, 2014.
  • [25] A. S. Razavian, J. Sullivan, A. Maki, and S. Carlsson. A baseline for visual instance retrieval with deep convolutional networks. In ICLRW, 2015.
  • [26] O. Russakovsky, J. Deng, H. Su, J. Krause, S. Satheesh, S. Ma, Z. Huang, A. Karpathy, A. Khosla, M. Bernstein, A. C. Berg, and L. Fei-Fei. ImageNet Large Scale Visual Recognition Challenge. IJCV, 2015.
  • [27] K. Simonyan and A. Zisserman. Very deep convolutional networks for large-scale image recognition. CoRR, abs/1409.1556, 2014.
  • [28] J. Sivic and A. Zisserman. Video google: A text retrieval approach to object matching in videos. In ICCV, 2003.
  • [29] C. Szegedy, W. Liu, Y. Jia, P. Sermanet, S. Reed, D. Anguelov, D. Erhan, V. Vanhoucke, and A. Rabinovich. Going deeper with convolutions. In CVPR, 2015.
  • [30] R. Tao, E. Gavves, C. G. M. Snoek, and A. W. M. Smeulders. Locality in generic instance search from one example. In CVPR, 2014.
  • [31] G. Tolias, R. Sicre, and H. Jégou. Particular object retrieval with integral max-pooling of CNN activations. In ICLR, 2016.
  • [32] U. von Luxburg. A tutorial on spectral clustering. SAC, 2007.
  • [33] J. Wan, D. Wang, S. C. Hoi, P. Wu, J. Zhu, Y. Zhang, and J. Li. Deep learning for content-based image retrieval: A comprehensive study. In MM, 2014.
  • [34] S. Wang and S. Jiang. INSTRE: A new benchmark for instance-level object retrieval and recognition. TOMM, 2015.
  • [35] Z. Zhong, J. Zhu, and S. C. H. Hoi. Fast object retrieval using direct spatial matching. TMM, 2015.