{'fraction_non_alphanumeric': 0.033482142857142856, 'fraction_numerical': 0.011732360627177701, 'mean_word_length': 4.850772415989807, '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}}
End-to-End Comparative Attention Networks for Person Re-identification

Person re-identification across disjoint camera views has been widely applied in video surveillance yet it is still a challenging problem. One of the major challenges lies in the lack of spatial and temporal cues, which makes it difficult to deal with large variations of lighting conditions, viewing angles, body poses and occlusions. Recently, several deep learning based person re-identification approaches have been proposed and achieved remarkable performance. However, most of those approaches extract discriminative features from the whole frame at one glimpse without differentiating various parts of the persons to identify. It is essentially important to examine multiple highly discriminative local regions of the person images in details through multiple glimpses for dealing with the large appearance variance. In this paper, we propose a new soft attention based model, i.e., the end to-end Comparative Attention Network (CAN), specifically tailored for the task of person re-identification. The end-to-end CAN learns to selectively focus on parts of pairs of person images after taking a few glimpses of them and adaptively comparing their appearance. The CAN model is able to learn which parts of images are relevant for discerning persons and automatically integrates information from different parts to determine whether a pair of images belongs to the same person. In other words, our proposed CAN model simulates the human perception process to verify whether two images are from the same person. Extensive experiments on three benchmark person re-identification datasets, including CUHK01, CHUHK03 and Market-1501, clearly demonstrate that our proposed end-to-end CAN for person re-identification outperforms well established baselines significantly and offer new state-of-the-art performance.


I. INTRODUCTION
R ECENTLY, person re-identification (re-id), i.e., person or pedestrian re-identification across multiple cameras without overlapping view, has received increasing attention [1]- [17]. It aims to re-identify a person that has been captured by one camera in another camera at any new location. Person re-identification has many important applications in security systems and video surveillance of public scenarios such as stores and shopping malls. However, it is still challenging to obtain satisfactory results in terms of accuracy in real-world Hao Fig. 1. Sample frames of persons captured by two cameras located at different places (shown in top and bottom rows respectively). Each column corresponds to one person. The frames present large variations in lighting, view point and pose on the same person captured by different cameras. Contrast to the whole image, some local parts of person image, such as clothing, carry-on baggage, even the environment, would be more discriminative and deserve more attention in the process of person re-identification. Therefore, adaptively localizing the discriminative parts is important for person re-identification. scenarios due to the large appearance variance across multiple cameras. For example, as shown in Fig. 1, people usually pose differently over time. Besides, other factors such as variations in color, illumination, occlusion as well as low-resolution of the captured frames also increase difficulties of the realistic person re-identification.
Recently, several research attempts have been made for solving the re-identification problem through effectively reasoning over the person appearance. Some approaches for person reidentification [13], [14], [16], [17] utilize the Convolutional Neural Networks (CNNs) to learn effective representation of person appearance and achieve remarkable performance. However, most of them [13], [14], [16], [17] take the whole person image as input without any focus on local regions. As a consequence, the performance of such approaches may still suffer from factors such as illumination variance and occlusion. Considering the problems above, we propose a model which can find some local regions with more discriminative information in person images to further improve the person re-identification performance.
According to related research [1]- [17] and our daily experience, in the process of a human discerning another in a crowd, the human often abstracts the discriminative features of all the individuals and then compare the similarity and difference of them to find the specific one correctly, and this process can be repeated many times (i.e. multiple glimpses of each person). At the end of the process, the information gathered from glimpses are integrated as the comprehensive information to help the discerning. Inspired by this observation, we propose attention based model with inherent comparative components to solve the person re-identification problems.
With the recent development of Recurrent Neural Networks (RNNs) based on Long Short-Term Memory (LSTM) [18], the attention based models have demonstrated outstanding performance on several challenging sequential data recognition and modeling tasks, including caption generation [19], machine translation [20], as well as action recognition [21]. Briefly, similar to human visual processing, attention-based algorithms tend to selectively concentrate on a part of the information, and at the same time ignore other perceived information. Such a mechanism is usually called attention and can be employed to adaptively localize discriminative parts or regions of person images. Thus it is helpful to solve the person re-identification problem, which however has been rarely considered in the literatures.
In this work, we go beyond the standard LSTM based attention models and propose an end-to-end Comparative Attention Network (CAN). The proposed end-to-end CAN framework simulates the re-identification process of human visual system by learning a comparative model from raw person images to recurrently localize some discriminative parts of person images via a set of glimpses. At each glimpse, the model generates different parts without any manual annotations. It takes both the raw person images and the locations of a previous glimpse as inputs, and produces the next glimpse local region features as the outputs. These features can be regarded as a kind of dynamical pooling feature, and we show that exploiting these features generated by our CAN model for person re-identification performs better than conventional pooling features, which is used by many existing models [13], [14], [16], [17]. In contrast, our approach is also able to achieve comparatively better performance compared to other methods, as validated by experimental results.
In summary, we make following contributions to person reidentification: • We propose a new attention model that dynamically generates discriminative features in a recurrent way of "seeing" and "comparing" person images for automatically localizing the most discriminative parts of persons. • We develop a comparative network that can efficiently seek discriminative parts of person image pairs by incorporating an on-line triplet selection method. Moreover, our CAN framework is able to generate attention parts directly from raw person image pairs in an end-to-end way. • Finally, we quantitatively validate the good performance of our end-to-end CAN framework by comparing it to the state-of-the-art performance on three benchmark datasets: CUHK01 [9], CUHK03 [13] and Market-1501 [15].
The paper is organized as follows. Sec. II reviews the related work briefly. In Sec. III, the framework is described in details. Then, the experimental results on several public benchmark datasets are shown and the analyses are given in Sec. IV. Finally, a conclusion is presented in Sec. V.

II. RELATED WORK
Typically, extracting features from input images and seeking a metric for comparing these features across images are two main components of person re-identification. The basic thought of searching for better feature representation is to find features that are partially invariant to lighting, pose, and viewpoint changes. A part of existing methods primarily employ hand crafted features such as color and texture histograms. Some studies have obtained more discriminative and robust feature representation, such as Symmetry-Driven Accumulation of Local Features (SDALF) [4] exploiting both symmetry and asymmetry color and texure information and Ensembles of Localized Features (ELF) [2] using AdaBoost to select discriminative color and texture features. Additionally, some saliency-related methods [10], [11] have been proposed to enhance the ability of representation and discrimination of the feature for person re-identification. In [10], the authors presented a method of adjacency constrained patch matching to build dense correspondence between image pairs in an unsupervised way. Moreover, an approach called SalMatch [11] integrated both salience matching and patch matching based on the RankSVM framework. And mid-level filters (Mi-dLevel) [12] was learned from patch clusters with coherent appearance obtained by pruning hierarchical clustering trees to get view-invariant and discriminative features.
Compared with the methods where complicated handcrafted feature representation is designed, there are some approaches using metric learning, which formulate the person reidentification as a supervised distance metric learning problem where a transformation matrix is learned so that the Mahalanobis distance is relatively small when extracted features represent a same person and big otherwise. To achieve this goal, Large Margin Nearest Neighbor (LMNN) [5], Logistic Discriminant Metric Learning (LDM) [3], Information Theoretic Metric Learning (ITML) [1], and Kernelized Relaxed Margin Components Analysis (KRMCA) [22] are representative methods. Inspired by the thought of comparison in [5], [3], [1] and [22], we exploit the triplet loss function in this paper, forcing the similarities of instances "more similar" and diversities "more different". Besides, in [6], Pairwise Constrained Component Analysis (PCCA) learns distance metrics from sparse pairwise similarity/dissimilarity constraints in the high dimensional input space. And large scale metric learning from equivalence constraint (KISSME) [7] considers a loglikelihood ratio test of two Gaussian distributions. In [8], the authors presented an effective structured learning based approach by combining multiple low-level hand-crafted and high-level visual features.
Despite the hand-crafted features based methods aforementioned, there are several deep learning based person reidentification approaches proposed [16], [13], [14], [17]. [13] proposed a method learning a Filter Pairing Neural Network (FPNN) to encode and model photometric transforms for person re-identification. In [14], a Siamese CNN, which is connected by a cosine layer, jointly learns the color feature, texture feature and metric in a unified framework. Moreover, [17] improved the performance by increasing the depth of   layers and using very small convolution filters.
Recently, LSTMs have shown good performance in the domain of speech recognition [23] and image description [19]. More recently, [21] developed recurrent soft attention based models for action recognition and analysed where they focus their attention. Especially, the authors suggested that it is quite difficult to interpret internal representations learned by deep neural networks. Therefore, attention models add a dimension of interpretability by capturing where the model is focusing its attention when performing a particular task. Inspired by the above work, in this paper, we employ the recurrent attention model to generate different attention location information by comparing image pairs of persons and then integrate them together. As far as we know, our work is the first one applying the attention model to the person re-identification problem. Similar to saliency-related [10], [11], [12] methods mentioned above, the attention model is also a kind of saliency to certain extent, but our attention model can directly obtain the saliencylike attention maps from raw person image due to the end-toend training pattern. Moreover, different from other attention models, our attention model generates attention maps based on the comparison over image triplets of people. Consequently, our network outperforms all previous approaches on benchmark person re-identification datasets.

III. MODEL ARCHITECTURE
In this paper, we propose an end-to-end Comparative Attention Network (CAN) based architecture that formulates the problem of person re-identification as discriminative visual attention finding and ranking optimization. Fig. 2 illustrates our network architecture (III-A). For a given triplet of person images, we first apply CNN at each one to learn and extract features. Then the features are passed to the LSTM-based (III-B) comparative attention components (III-C) to obtain the discriminative attention masked features at different time steps. To combine these different time-step features and make them more discriminative, a triplet selection method (III-D) is utilized after concatenating different time-step features. Each of these components is explained in the following subsections.
A. End-to-End Comparative Attention Network Architecture Fig. 2 illustrates the architecture of the proposed end-to-end Comparative Attention Network (CAN). The CAN network can localize and compare multiple person parts using the comparative attention mechanism. In this section, we describe how our comparative attention network works in the training phase and the test phase individually.
1) Training Phase: During training, the model starts from processing a triplet of images. Here, we denote the images of a triplet as I, I + and I − , corresponding to the anchor sample, the positive sample and the negative sample respectively. I and I + come from the same class (positive pair), while I − is from a different class (negative pair). The objective of CAN is to learn effective feature representation and to generate discriminative visual attention regions. Thus, in terms of the features extracted from the attention regions, the truly matched images are closer than the mismatched images by training the model on a set of triplets I, I + , I − . Fig. 2(a) shows the overall architecture used for training which consists of following two parts: feature learning and comparative attention components. In this paper, we adopt the truncated Alexnet [24] for feature learning. In particular, we generate appearance features X = φ A (I) using the first five layers of the AlexNet. We pre-train an eight-layer classification model, which contains five convolutional feature learning layers with three fully-connected classification layers followed. After the pretraining of this network, the last three fully-connected layers are replaced with our proposed comparative attention model. The five convolutional layers are used to learn discriminative appearance features. Then, they are passed to our proposed comparative attention model to generate the comparative visual attention regional features, which are denoted as H = β(X).
Here, β denotes the comparative attention generation part of our model, and H correspond to local comparative attention features of persons. Note that all the person samples in a triplet share the same parameters in feature learning and comparison, as shown in Fig. 2(a). Details of the comparative attention model will be given in Section III-B and III-C.
As mentioned above, our goal is to generate discriminative feature representation and visual attention regions through comparing the similarity and difference of positive and negative pairs in each triplet. Therefore, we adopt the triplet loss [25] as the final loss function. Within a triplet of we expect features of the positive sample H + is more similar to H i than the features of the negative sample: Here α is a margin that is introduced to enhance the discriminative ability of learned features between positive and negative pairs. Therefore, for N triplets, the loss function that CAN is going to minimize is: where [·] + truncates the involved variable at zero. Next, we proceed to introduce how to apply the network trained for testing.
2) Test Phase: As shown in Fig. 2(b), it also has two parts in the testing architecture, features extraction and comparative attention generation. After passing a set of person image pairs in the testing set into the trained CAN, the distances of them are computed. Then the ranking unit directly outputs the final ranking results. Here, we adopt average CMC (Cumulative Matching Characteristics) [26] and the accuracy at top ranks as the evaluation metrics, as in [1]- [17]. The detailed definition of CMC will be given in the Sec.IV-A. It is worth to mention that we also examine these items to see the performance of the whole network on the validation dataset during the training phase. This is because the training loss can only reflect the tendency of performance variance on the training set while the output evaluations on the validation set can directly indicate the true ranking performance. That is, we can train the network through directly optimizing the ranking results on the validation set.

