{'fraction_non_alphanumeric': 0.03814957766963137, 'fraction_numerical': 0.012474128768809085, 'mean_word_length': 4.6255506607929515, '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': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Knowledge Distillation for Multi-Target Domain Adaptation in Real-Time Person Re-Identification

Despite the recent success of deep learning architectures, person re-identification (ReID) remains a challenging problem in real-word applications. Several unsupervised single-target domain adaptation (STDA) methods have recently been proposed to limit the decline in ReID accuracy caused by the domain shift that typically occurs between source and target video data. Given the multimodal nature of person ReID data (due to variations across camera viewpoints and capture conditions), training a common CNN backbone to address domain shifts across multiple target domains, can provide an efficient solution for real-time ReID applications. Although multi-target domain adaptation (MTDA) has not been widely addressed in the ReID literature, a straightforward approach consists in blending different target datasets, and performing STDA on the mixture to train a common CNN. However, this approach may lead to poor generalization, especially when blending a growing number of distinct target domains to train a smaller CNN. To alleviate this problem, we introduce a new MTDA method based on knowledge distillation (KD-ReID) that is suitable for real-time person ReID applications. Our method adapts a common lightweight student backbone CNN over the target domains by alternatively distilling from multiple specialized teacher CNNs, each one adapted on data from a specific target domain. Extensive experiments conducted on several challenging person ReID datasets indicate that our approach outperforms state-of-art methods for MTDA, including blending methods, particularly when training a compact CNN backbone like OSNet. Results suggest that our flexible MTDA approach can be employed to design cost-effective ReID systems for real-time video surveillance applications.


INTRODUCTION
Person ReID aims to recognize an individual captured over a set of non-overlapping camera viewpoints. It is an important function required in many computer vision applications, ranging from sports analytics to video surveillance [1]. State-of-the-art approaches for person ReID are typically implemented with a deep learning (DL) model, e.g., deep Siamese networks, trained through metric learning to provide global appearance features. CNN backbones are often used to learn an embedding, where similar image pairs (with the same identity) are close to each other, and dissimilar image pairs (with different identities) are distant from each other. Popular supervised losses include cross-entropy, triplet, and contrastive losses based on positives and negatives pairs in a labeled dataset [2]. Despite their success, they remain complex models, and typically require optimizing many parameters using large annotated image datasets. They also suffer from poor generalization in the presence of domain shift, where the distribution of original video data captures from the source domain diverges w.r.t data from the operational target domain. Domain shifts are introduced by variations in capture conditions (i.e., pose and illumination), camera settings and viewpoints from which a person is observed, and lead to considerable changes in the distribution of images in different datasets [3,4].
Given the cost of data annotation, several unsupervised STDA methods have recently been proposed to limit the decline of ReID accuracy caused by domain shifts. These methods seek to adapt CNNs trained with annotated source video data to perform well in a target domain by leveraging unlabeled data captured from that domain. To learn a discriminant domain-invariant feature representation from source and target data, STDA methods typically rely on discrepancy-based or adversarial approaches [3,5,6,7,8,9,10,11,12,13].
Although MTDA based on unlabeled data from multiple targets is important in many real-world applications, it remains largely unexplored [14]. Existing STDA techniques can be extended to MTDA by either adapting multiple models, one for each target domain, or by blending data from the multiple target domains, and then applying STDA on the mixture of target data. For image classification, an adversarial MTDA approach based on blending transfer recently proposed where all targets are viewed as one domain. In [15], target-specific representations were concatenated to deploy a common model [16]. Nevertheless, these approaches are either too complex (require one model per target domain), or generalize poorly on distinct target domains, particularly when adapting a smaller common CNN backbone on a growing number of targets. In [6], MTDA is performed by distilling information from targetspecific teachers to a student model (deployed for testing), significantly reducing system complexity.
In person ReID, distributed video cameras may correspond to different target domains (defined by viewpoints and capture conditions), and the CNN backbone should therefore be adapted to generalize well across multiple target domains. Few MTDA methods are proposed for person ReID. Recently, Tian et al. [17] introduced an MTDA method for ReID. Inspired by intra-domain camera style, they propose a Camera Identityguided Distribution Consistency method based on distribution consistency and discriminative embedding losses. The first loss aligns image style of source and targets through a generative approach, while the second predicts the camera for each identity to decrease distances for each individual across cameras. However, for real-time person ReID, specialized MTDA techniques are required to train smaller cost-effective CNN backbones that can address domain shifts across multiple data distributions. In this paper, we advocate for MTDA methods based on knowledge distillation (KD) [18,14] to provide a better trade-off between CNN accuracy and efficiency.
In this paper, we propose KD-ReID, a cost-effective MTDA method for real-time person ReID applications. A CNN backbone (teacher) is adapted for each target domain, using an STDA method, and the corresponding unlabeled target dataset. Then, the knowledge learned from all the target-specific teachers is alternatively distilled to a common lightweight CNN backbone (student). This paper expands significantly from the KD method in [14], which was proposed for image classification tasks on larger CNNs. Additionally, KD-ReID differs considerably from a KD method for person ReID that was proposed in [18] for multi-source domain adaptation (MSDA). It was applied in a semi-supervised learning scenario and distills knowledge from multiple source models (teachers) to a target model (student) by aligning studentteacher similarity matrices. The accuracy and complexity of KD-ReID are compared extensively against state-of-the-art MTDA methods on several challenging person ReID datasets.

PROPOSED APPROACH
Let x s ∈ X s be the set of samples from the source domain, and y s ∈ Y be their corresponding labels, where X s is the source domain feature space, and Y is the source label space. Given the target domains feature space X t , let x t = {x t 1 , x t 2 , ..., x t T } ∈ X t be the set of samples for T unlabeled target domain datasets. We define the common CNN backbone as Θ, and a set of target-specific CNN backbones, each one adapted to each target domain, as Φ = {Φ 1 , Φ 2 , ..., Φ T }. As illustrated in Figure 1 (a), a straightforward MTDA method for adapting a common CNN backbone Θ consists in blending the data x t i of all of the targets for i = 1, 2, ..., T , and then applying a STDA method on the resulting dataset x t .
We introduce KD-ReID, a MTDA method based on KD that is suitable for real-time person ReID. Our method adapts a common lightweight CNN backbone (student model) Θ to address multiple domain shifts, and perform well over all the target domains. As illustrated in Figure 1 (b), our proposed method distills knowledge learned by multiple specialized CNN backbones Φ i (teacher models), each one adapted on data x t i from a specific target domain, for i = 1, 2, ..., T , using a STDA method. In particular, the KD-ReID method consists of three steps. (1) Pre-training on source data: All the CNN backbones (teachers Φ i and student Θ models) undergo supervised pre-training on the labeled source domain dataset x s . This process should provide discriminant networks for person ReID on the source data. Any appropriate supervised loss functions for metric learning can be applied, including softmax cross-entropy [19], and hard samples mining triplet loss [20]. (2) STDA of teacher CNNs: The teacher models Φ i are adapted to their respective target domains using some STDA method with source x s and target x t i datasets, for i = 1, 2, ..., T . Any STDA method can be applied, including the D-MMD [3], and SPCL [21] methods. (3) KD to student CNN: Knowledge from every teacher model Φ i is distilled to the common student model Θ based on target datasets x t i , for i = 1, 2, ..., T , and on the KD loss function, L KD (described below). The KD-ReID method is summarized in Algorithm 1.
Once the set of teacher models Φ are adapted to respective target domains, KD is proposed to progressively integrate their knowledge into the common student model Θ. Based on the self-similarity matrices of feature vectors from Φ and Θ, our proposed KD loss L KD aligns student-teacher representations. Let f n = Φ i (x n ) be the feature vector output from the fully Algorithm 1 KD-ReID method. Require: labeled source datasets: x s , unlabeled target data: x t = {x t 1 , x t 2 , ..., x t T }, 1) Pre-train teacher models, Φ = {Φ 1 , Φ 2 , ..., Φ T }, and student model, Θ, on the source labeled data x s for i = 1, 2, ...T do for each mini-batches B s ⊂ x s and B t ⊂ x t i do 2) STDA: adapt teacher Φ i on source and target data end for end for for i = 1, 2, ...T do for each mini-batch B t ⊂ x t i do 3) KD: adapt student Θ using target data and L KD end for end for connected layer of Φ i in response to sample x n . Consider a feature matrix F = [f 1 , f 2 , ..., f N ] ∈ R D×N where N is the batch size and D is the dimension of feature vectors. The self-similarity matrix denoted as A ∈ R N ×N is defined as a j,k = f j , f k , where ·, · is the cosine distance between the feature vectors and f j , f k ∈ F . Similarity matrices A s and A t are computed based on student F s and teacher F t feature matrices, respectively. Our KD loss L KD is then computed as: L KD = ||A s − A t || F , where ||·, ·|| F is the Frobenius norm matrix. Optimizing Θ parameters with L KD allows the student model to produce a distance matrix aligned to the teacher model. We only apply this loss on target samples x t . It allows tuning Θ parameters, while Φ parameters are fixed. For each mini-batch B t from a given target domain i, we select only the corresponding teacher model Φ i . The order of targets for KD is selected randomly, and it changes at every epoch.
An important benefit of the KD-ReID approach is its versatility. It is independent of the STDA methods used to adapt each Φ i . The choice of CNN backbones Φ i , and its STDA methods may differ, allowing to select the best configuration to address the specific challenges (i.e., domain shift) faced by each target domain. Moreover, KD-ReID allows distilling knowledge to a lighter common CNN backbone (student model), making it suitable for real-time applications.