B. Long Short-Term Memory Networks
In our CAN framework, we use a long short-term memory (LSTM) network to produce a local attention region at every Fig. 3. A single time-step LSTM unit which takes masked CNN feature map and previous hidden state as input. Each component of LSTM learns how to cooperate to weigh the input information (input gate), i.e. to remember the useful one (memory state) and to erase the unnecessary one (forget gate). Finally, the output gate controls how the filtered memory should be emitted. time step conditioned on D CNN feature maps, the previous hidden state and the previous generated attention location map. The size of the feature map is K × K × D. We use the LSTM implementation, shown in Fig. 3, introduced in [27], [19] and [21]. The formulations are shown as follows: where i t , f t , c t , o t and h t are the input gate, forget gate, cell state, output gate and hidden state respectively. In addition, x t represents the input feature to the LSTM at time-step t and M is an affine transformation containing a set of learnable weights parameters. At each time-step t, the LSTM of our model predicts l t+1 , which denotes the softmax locations of size K × K and is defined as follows: where W i,h denotes the weight parameters to generate softmax locations. Then, the aggregated (via pooling) feature can be computed as follows: where X t and X t,i correspond to the feature maps and the i th slice of the feature cube at time-step t. We adopt the similar initialization method for memory state and hidden state used in [21]: where f init,c and f init,h are two-multilayer perceptrons and T is the number of time-steps in the model. These values are used to calculate the initial softmax attention location l 1 which is applied on CNN features X 1 to get the initial input x 1 as shown in Fig. 3 and Fig. 4.

C. The Comparative Attention Model
We extract the CNN features as the inputs of our LSTMbased comparative attention components. Generally, CNN is used to obtain the global discriminative features from raw person images while the comparative attention components generate more local attention regions through comparing different person images. Intuitively, this mechanism has somewhat similarity with the function of the human visual system. In this subsection, we look inside the comparative attention components. The detailed composition shown in Fig. 3 corresponds to the attention components in the training phase and the test phase in Fig. 2. The brief working process of the comparative attention components is illustrated in Fig. 4. Note that although we simply show one attention component here, there exist three weight-sharing attention components working simultaneously in the training phase, among which two work in the test phase in practice, as shown in Fig. 2. At each timestep, the attention component takes CNN features extracted from a triplet of raw person images as its inputs. Each triplet of person images is "seen" once by our attention component in one glimpse.
Then some information is "remembered" and some "forgotten", decided by the LSTM unit, in order to generate attention location maps and hidden states for the next timestep or "glimpse". For the hidden states output by each timestep of comparative attention components, they contain the memory in the process of comparing person images, and are exploited to obtain the local attention maps, as introduced in III-B. Therefore, to combine all the generated attention parts information and utilize it as holistic discriminative features for comparison, a concatenation layer is applied to concatenate a few time-steps of hidden states. Our CAN framework employs the triplet loss function and the whole framework is a threeweights-sharing-branch as well as recurrent network, so it does not converge quickly. To make the network converge faster, the concatenated features are passed to the 2 -normalization layer as the output of attention components: where c = [c 1 , c 2 , ..., c q ] is the output of the concatenation layer with dimension r. The 2 -normalization layer ensures that the distance computed from each triplet can not exceed the margin α described in Eqn. (1). It is obvious that the upper bound of the distance between two 2 -normalized concatenated features of two person images is two. Therefore, more triplet constraints can take effect for the loss function, which accelerates convergence speed of the end-to-end CAN framework training.