EXPERIMENTAL RESULTS
Experimental Methodology: We evaluate MTDA methods across datasets, where each dataset is a target domain. Four benchmark datasets are used for person ReID experiments. CUHK03 [22] consists of 13,164 images of 1,467 identities from 5 camera pairs. Market1501 [23] is comprised of a high number of images per identities (32,217 images of 1,501 identities) captured with 6 cameras. Compared to CUHK03, the bounding box annotations in Market1501 are lower quality, and persons captured in each box may be represented partially, which makes for a challenging dataset. DukeMTMC [24] is designed such that each one of the 8 cameras contains unique identities. This dataset contains 36,441 images of 1,812 identities, which is similar in size to Market1501 in terms of the number of images and identities. Finally, MSMT17 [25] includes video from 15 indoor and outdoor cameras, and consists of 126,441 images of 4,101 identities. Since videos are captured in indoor/outdoor conditions, on different days, weather conditions, and times of the day, MSMT17 represents a more challenging and realistic dataset compared to the others. MSMT17 is always used as the source dataset to pre-train the CNNs. Given the diversity of capture conditions, there is a significant domain shift between images from these datasets [3].
ResNet50 [26] is used to implement the target-specific CNN backbones (teachers), while OSNet_x0_25 [27] implements the common CNN backbone. A fully connected layer with 2048 neurons is added to each backbone to output feature vectors. The original hyperparameter setup for D-MMD [3] and SPCL [21] are used for our experiments. For KD-ReID, the Stochastic Gradient Descent (SGD) optimizer is used with a learning rate of 0.01. It is divided by 10 after every five epochs. A batch size of 64 is used, with 32 samples from the source and target data. Batches are constructed using groups of four images with the same identity corresponding to tracklets. Training is conducted until model accuracy improves by less than 0.5% average mAP over five consecutive epochs. Results and Discussion: Table 1 compares the performance of KD-ReID against baseline methods in terms of the mean Average Precision (mAP), rank-1 accuracy, and the number of parameters and FLOPs. As expected, the lower-bound accuracy on target datasets is low due to the domain shift between the source and target data. Blending all the target data, and then applying an STDA method improves accuracy significantly over the lower bound. The proposed KD-ReID outperforms the blending methods on all datasets for both D-MMD and SPCL methods for STDA. Training a single model per target is a straightforward MTDA approach that achieves a higher level of accuracy, but incurs a high computational cost. As shown in Table 1, the SPCL technique for STDA produces a less accurate teacher model for the CUHK03 dataset than D-MMD. This observation motivates us to select the best STDA technique for each teacher model. The highest average accuracy is obtained when mixing STDA methods to adapt teachers for KD-ReID, highlighting its versatility. Table 1 also shows the complexity of approaches in terms of the memory needed to store model weights (# Parameters), and inference time for a sample (FLOPs). Note that our KD-ReID has significantly lower complexity than the teacher models from which it learns. Furthermore, although accuracy may decline as T grows, the memory requirement for blending and KD-ReID is independent of the number of target domains T . Table 2 shows the performance of KD-ReID versus three related SOTA methods. First, Wu et. al. [18] proposed an MSDA method based on KD for a semi-supervised scenario. The method should be robust to domain shift across new do- mains since it benefits from some labeled target domain data, and the labeled data from multiple different source domains to adapt the common CNN backbone. In practice, this scenario is restrictive for ReID, given the need to collect datasets and annotate samples. Yet, our KD-ReID outperforms this method significantly , even with a lighter CNN backbone. Second, Tian et. al. [17] recently proposed the only MTDA method in literature for ReID. Our method significantly outperforms this approach with an improvement of 18.3% in mAP, and 6.2% in rank-1 on average, even using OSNet_x0_25, a much smaller CNN architecture (by a ratio close to 60). In contrast, our KD-ReID method divides the problem into simpler STDA problems, that may be solved using any combination of STDA methods, rather than resolving for the complex MTDA problem. Compression achieved with KD provides a lightweight student model to reproduce the performance of the highly optimized teachers. Recently, Li et. al. [28] proposed a SOTA unsupervised person ReID method that relies on clustering. While this setting is more challenging, our method offers significantly better accuracy and is computationally efficient. Figure 2 compares the average performance of the common CNNs obtained using KD-ReID and blending. The experiments are conducted using three variations of the OSNet CNN: OSNet_x1_0, OSNet_x0_5, and OSNet_x0_25, having about 4.0M, 1.0M, and 0.4M parameters, respectively.   shows that the gap in accuracy between methods widens as the model complexity is reduced. KD-ReID always outperforms blending, and remains more effective at adapting lightweight CNNs, thus more suitable for real-time applications.

CONCLUSION
In this paper, KD-ReID is introduced as a versatile MTDA method for real-time person ReID. To adapt each teachers model, KD-ReID allows selecting the STDA method and CNN individually, and then knowledge of all teacher models is distilled to a common lightweight CNN (student). Our experiments conducted on challenging person ReID datasets indicate that student models adapted through KD-ReID outperform blending methods, and generalize well on all targets at the same time, even when adapting a small common CNN backbone on a growing number of targets. Such scalability paves the way for cost-effective systems for real-time applications.
Acknowledgements: This work was supported by Nuvoola AI Inc., and the Natural Sciences and Engineering Research Council of Canada. Fig. 2. Impact of student model complexity on the average mAP over targets (Market1501, DukeMTMC, and CUHK03), and using MSMT17 as source. The common CNN is OSNet, while teachers are ResNet50s, and D-MMD is used for STDA.