D. Triplet Selection
It is crucial to select triplets that violate the constraint given in Eqn. (1). In particular, given H i , we want to select a pos- However, it is difficult and unrealistic to compute the argmin and argmax for the whole training set. Furthermore, our model needs to compare pair-wise images and to generate a series of attention locations for every image of each person. Therefore, it requires an efficient way to compute the argmin and argmax. There are two methods to be chosen as mentioned in [25]: • Off-line triplets selection. The triplets are generated every few steps, and the most recent network checkpoint is employed to compute the argmin and argmax. • On-line triplets selection. The selection can be done within a mini-batch. Obviously, generating all possible triplets would result in overwhelming many triplets that are feasible for the constraint in Eqn.1. But some of these triplets would not contribute to the training and slow down the convergence of model training.
Besides, they would still be passed through the network, which cause large unnecessary resource consumption. Different from off-line triplets selection method, on-line triplets selection approach selects triplets that are active and can contribute to improving the model within a mini-batch, so it is of higher efficiency and lower resource consumption. Therefore, we adopt the on-line triplets selection method in this paper. Specifically, instead of picking the hard positive, we adopt all positive pairs and randomly sample negative samples added to each mini-batch. In practice, we find that using all positive pairs makes the model more stable and converge faster than selectively using hard positive pairs in a mini-batch.

A. Datasets and Evaluation Protocol
There exist several challenging benchmark data sets for person re-identification. In this paper, we use CUHK01 [9], CUHK03 [13] and Market-1501 [15], which are three largest benchmarks available, to conduct experiments. In experiments, for each pedestrian, the matching of his or her probe image (captured by one camera) with the gallery images (captured by another camera) is ranked. To reflect the statistics of the ranks of true matches, the Cumulative Match Characteristic (CMC) curve is adopted as the evaluation metric. Specifically, to create a CMC curve, the L2-norm distances between probe samples and those of gallery samples are computed firstly. Secondly, for each sample, a rank order of all the samples in the gallery is sorted from the sample with the smallest distance to the biggest distance. In the end, the percentage of true matches founded among the first m ranked samples is computed and denoted as rank(m). Note, all the CMC curves are computed with single-shot setting. And for the Market-1501 dataset, mean average precision (mAP) as in [15] is also employed to evaluate the performance since there are on average 14.8 cross-camera ground truth matches for each query.
1) CUHK01: The CUHK01 [9] dataset contains 971 persons captured from two camera views, and each of them has two images in each camera view. Camera A captures the individuals in frontal or back views while camera B captures them in side views. All the images are normalized to the size of 160×60 pixels. We randomly divide the data set into a training set of 871 people and a test set of 100 people. This procedure is repeated 10 times and the average of CMC curves is reported.
2) CUHK03: There are 13,164 images of 1,360 identities contained in the CUHK03 dataset [13]. All pedestrians are captured by six cameras, and each person is only taken from two camera views. It consists of manually cropped person images and images automatically detected by the Deformable-Part-Model (DPM) detector [28]. This is a more realistic setting considering the existence of misalignment, occlusions, body part missing and detector errors. We evaluate the performance of CAN with the similar setting of [13]. That is, the dataset is randomly partitioned into two parts: 1,160 persons for training and 100 persons for testing. This random partition is repeated for 20 times for computing averaged performance.
3) Market-1501: Market-1501 [15] is currently the largest public available re-identification dataset, containing 32,668 detected bounding boxes of 1,501 persons, with each of them captured by six cameras at most and two cameras at least. Similar to the CUHK01 dataset, it also employs DPM detector [28]. We use the provided fixed training and test set, containing 750 and 751 identities respectively, to conduct experiments.

B. Parameters Setting
We implement our network using Caffe [29] deep learning framework. The training of the network converges in roughly 8-10 hours on NVIDIA GeForce GTX TITAN X GPU. In all of experiments, the dimensionality of the LSTM hidden state, the cell state, and the hidden layer are set to 512 for CUHK01, CUHK03 and Market-1501. All the images are resized to 227 × 227 to train our model. As mentioned above, we first use the softmax regression network to pre-train the truncated CNN. At this stage, we perform stochastic gradient descent [30] to update the weights. We start with a base learning rate of η (0) = 0.01 and gradually decrease it along with the training process using an inverse policy: η (k) = η (0) (1 + γ · k) −p where γ = 10 −4 , p = 0.75, and k is index of the current mini-batch iteration. We use a momentum of µ = 0.9 and weight decay λ = 5 × 10 −4 . After the CNN feature learning network is pre-trained, we use the pre-trained model to initialize our endto-end Comparative Attention Network (CAN). Here, we use the weight update parameter settings similar to those in the pre-training stage except that the initial learning rate is set to η (0) = 0.001. As mentioned above, we adopt the on-line triplet selection method, so the batchsize is set to 134 determined by cross-validation. We empirically set the value of the margin parameter as α = 0.3. As mentioned in Sec. III-B, hidden states of LSTM at different time-steps are concatenated as the final features passed to the normalization layer. Thus, we use 8 time-steps and the extracted hidden states of the 2 nd , 4 th and 8 th time-step in all experiments. It is illustrated in Fig. 5(d) and is validated in Sec. IV-D.

C. Data Augmentation
In the training set, there exist much more negative pairs than positive pairs, which can lead to data imbalance and overfitting. To overcome this issue, we artificially augment the data by performing random 2D translation, similar to the processing in [13]. For an original image of size w × h, we sample ten same-sized images around the image center, with translation drawn from a uniform distribution in the range [−0.05w, 0.05w] × [−0.05h, 0.05h]. For CUHK01 dataset, we also horizontally flip each image. In addition, because we use the on-line triplet selection method (see III-D), we randomly shuffle the dataset in terms of their labels. Through this shuffle strategy, more triplets can be produced in a minibatch. Specifically, we perform this operation ten rounds for each dataset.

D. Analysis of the Proposed Model
In Sec. III, we introduce our model architecture using CNN as the features extractor. Here we compare the performance of our model by using features extracted from different layers: Conv5 and M ax5, which represent features from the 5 th convolutional layer and from the 5 th max pooling layer, respectively. Note, if Conv5 is used as a feature, the shape of the feature cube is 13 × 13 × 256, while if M ax5 is used as a feature, the shape of the feature cube is 6 × 6 × 256. The experimental results on CUHK03 dataset are shown in Table I. From it, we observe that using M ax5 can achieve better performance than using Conv5 as features. This may be because the M ax5 can represent more abstract information for each person image, and provide more effective information for the subsequent comparative attention components. Moreover, different from [21], our attention-based model is end-to-end trainable, which means that the comparative attention location maps can be obtained directly from the raw person images. So in Table I, we also compare the performance of end-to-end CAN with CAN using pre-extracted CNN features. It suggests that end-to-end CAN can achieve better results than the one using pre-extracted CNN features. This is because the features extraction and comparative attention components of the end-to-end version both participate in the process of comparing person images and updating the parameters. Otherwise, if the features are pre-extracted and sent to the attention model, the CNN features may not contain enough comparative information since the CNN model is pretrained using the network for the classification task.
To further demonstrate the effectiveness of the comparative attention components in CAN, we also compare the performance of the proposed CAN with that of a similar architecture with input of each LSTM replaced by the simple average pooling or max pooling output in Fig. 4. In other words, we use the same architecture illustrated in Fig. 2 except that none of the attention mechanisms is contained in the model, and thus there are no softmax location map produced and all locations in a feature map have the same weight. Note that the model used here is also in an end-to-end form. From the results given in Table I, it is obvious that comparing positive pair and negative pair of each person triplet and staying focus on those more discriminative parts or locations can perform better than using the complete feature cube to discern different persons.
In the end, we also conduct a series of experiments to evaluate which time-steps are chosen to be concatenated can achieve the best performance for our model. We use the following three settings: i) all the time-steps; ii) last timestep; iii) 2 nd , 4 th and 8 th time-steps. The experimental results are shown in Fig. 5(d). We find that using the third setting can make our framework perform best.
1) Results on CUHK01 and CUHK03: These two datasets consist of thousands of training samples. Table II and Fig. 5(a) show results on CUHK01. Our method beats all compared methods at low ranks and achieves around 10% improvement in Rank1 recognition rate compared to the second best method (PersonNet [17]), which is significant. As for CUHK03, there are two settings: manually cropped person images and person images produced by DPM detector. Obviously, the performance on the latter one appears lower than that on the former, as shown in Fig. 5(b), Fig. 5(c), Table III and  Table IV. However, the images produced by the detector can also reflect the algorithms in the real world. It can be seen from Fig. 5(b) and Table III that, as expected, on this large dataset, some other deep learning based methods, such as PersonNet [17], can achieve similar performance with millions of parameters or become much more competitive. However, with the detector boxes, our method is less affected, especially for the Rank1, and outperforms other approaches including deep learning based ones by a large margin. We suppose that the performance is not affected too much, possibly because our model could accurately attend to different discriminative parts of images and integrate their information which is robust to the influence brought by the detector. 2) Results on Market-1501: Market-1501 is a large and realistic dataset since it was captured in a scene of crowded supermarket with complex environment. Besides, it contains several natural detector errors as the person images were collected by applying the automatic DPM detector. Each person is captured by by six cameras at most in Market-1501 -the number of cameras is significantly larger than the CUHK01 and CUHK03 datasets. Therefore, the relationships between person pairs are more complicated. We compare the performance of our proposed CAN model against state-of-theart results in Table V. The performance of baseline methods given in [15] is not very competitive, probably because BoW (Bag-of-Word) features the authors used are not robust enough. Note that the experiments are all conducted based on singleshot and single-query. From Table V, we can observe that our CAN model is superior to the state-of-the-art methods by a large margin and successfully improve the mAP from 18.57% to 24.43%, bringing a 5.3% absolute improvement. This shows that our model performs better than other methods in more complex multi-camera person re-identification tasks, benefiting from the inherent attention and comparison mechanism.

F. Visualization of Attention Maps and Discussions
In Fig. 6(a), we visualize some comparative attention maps produced by our network for testing samples from CUHK01 dataset, which are all ranked at top 1 in re-identification results. We can see that the model is able to focus on different parts of the person images at different time-steps. Taking person 1 and person 2 in Fig. 6 as examples, the attention is focused on the lower part of the body at several first timesteps for person 1 in both camera A and camera B while on the whole body for person 2. In other words, our model is able to focus on the same parts of positive pairs, different parts of negative pairs otherwise. Note that, the model does not always attend to the foreground. We can see that some background is attended to, which means the background can also provide information to assist matching persons correctly.
In Fig. 6(b), we also visualize some failure cases of our proposed CAN model in terms of the generated attention maps based on comparison mechanism. As an example, for the person 1 in the figure, our model fails to focus on the same parts of positive person image pairs. This is partially because there are more than one persons in the image captured by camera B and this person is occluded heavily by other persons in the view of camera B. This extremely hard scenario presents challenges to our CAN model as it can not exactly compare person image pairs and decide which local region should be selected. This phenomenon can also be observed from the generated attention maps of person 2 and person 3 in Fig. 6(b).

V. CONCLUSION
In this work, we introduced a novel visual attention model that is formulated as a triplet recurrent neural network which takes several glimpses of triplet images of persons and dynamically generates comparative attention location maps for person re-identification. We conducted extensive experiments on three public available person re-identification datasets to validate our method. Experimental results demonstrated that our model outperforms other state-of-the-art methods in most cases, and verified that our comparative attention model is beneficial for the recognition accuracy in person matching.