A multi-scale multi-feature fusion pedestrian re-identification method and device
The pedestrian re-identification method through multi-scale and multi-feature fusion uses a combination of multi-branch structures and loss functions to solve the problems of low accuracy and neglect of local feature connections in the existing technology for pedestrian re-identification under complex lighting conditions, achieving a higher recognition accuracy and efficiency.
Patent Information
- Application Number
- CN202110776004.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-07-08
- Publication Date
- 2024-08-23
- Estimated Expiration
- 2041-07-08
AI Technical Summary
Existing pedestrian re-identification methods have low recognition accuracy under complex lighting conditions. In particular, local feature extraction methods ignore the intrinsic connections between different areas, resulting in low recognition accuracy.
Using a multi-scale multi-feature fusion method, through the pre-trained pedestrian re-identification model, the multi-branch structure of the feature extraction layer is used to obtain feature maps of different scales, and combined with the global maximum pooling layer and the global average pooling layer, the features are The graph is converted into a one-dimensional vector, and trained by combining the difficult sample triplet loss and the central loss function to make full use of the connection between local features.
It improves the accuracy and efficiency of pedestrian re-identification, can more fully express pedestrian characteristics, avoid conflicts between different loss functions, and improve training efficiency.
Smart Images

Figure CN113449671B
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of pedestrian recognition, and in particular to a multi-scale and multi-feature fusion pedestrian re-recognition method and device. Background Art
[0002] Person re-identification refers to the process of accurately matching a video image of a pedestrian to be retrieved from a database containing a large amount of pedestrian data by using a series of features in the image or video, such as body shape, clothing, posture, etc., given a pedestrian image or a video sequence.
[0003] Pedestrian re-identification methods are mainly divided into traditional methods and deep learning-based methods. In traditional processing methods, different feature extraction methods need to be designed manually and appropriate distance metrics need to be selected for pedestrian re-identification. However, traditional methods are more focused on capturing lower-level visual information, and are prone to errors when there are serious changes in the environment and lighting of pedestrian video images.
[0004] The deep learning-based method integrates a series of operations on video images into a complete framework. As an end-to-end method, the deep learning-based person re-identification algorithm uses a multi-layer nonlinear structure to mine higher-level visual information, and can still maintain good re-identification results under complex lighting conditions. Therefore, it has become the mainstream method in the current person re-identification research. In the process of pedestrian re-identification, global features and local features have different meanings for achieving more accurate pedestrian matching. Global features can obtain more macroscopic feature information, while local features pay more attention to feature information on details. However, the current common method of using local features for pedestrian re-identification is prone to artificially separate the potential connections between different regions, resulting in low recognition accuracy. Common pedestrian re-identification methods based on local features, such as Part-based Convolutional Baseline (PCB). Although the Multiple Granularity Network (MGN) fully utilizes the advantages of PCB, it does not take into account the intrinsic relationship between different local regions. For example Figure 1 As shown in the figure, there is obviously similar feature information between the local areas in a pedestrian image, especially in the upper half, and there is a strong correlation. They should be used as a whole for pedestrian re-identification, but the PCB re-identification method regards them as two unrelated parts and processes them separately, which affects the pedestrian re-identification performance. At the same time, the PCB method focuses on obtaining local feature information using feature maps of a single scale, without considering that splicing feature maps of different scales can obtain richer feature information. Summary of the invention
[0005] The embodiment of the present invention provides a multi-scale multi-feature fusion pedestrian re-identification method and device. The technical solution is as follows:
[0006] On the one hand, a multi-scale multi-feature fusion pedestrian re-identification method is provided, and the method is applied to an electronic device, and the method includes:
[0007] Input the image to be identified into a pre-trained pedestrian re-identification model, wherein the pedestrian re-identification model includes a feature extraction layer, an embedding layer, a global maximum pooling layer GMP, a global average pooling layer GAP, a convolution layer, a batch normalization layer, and an activation function; wherein the feature extraction layer is provided with three branches, and the embedding layer pre-stores the number of segmentations set for each branch;
[0008] Through the three branches of the feature extraction layer, three feature maps of different scales are obtained;
[0009] According to the number of segmentations preset by the embedding layer, the three feature maps are segmented respectively to obtain three groups of segmented local feature maps, and each group of local feature maps is spliced to obtain multiple feature tensors;
[0010] The multiple feature tensors are converted into one-dimensional vectors through the global maximum pooling layer GMP, the global average pooling layer GAP, the convolution layer, the batch normalization layer and the linear rectification ReLU activation function;
[0011] The obtained one-dimensional vectors are spliced to obtain one-dimensional vectors corresponding to multiple images to be detected, and the similarities between the one-dimensional vector of the image to be identified and the one-dimensional vectors of the multiple images to be detected are calculated. According to the obtained multiple similarities, the image to be detected corresponding to the image to be identified is determined.
[0012] Optionally, the structure of the feature extraction layer includes:
[0013] The first three layers of the feature extraction layer completely inherit the first three layers of the Resnet-50 network. Among the three branches, the structure of the first branch is the same as the fourth and fifth layers of the Resnet-50 network, the structure of the second branch is the same as the fourth and improved fifth layers of the Resnet-50 network, and the structure of the third branch is the same as the improved fourth and improved fifth layers of the Resnet-50 network; wherein the improved fifth layer structure is the fifth layer structure with the downsampling link deleted, and the improved fourth layer structure is the fourth layer structure with the downsampling link deleted.
[0014] Optionally, the number of splits set for each branch pre-stored in the embedding layer includes:
[0015] The number of divisions of the first branch is 1, the number of divisions of the second branch is 2, and the number of divisions of the third branch is 3.
[0016] Optionally, each group of local feature maps is concatenated to obtain multiple feature tensors, including:
[0017] For any group of local feature maps, the number X of the group of local feature maps is determined, and the local feature maps of the group are spliced through X rounds, wherein the i-th round of splicing includes i times of splicing, and the number of local feature maps included in the i-th splicing is respectively X, X-1, X-2, ..., X-i+1, and a feature tensor is obtained each time the splicing is performed. Then, the local feature maps of the group are spliced to obtain A feature tensor.
[0018] Optionally, the training method of the person re-identification model is as follows:
[0019] Obtain training sample data set;
[0020] The cross entropy loss Softmax Loss function is used to preliminarily train the initial pedestrian re-identification model to obtain a pre-trained pedestrian re-identification model;
[0021] The training sample data set is input into the pre-trained pedestrian re-identification model, and the hard sample triplet loss TriHard Loss function, the center loss Center Loss function and the Softmax Loss function are combined to obtain a comprehensive loss function. The pre-trained pedestrian re-identification model is trained according to the comprehensive loss function until the comprehensive loss function converges, and the training of the pedestrian re-identification model is completed to obtain a trained pedestrian re-identification model.
[0022] Optionally, the comprehensive loss function is defined as:
[0023] L=L softmax +γL Hardtrip +βL c
[0024] Among them, L softmax Represents the cross entropy loss function Softmax Loss, L softmax Defined as:
[0025]
[0026] In the formula, p(y i |x i ) represents the label y i The input x i The probability of being correctly identified;
[0027] Wherein, γ represents the first preset parameter, L Hardtrip Represents the TriHard Loss function of the difficult sample triplet, L Hardtrip Defined as:
[0028]
[0029] Where α is the set threshold, d represents the Euclidean distance between two images, (z) + represents max(z, 0), P, K refer to the P pedestrians constituting the triplet and the K images corresponding to each pedestrian, a, p represent positive sample pairs, and a, n represent negative sample pairs;
[0030] Where, β represents the second preset parameter, L c Represents the center loss function Center Loss, L c Defined as:
[0031]
[0032] Optionally, the initial person re-identification model includes a fully connected layer and a Softmax Loss function;
[0033] The step of inputting the training sample data set into the initial person re-identification model, combining the hard sample triplet loss TriHard Loss function, the center loss Center Loss function and the Softmax Loss function to obtain a comprehensive loss function, and training the pre-trained person re-identification model according to the comprehensive loss function includes:
[0034] Inputting the training sample data set into the pre-trained pedestrian re-identification model, and training the pre-trained pedestrian re-identification model according to the output data of the ReLU activation function, the TriHard Loss function, and the Center Loss function in the pre-trained pedestrian re-identification model;
[0035] The output data of the ReLU activation function is input into a fully connected layer, and the pre-trained person re-identification model is trained according to the output data of the fully connected layer and a Softmax Loss function.
[0036] Optionally, a stochastic gradient descent (SGD) optimizer is used to update parameters during the person re-identification model training process.
[0037] On the one hand, a multi-scale multi-feature fusion pedestrian re-identification device is provided, and the device is applied to an electronic device, and the device includes:
[0038] An input unit, used for inputting the image to be identified into a pre-trained pedestrian re-identification model, wherein the pedestrian re-identification model includes a feature extraction layer, an embedding layer, a global maximum pooling layer GMP, a global average pooling layer GAP, a convolution layer, a batch normalization layer and an activation function; wherein the feature extraction layer is provided with three branches, and the embedding layer pre-stores the number of segmentations set for each branch;
[0039] A feature extraction unit, used for obtaining feature maps of three different scales through three branches of the feature extraction layer;
[0040] A splicing unit, used to segment the three feature maps according to the number of segmentations preset by the embedding layer, respectively, to obtain three groups of segmented local feature maps, and to splice each group of local feature maps respectively to obtain multiple feature tensors;
[0041] A conversion unit, used to convert the multiple feature tensors into one-dimensional vectors through the global maximum pooling layer GMP, the global average pooling layer GAP, the convolution layer, the batch normalization layer and the linear rectification ReLU activation function;
[0042] The result acquisition unit is used to splice the obtained one-dimensional vectors to obtain the one-dimensional vectors corresponding to multiple images to be detected, calculate the similarity between the one-dimensional vector of the image to be identified and the one-dimensional vectors of the multiple images to be detected, and determine the image to be detected corresponding to the image to be identified based on the multiple similarities obtained.
[0043] Optionally, the structure of the feature extraction layer includes:
[0044] The first three layers of the feature extraction layer completely inherit the first three layers of the Resnet-50 network. Among the three branches, the structure of the first branch is the same as the fourth and fifth layers of the Resnet-50 network, the structure of the second branch is the same as the fourth and improved fifth layers of the Resnet-50 network, and the structure of the third branch is the same as the improved fourth and improved fifth layers of the Resnet-50 network; wherein the improved fifth layer structure is the fifth layer structure with the downsampling link deleted, and the improved fourth layer structure is the fourth layer structure with the downsampling link deleted.
[0045] Optionally, the number of splits set for each branch pre-stored in the embedding layer includes:
[0046] The number of divisions of the first branch is 1, the number of divisions of the second branch is 2, and the number of divisions of the third branch is 3.
[0047] Optionally, the splicing unit is used to:
[0048] For any group of local feature maps, the number X of the group of local feature maps is determined, and the local feature maps of the group are spliced through X rounds, wherein the i-th round of splicing includes i times of splicing, and the number of local feature maps included in the i-th splicing is respectively X, X-1, X-2, ..., X-i+1, and a feature tensor is obtained each time the splicing is performed. Then, the local feature maps of the group are spliced to obtain A feature tensor.
[0049] Optionally, the device further comprises a training unit, wherein the training unit is configured to:
[0050] Obtain training sample data set;
[0051] The cross entropy loss Softmax Loss function is used to preliminarily train the initial pedestrian re-identification model to obtain a pre-trained pedestrian re-identification model;
[0052] The training sample data set is input into the pre-trained pedestrian re-identification model, and the hard sample triplet loss TriHard Loss function, the center loss Center Loss function and the Softmax Loss function are combined to obtain a comprehensive loss function. The pre-trained pedestrian re-identification model is trained according to the comprehensive loss function until the comprehensive loss function converges, and the training of the pedestrian re-identification model is completed to obtain a trained pedestrian re-identification model.
[0053] Optionally, the comprehensive loss function is defined as:
[0054] L=L softmax +γL Hardtrip +βL c
[0055] Among them, L softmax Represents the cross entropy loss function Softmax Loss, L softmax Defined as:
[0056]
[0057] In the formula, p(y i |x i ) represents the label y i The input x i The probability of being correctly identified;
[0058] Wherein, γ represents the first preset parameter, L Hardtrip Represents the TriHard Loss function of the difficult sample triplet, L Hardtrip Defined as:
[0059]
[0060] Where α is the set threshold, d represents the Euclidean distance between two images, (z) + represents max(z, 0), P, K refer to the P pedestrians constituting the triplet and the K images corresponding to each pedestrian, a, p represent positive sample pairs, and a, n represent negative sample pairs;
[0061] Where β represents the second preset parameter, L c Represents the center loss function Center Loss, L c Defined as:
[0062]
[0063] Optionally, the training unit is used to:
[0064] Inputting the training sample data set into the pre-trained person re-identification model, and training the pre-trained person re-identification model according to the output data of the ReLU activation function, the TriHard Loss function, and the Center Loss function in the pre-trained person re-identification model; wherein the initial person re-identification model includes a fully connected layer and a Softmax Loss function;
[0065] The output data of the ReLU activation function is input into a fully connected layer, and the pre-trained person re-identification model is trained according to the output data of the fully connected layer and a Softmax Loss function.
[0066] Optionally, a stochastic gradient descent (SGD) optimizer is used to update parameters during the person re-identification model training process.
[0067] On the one hand, an electronic device is provided, comprising a processor and a memory, wherein the memory stores at least one instruction, and the at least one instruction is loaded and executed by the processor to implement the above-mentioned multi-scale and multi-feature fusion pedestrian re-identification method.
[0068] On the one hand, a computer-readable storage medium is provided, wherein at least one instruction is stored in the storage medium, and the at least one instruction is loaded and executed by a processor to implement the above-mentioned multi-scale and multi-feature fusion pedestrian re-identification method.
[0069] The beneficial effects brought about by the technical solution provided by the embodiment of the present invention include at least:
[0070] In the above scheme, in the embodiment of the present invention, a multi-branch structure is used to obtain the pedestrian feature map. Compared with other algorithms that only use a single branch, the multi-branch structure can obtain richer pedestrian feature information. By combining the feature information in different branches, the pedestrian features can be more fully expressed. Moreover, the present invention combines the multi-branch structure with local feature learning to obtain the feature representation of pedestrians at different levels, while fully utilizing the connection between adjacent local features, solving the problem that other pedestrian re-identification algorithms ignore the intrinsic connection between local features. In addition, the present invention adopts a new training strategy. Compared with the training strategy of directly combining different loss functions, the training strategy proposed by the present invention, while making full use of the triplet loss, also avoids the conflict between different loss functions to a certain extent, thereby improving the training efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0071] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0072] Figure 1 It is a schematic diagram of a recognition process of the prior art provided by an embodiment of the present invention;
[0073] Figure 2 It is an implementation environment diagram provided by an embodiment of the present invention;
[0074] Figure 3 This is a flow chart of a multi-scale and multi-feature fusion pedestrian re-identification method provided by an embodiment of the present invention;
[0075] Figure 4 This is a flow chart of a multi-scale and multi-feature fusion pedestrian re-identification method provided by an embodiment of the present invention;
[0076] Figure 5 is a structural schematic diagram of a feature extraction layer provided by an embodiment of the present invention;
[0077] Figure 6 is a structural schematic diagram of a training process provided by an embodiment of the present invention;
[0078] Figure 7 is a schematic diagram of a local feature map splicing method provided by an embodiment of the present invention;
[0079] Figure 8 It is a block diagram of a multi-scale multi-feature fusion pedestrian re-identification device provided by an embodiment of the present invention;
[0080] Fig. 9It is a structural schematic diagram of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0081] In order to make the technical problems, technical solutions and advantages to be solved by the present invention more clear, a detailed description will be given below with reference to the accompanying drawings and specific embodiments.
[0082] The embodiment of the present invention provides a multi-scale multi-feature fusion pedestrian re-identification method, such as Figure 2 As shown, the implementation environment may include at least one terminal 201 and a server 202 for providing services to the multiple terminals 201. At least one terminal 201 is connected to the server 202 via a wireless or wired network, and the multiple terminals 201 may be computer devices or intelligent terminals that can access the server 202. For the process of pedestrian re-identification, the terminal 201 may obtain an image to be identified, and the server 202 stores a pre-trained pedestrian re-identification model. After the terminal 201 obtains the image to be identified, the terminal 201 sends the image to be identified to the server 202, and then the server 202 inputs the image to be identified into the pedestrian re-identification model, so that the pedestrian re-identification model identifies the image to be identified. Alternatively, the identification process may also be completed by the terminal 201, and the server 202 obtains a training sample data set, and trains the pedestrian re-identification model of the terminal 201 through the training sample data set, which is not limited in the present invention.
[0083] The embodiment of the present invention provides a multi-scale multi-feature fusion pedestrian re-identification method, which can be implemented by an electronic device, and the electronic device can be a terminal or a server. Figure 3 The flowchart of the multi-scale multi-feature fusion pedestrian re-identification method shown in the figure can include the following steps:
[0084] Step 301: Input the image to be recognized into a pre-trained person re-recognition model.
[0085] The pedestrian re-identification model includes a feature extraction layer, an embedding layer, a global maximum pooling layer GMP, a global average pooling layer GAP, a convolution layer, a batch normalization layer and an activation function; wherein the feature extraction layer is set with three branches, and the embedding layer pre-stores the number of segmentations set for each branch;
[0086] Step 302: Obtain feature maps of three different scales through three branches of the feature extraction layer;
[0087] Step 303: segment the three feature maps according to the number of segmentations preset in the embedding layer to obtain three groups of segmented local feature maps, and concatenate each group of local feature maps to obtain multiple feature tensors;
[0088] Step 304: convert multiple feature tensors into one-dimensional vectors through a global maximum pooling layer GMP, a global average pooling layer GAP, a convolutional layer, a batch normalization layer, and a linear rectification ReLU activation function;
[0089] Step 305: concatenate the obtained one-dimensional vectors to obtain one-dimensional vectors corresponding to multiple images to be detected, calculate the similarities between the one-dimensional vector of the image to be identified and the one-dimensional vectors of the multiple images to be detected, and determine the image to be detected corresponding to the image to be identified based on the obtained multiple similarities.
[0090] Optionally, the structure of the feature extraction layer includes:
[0091] The first three layers of the feature extraction layer completely inherit the structure of the first three layers of the Resnet-50 network. Among the three branches, the structure of the first branch is the same as the fourth and fifth layers of the Resnet-50 network, the structure of the second branch is the same as the fourth and improved fifth layers of the Resnet-50 network, and the structure of the third branch is the same as the improved fourth and improved fifth layers of the Resnet-50 network; among them, the improved fifth layer structure is the fifth layer structure with the downsampling link deleted, and the improved fourth layer structure is the fourth layer structure with the downsampling link deleted.
[0092] Optionally, the number of splits set for each branch pre-stored in the embedding layer includes:
[0093] The number of splits in the first branch is 1, the number of splits in the second branch is 2, and the number of splits in the third branch is 3.
[0094] Optionally, each group of local feature maps is concatenated separately to obtain multiple feature tensors, including:
[0095] For any group of local feature maps, the number of local feature maps in the group is determined to be X, and the local feature maps of the group are spliced through X rounds, where the i-th round of splicing includes i times of splicing, and the number of local feature maps included in the i-th splicing is X, X-1, X-2, ..., X-i+1, respectively. Each splicing obtains a feature tensor, and the local feature maps of the group are spliced to obtain A feature tensor.
[0096] Optionally, the training method of the person re-identification model is as follows:
[0097] Obtain training sample data set;
[0098] The cross entropy loss Softmax Loss function is used to preliminarily train the initial pedestrian re-identification model to obtain a pre-trained pedestrian re-identification model;
[0099] The training sample data set is input into the pre-trained pedestrian re-identification model, and the difficult sample triplet loss TriHardLoss function, the center loss Center Loss function and the Softmax Loss function are combined to obtain a comprehensive loss function. The pre-trained pedestrian re-identification model is trained according to the comprehensive loss function until the comprehensive loss function converges. The training of the pedestrian re-identification model is completed to obtain a trained pedestrian re-identification model.
[0100] Optionally, the comprehensive loss function is defined as:
[0101] L=L softmax +γL Hardtrip +βL c
[0102] Among them, L softmax Represents the cross entropy loss function Softmax Loss, L softmax Defined as:
[0103]
[0104] In the formula, p(y i |x i ) represents the label y i The input x i The probability of being correctly identified;
[0105] Wherein, γ represents the first preset parameter, L Hardtrip Represents the TriHard Loss function of the difficult sample triplet, L Hardtrip Defined as:
[0106]
[0107] Where α is the set threshold, d represents the Euclidean distance between two images, (z) + represents max(z, 0), P, K refer to the P pedestrians constituting the triplet and the K images corresponding to each pedestrian, a, p represent positive sample pairs, and a, n represent negative sample pairs;
[0108] Where β represents the second preset parameter, L c Represents the center loss function Center Loss, L c Defined as:
[0109]
[0110] Optionally, the training sample data set is input into the initial person re-identification model, the hard sample triplet loss TriHard Loss function, the center loss Center Loss function and the Softmax Loss function are combined to obtain a comprehensive loss function, and the pre-trained person re-identification model is trained according to the comprehensive loss function, including:
[0111] Input the training sample data set into the pre-trained pedestrian re-identification model, and train the pre-trained pedestrian re-identification model according to the output data of the ReLU activation function, the TriHard Loss function, and the Center Loss function in the pre-trained pedestrian re-identification model; wherein the pre-trained pedestrian re-identification model includes a fully connected layer and a Softmax Loss function;
[0112] The output data of the ReLU activation function is input into the fully connected layer, and the pre-trained pedestrian re-identification model is trained according to the output data of the fully connected layer and the Softmax Loss function.
[0113] Optionally, the stochastic gradient descent (SGD) optimizer is used to update parameters during the person re-identification model training process.
[0114] The embodiment of the present invention provides a multi-scale multi-feature fusion pedestrian re-identification method, which can be implemented by an electronic device, and the electronic device can be a terminal or a server. Figure 4 The flowchart of the multi-scale multi-feature fusion pedestrian re-identification method shown in the figure can include the following steps:
[0115] Step 401: Obtain an initial person re-identification model.
[0116] The initial person re-identification model includes a feature extraction layer, an embedding layer, a global maximum pooling layer GMP, a global average pooling layer GAP, a convolution layer, a batch normalization layer, an activation function, and a linear fully connected layer. The feature extraction layer is set with three branches, and the embedding layer pre-stores the number of segmentations set for each branch.
[0117] Optionally, the structure of the feature extraction layer may include:
[0118] The first three layers of the feature extraction layer completely inherit the first three layers of the Resnet-50 network. Among the three branches, the structure of the first branch is the same as the fourth and fifth layers of the Resnet-50 network, the structure of the second branch is the same as the fourth and improved fifth layers of the Resnet-50 network, and the structure of the third branch is the same as the improved fourth and improved fifth layers of the Resnet-50 network; among them, the improved fifth layer structure is the fifth layer structure with the downsampling link deleted, and the improved fourth layer structure is the fourth layer structure with the downsampling link deleted. Figure 5 As shown in the figure, Res_convx' and Res_convx represent the xth convolution layer with and without the downsampling link respectively. The downsampling link is used to reduce the resolution of the feature image. By adjusting the downsampling links of the three branches, the three branches extract features of the feature image at different scales, so that three feature images of different scales can be obtained.
[0119] Step 402: Obtain a training sample data set.
[0120] When a complete data set passes through the neural network once and returns once, this process is called an epoch, that is, all training samples of a data set undergo one forward propagation and one backward propagation in the neural network. A person has various postures and occlusions under the camera. In order to realize the appearance of pedestrians under different cameras as much as possible, when obtaining sample images, the sample images are preprocessed, including random horizontal flipping and random cropping.
[0121] Step 403: Use the cross entropy loss Softmax Loss function to perform preliminary training on the initial person re-identification model to obtain a pre-trained person re-identification model.
[0122] In a feasible implementation, in the first 10 epochs, only the cross entropy loss Softmax Loss is used to perform preliminary training on the initial person re-identification model. The cross entropy loss is defined as:
[0123]
[0124] In the formula, p(y i |x i ) represents the label y i The input x i The probability of being correctly identified.
[0125] Step 404: input the training sample data set into the pre-trained pedestrian re-identification model, combine the hard sample triplet loss TriHard Loss function, the center loss Center Loss function and the Softmax Loss function to obtain a comprehensive loss function, and train the pre-trained pedestrian re-identification model according to the comprehensive loss function.
[0126] In a feasible implementation, in the subsequent training process, the hard sample triplet loss TriHardLoss, the center loss Center Loss and the cross entropy loss are combined for training. The hard sample triplet loss is defined as:
[0127]
[0128] Where α is the set threshold, d represents the Euclidean distance between two images, (z) + represents max(z, 0), P, K refer to the P pedestrians constituting the triplet and the K images corresponding to each pedestrian, a, p represent positive sample pairs, and a, n represent negative sample pairs.
[0129] Center Loss is defined as:
[0130]
[0131] Since the direct combination of the difficult sample triplet loss and the cross entropy loss will cause some conflicts, the difficult sample triplet loss is used as an auxiliary loss in model training. At the same time, an auxiliary coefficient is set for the difficult sample triplet loss. The specific loss function is designed as:
[0132] L=L softmax +γL Hardtrip +βL c
[0133] Among them, L softmax represents the cross entropy loss function Softmax Loss, γ represents the first preset parameter, L Hardtrip represents the TriHard Loss function for the difficult sample triplet, β represents the second preset parameter, and L c represents the center loss function CenterLoss, wherein the first preset parameter and the second preset parameter are set by the user according to specific needs.
[0134] When training according to the comprehensive loss function, since Softmax Loss cannot directly train the output data of the activation function, the fully connected layer combined with the sample ID Loss is required as a classifier, and Softmax Loss is trained on the output data of the fully connected layer. Specifically, Figure 6 As shown, the training sample data set is input into the pre-trained pedestrian re-identification model, and the pre-trained pedestrian re-identification model is trained according to the output data of the ReLU activation function, the TriHard Loss function, and the Center Loss function in the pre-trained pedestrian re-identification model; at the same time, the output data of the ReLU activation function is input into the fully connected layer, and the pre-trained pedestrian re-identification model is trained according to the output data of the fully connected layer and the Softmax Loss function.
[0135] Optionally, in the above steps, a stochastic gradient descent SGD optimizer may be used to update parameters during the person re-identification model training process.
[0136] Step 405: Use the training sample data set to perform multiple trainings until the comprehensive loss function converges, thereby completing the training of the person re-identification model and obtaining a trained person re-identification model.
[0137] Step 406: normalize the image to be recognized.
[0138] In a feasible implementation manner, in order to make the specifications of the image to be recognized in the input model uniform, the image to be recognized is normalized.
[0139] Step 407: input the normalized image to be identified into a pre-trained person re-identification model.
[0140] Step 408: Obtain feature maps of three different scales through the three branches of the feature extraction layer.
[0141] In a feasible implementation, since the downsampling steps of the three branches are different, the three obtained feature maps include different feature information.
[0142] Step 409: segment the three feature maps according to the number of segmentations preset in the embedding layer to obtain three groups of segmented local feature maps, and concatenate each group of local feature maps to obtain multiple feature tensors.
[0143] In a feasible implementation, the applicant found that the prior art usually divides the feature image into 6 blocks, and 21 feature tensors can be obtained when they are subsequently spliced. The problem here is that the feature image of the pedestrian is divided into 6 blocks, and the division is relatively fine. In the case of non-aligned pedestrians, it is very likely that there is no pedestrian feature in one of the blocks but only a background image. This local feature map is noise. In other words, the prior art will introduce noise when dividing the feature image into 6 blocks, which will affect the accuracy of the subsequent recognition results. Moreover, the number of spliced 21 feature tensors is relatively large, which will not only fail to improve the accuracy, but also increase the amount of calculation and reduce the efficiency of recognition.
[0144] Therefore, in order to solve the above problem, in the embodiment of the present invention, the number of segmentations pre-stored in the embedding layer for each branch is: the number of segmentations of the first branch is 1, the number of segmentations of the second branch is 2, and the number of segmentations of the third branch is 3. In this way, three groups of local feature maps can be obtained, the number of local feature maps of the first group is 1, the number of local feature maps of the second group is 2, and the number of local feature maps of the third group is 3. In this way, even if the image to be recognized contains part of the background image, it can be ensured that the local feature maps after segmentation contain pedestrian features without introducing noise.
[0145] Afterwards, each group of local feature maps is spliced separately to obtain multiple feature tensors. Specifically, for any group of local feature maps, the number of group local feature maps X is determined, and the local feature maps of the group are spliced through X rounds, wherein the i-th round of splicing includes i times of splicing, and the number of local feature maps included in the i-th splicing is X, X-1, X-2, ..., X-i+1, respectively. Each splicing obtains a feature tensor, and the group of local feature maps is spliced to obtain feature tensors, such as Figure 7 Shown is a concatenation method for a set of local feature maps.
[0146] For the three groups of local feature maps included in the embodiment of the present invention, the specific stitching steps are as follows:
[0147] 1. For the first group of local feature maps, since the group only includes one local feature map, only one round of splicing is required, that is, no splicing is required, and one feature tensor is obtained.
[0148] 2. For the second group of local feature maps, this group includes 2 local feature maps, so after 2 rounds of splicing:
[0149] (1) The first round of splicing includes one splicing, and the number of local feature maps included in this splicing is 2, that is, two local feature maps are spliced together, and this round of splicing obtains one feature tensor;
[0150] (2) The second round of splicing includes two splicing steps:
[0151] ① The number of local feature maps included in the first splicing is 2, that is, two local feature maps are spliced together;
[0152] ② The number of local feature maps included in the second splicing is 1, and no splicing is required. This round of splicing obtains 2 feature tensors.
[0153] That is to say, the second set of local feature maps obtains 1+2=3 feature tensors.
[0154] 3. For the third group of local feature maps, this group includes 3 local feature maps, so after 3 rounds of splicing:
[0155] (1) The first round of splicing includes one splicing, and the number of local feature maps included in this splicing is 3, that is, three local feature maps are spliced together, and this round of splicing obtains one feature tensor;
[0156] (2) The second round of splicing includes two splicing steps:
[0157] ① The number of local feature maps included in the first splicing is 3, that is, 3 local feature maps are spliced together;
[0158] ② The number of local feature maps included in the second splicing is 2, and the two local feature maps are spliced together; this round of splicing obtains 2 feature tensors.
[0159] (3) The third round of splicing includes three splicing steps:
[0160] ① The number of local feature maps included in the first splicing is 3, that is, 3 local feature maps are spliced together;
[0161] ② The number of local feature maps included in the second splicing is 2, and the two local feature maps are spliced together;
[0162] ③ The number of local feature maps included in the third splicing is 1, and no splicing is required. This round of splicing obtains 3 feature tensors.
[0163] That is to say, the third set of local feature maps obtains 1+2+3=6 feature tensors.
[0164] In summary, the three groups of local feature maps in the embodiment of the present invention can obtain 1+3+6=10 feature tensors, which greatly reduces the amount of computation compared to the 21 feature tensors in the prior art. Therefore, the present invention can improve the recognition efficiency without affecting the recognition accuracy.
[0165] Step 410: Convert multiple feature tensors into one-dimensional vectors through a global maximum pooling layer GMP, a global average pooling layer GAP, a convolutional layer, a batch normalization layer, and a linear rectification ReLU activation function.
[0166] Step 411, concatenate the obtained one-dimensional vectors to obtain one-dimensional vectors corresponding to multiple images to be detected, calculate the similarities between the one-dimensional vector of the image to be identified and the one-dimensional vectors of the multiple images to be detected, and determine the image to be detected corresponding to the image to be identified based on the multiple similarities obtained.
[0167] In a feasible implementation manner, the one-dimensional vectors of the multiple images to be detected can be obtained by processing in the above steps 406-410, and the specific operation process is not described in detail here.
[0168] The similarities between the one-dimensional vector of the image to be identified and the one-dimensional vectors of multiple images to be detected are calculated respectively, and then the similarities are arranged in descending order from large to small, and the images to be detected corresponding to the preset number of similarities are obtained. The preset number of images to be detected are the recognition results.
[0169] In an embodiment of the present invention, a multi-branch structure is used to obtain a pedestrian feature map. Compared with other algorithms that only use a single branch, the multi-branch structure can obtain richer pedestrian feature information. By combining the feature information in different branches, the pedestrian features can be more fully expressed. Moreover, the present invention combines the multi-branch structure with local feature learning to obtain feature representations of pedestrians at different levels, while fully utilizing the connections between adjacent local features, solving the problem that other pedestrian re-identification algorithms ignore the intrinsic connections between local features. In addition, the present invention adopts a new training strategy. Compared with the training strategy of directly combining different loss functions, the training strategy proposed by the present invention, while fully utilizing the triplet loss, also avoids conflicts between different loss functions to a certain extent, thereby improving training efficiency.
[0170] Figure 8 is a block diagram of a multi-scale multi-feature fusion pedestrian re-identification device according to an exemplary embodiment. Figure 8 The device includes an input unit 810, a feature extraction unit 820, a splicing unit 830, a conversion unit 840, a result acquisition unit 850 and a training unit 860.
[0171] The input unit 810 is used to input the image to be identified into a pre-trained pedestrian re-identification model, wherein the pedestrian re-identification model includes a feature extraction layer, an embedding layer, a global maximum pooling layer GMP, a global average pooling layer GAP, a convolution layer, a batch normalization layer, and an activation function; wherein the feature extraction layer is provided with three branches, and the embedding layer pre-stores the number of segmentations set for each branch;
[0172] A feature extraction unit 820, configured to obtain feature maps of three different scales through the three branches of the feature extraction layer;
[0173] A concatenation unit 830 is used to segment the three feature maps according to the number of segmentations preset by the embedding layer, respectively, to obtain three groups of segmented local feature maps, and to concatenate each group of local feature maps respectively to obtain multiple feature tensors;
[0174] A conversion unit 840, configured to convert the plurality of feature tensors into one-dimensional vectors through the global maximum pooling layer GMP, the global average pooling layer GAP, the convolution layer, the batch normalization layer, and the linear rectification ReLU activation function;
[0175] The result acquisition unit 850 is used to splice the obtained one-dimensional vectors to obtain one-dimensional vectors corresponding to multiple images to be detected, calculate the similarities between the one-dimensional vector of the image to be identified and the one-dimensional vectors of the multiple images to be detected, and determine the image to be detected corresponding to the image to be identified based on the multiple similarities obtained.
[0176] Optionally, the structure of the feature extraction layer includes:
[0177] The first three layers of the feature extraction layer completely inherit the first three layers of the Resnet-50 network. Among the three branches, the structure of the first branch is the same as the fourth and fifth layers of the Resnet-50 network, the structure of the second branch is the same as the fourth and improved fifth layers of the Resnet-50 network, and the structure of the third branch is the same as the improved fourth and improved fifth layers of the Resnet-50 network; wherein the improved fifth layer structure is the fifth layer structure with the downsampling link deleted, and the improved fourth layer structure is the fourth layer structure with the downsampling link deleted.
[0178] Optionally, the number of splits set for each branch pre-stored in the embedding layer includes:
[0179] The number of divisions of the first branch is 1, the number of divisions of the second branch is 2, and the number of divisions of the third branch is 3.
[0180] Optionally, the splicing unit 830 is used to:
[0181] For any group of local feature maps, the number X of the group of local feature maps is determined, and the local feature maps of the group are spliced through X rounds, wherein the i-th round of splicing includes i times of splicing, and the number of local feature maps included in the i-th splicing is respectively X, X-1, X-2, ..., X-i+1, and a feature tensor is obtained each time the splicing is performed. Then, the local feature maps of the group are spliced to obtain A feature tensor.
[0182] Optionally, the apparatus further includes a training unit 860, wherein the training unit 860 is configured to:
[0183] Obtain training sample data set;
[0184] The cross entropy loss Softmax Loss function is used to preliminarily train the initial pedestrian re-identification model to obtain a pre-trained pedestrian re-identification model;
[0185] The training sample data set is input into the pre-trained pedestrian re-identification model, and the hard sample triplet loss TriHard Loss function, the center loss Center Loss function and the Softmax Loss function are combined to obtain a comprehensive loss function. The pre-trained pedestrian re-identification model is trained according to the comprehensive loss function until the comprehensive loss function converges, and the training of the pedestrian re-identification model is completed to obtain a trained pedestrian re-identification model.
[0186] Optionally, the comprehensive loss function is defined as:
[0187] L=L softmax +γL Hardtrip +βL c
[0188] Among them, L softmax Represents the cross entropy loss function Softmax Loss, L softmax Defined as:
[0189]
[0190] In the formula, p(y i |x i ) represents the label y i The input x i The probability of being correctly identified;
[0191] Wherein, γ represents the first preset parameter, L Hardtrip Represents the TriHard Loss function of the difficult sample triplet, L Hardtrip Defined as:
[0192]
[0193] Where α is the set threshold, d represents the Euclidean distance between two images, (z) + represents max(z, 0), P, K refer to the P pedestrians constituting the triplet and the K images corresponding to each pedestrian, a, p represent positive sample pairs, and a, n represent negative sample pairs;
[0194] Where, β represents the second preset parameter, L c Represents the center loss function Center Loss, L c Defined as:
[0195]
[0196] Optionally, the training unit 860 is used to:
[0197] Inputting the training sample data set into the pre-trained pedestrian re-identification model, and training the pre-trained pedestrian re-identification model according to the output data of the ReLU activation function, the TriHard Loss function, and the Center Loss function in the pre-trained pedestrian re-identification model; wherein the pre-trained pedestrian re-identification model includes a fully connected layer and a Softmax Loss function;
[0198] The output data of the ReLU activation function is input into a fully connected layer, and the pre-trained person re-identification model is trained according to the output data of the fully connected layer and a Softmax Loss function.
[0199] Optionally, a stochastic gradient descent (SGD) optimizer is used to update parameters during the person re-identification model training process.
[0200] In an embodiment of the present invention, a multi-branch structure is used to obtain a pedestrian feature map. Compared with other algorithms that only use a single branch, the multi-branch structure can obtain richer pedestrian feature information. By combining the feature information in different branches, the pedestrian features can be more fully expressed. Moreover, the present invention combines the multi-branch structure with local feature learning to obtain feature representations of pedestrians at different levels, while fully utilizing the connections between adjacent local features, solving the problem that other pedestrian re-identification algorithms ignore the intrinsic connections between local features. In addition, the present invention adopts a new training strategy. Compared with the training strategy of directly combining different loss functions, the training strategy proposed by the present invention, while fully utilizing the triplet loss, also avoids conflicts between different loss functions to a certain extent, thereby improving training efficiency.
[0201] Fig. 9 1 is a schematic diagram of the structure of an electronic device 900 provided in an embodiment of the present invention. The electronic device 900 may have relatively large differences due to different configurations or performances, and may include one or more processors (central processing units, CPU) 901 and one or more memories 902, wherein the memory 902 stores at least one instruction, and the at least one instruction is loaded and executed by the processor 901 to implement the following steps of the multi-scale multi-feature fusion pedestrian re-identification method:
[0202] Input the image to be identified into a pre-trained pedestrian re-identification model, wherein the pedestrian re-identification model includes a feature extraction layer, an embedding layer, a global maximum pooling layer GMP, a global average pooling layer GAP, a convolution layer, a batch normalization layer, and an activation function; wherein the feature extraction layer is provided with three branches, and the embedding layer pre-stores the number of segmentations set for each branch;
[0203] Through the three branches of the feature extraction layer, three feature maps of different scales are obtained;
[0204] According to the number of segmentations preset by the embedding layer, the three feature maps are segmented respectively to obtain three groups of segmented local feature maps, and each group of local feature maps is spliced to obtain multiple feature tensors;
[0205] The multiple feature tensors are converted into one-dimensional vectors through the global maximum pooling layer GMP, the global average pooling layer GAP, the convolution layer, the batch normalization layer and the linear rectification ReLU activation function;
[0206] The obtained one-dimensional vectors are spliced to obtain one-dimensional vectors corresponding to multiple images to be detected, and the similarities between the one-dimensional vector of the image to be identified and the one-dimensional vectors of the multiple images to be detected are calculated. According to the obtained multiple similarities, the image to be detected corresponding to the image to be identified is determined.
[0207] In an exemplary embodiment, a computer-readable storage medium is also provided, such as a memory including instructions, and the instructions can be executed by a processor in a terminal to complete the above-mentioned multi-scale multi-feature fusion pedestrian re-identification method. For example, the computer-readable storage medium can be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, etc.
[0208] A person skilled in the art will understand that all or part of the steps to implement the above embodiments may be accomplished by hardware or by instructing related hardware through a program, and the program may be stored in a computer-readable storage medium, and the above-mentioned storage medium may be a read-only memory, a disk or an optical disk, etc.
[0209] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principle of the present invention should be included in the protection scope of the present invention.
Claims
1. A multi-scale multi-feature fusion pedestrian re-identification method, characterized in that: The method comprises: Input the image to be identified into a pre-trained pedestrian re-identification model, wherein the pedestrian re-identification model includes a feature extraction layer, an embedding layer, a global maximum pooling layer GMP, a global average pooling layer GAP, a convolution layer, a batch normalization layer, and an activation function; wherein the feature extraction layer is provided with three branches, and the embedding layer pre-stores the number of segmentations set for each branch; Wherein, the structure of the feature extraction layer includes: The first three layers of the feature extraction layer completely inherit the first three layers of the Resnet-50 network. Among the three branches, the structure of the first branch is the same as the fourth and fifth layers of the Resnet-50 network, the structure of the second branch is the same as the fourth and improved fifth layers of the Resnet-50 network, and the structure of the third branch is the same as the improved fourth and improved fifth layers of the Resnet-50 network; wherein the improved fifth layer structure is the fifth layer structure with the downsampling link deleted, and the improved fourth layer structure is the fourth layer structure with the downsampling link deleted; Through the three branches of the feature extraction layer, three feature maps of different scales are obtained; According to the number of segmentations preset by the embedding layer, the three feature maps are segmented respectively to obtain three groups of segmented local feature maps, and each group of local feature maps is spliced to obtain multiple feature tensors; Wherein, each group of local feature maps is spliced separately to obtain multiple feature tensors, including: For any group of local feature maps, the number X of the group of local feature maps is determined, and the local feature maps of the group are spliced through X rounds, wherein the i-th round of splicing includes i times of splicing, and the number of local feature maps included in the i-th splicing is respectively X, X-1, X-2, ..., X-i+1, and a feature tensor is obtained each time the splicing is performed. Then, the local feature maps of the group are spliced to obtain feature tensors; The number of splits set for each branch pre-stored in the embedding layer includes: The number of divisions of the first branch is 1, the number of divisions of the second branch is 2, and the number of divisions of the third branch is 3; The multiple feature tensors are converted into one-dimensional vectors through the global maximum pooling layer GMP, the global average pooling layer GAP, the convolution layer, the batch normalization layer and the linear rectification ReLU activation function; splicing the obtained one-dimensional vectors to obtain one-dimensional vectors corresponding to multiple images to be detected, calculating the similarities between the one-dimensional vector of the image to be identified and the one-dimensional vectors of the multiple images to be detected, and determining the image to be detected corresponding to the image to be identified according to the obtained multiple similarities; The training method of the pedestrian re-identification model is as follows: Obtain training sample data set; The cross entropy loss Softmax Loss function is used to preliminarily train the initial pedestrian re-identification model to obtain a pre-trained pedestrian re-identification model; Inputting the training sample data set into the pre-trained pedestrian re-identification model, combining the hard sample triplet loss TriHard Loss function, the center loss Center Loss function and the Softmax Loss function to obtain a comprehensive loss function, and training the pre-trained pedestrian re-identification model according to the comprehensive loss function until the comprehensive loss function converges, completing the training of the pedestrian re-identification model, and obtaining a trained pedestrian re-identification model; Wherein, the comprehensive loss function is defined as: L=L softmax +γL Hardtrip +βL c Among them, L softmax Represents the cross entropy loss function Softmax Loss, L softmax Defined as: In the formula, p(y i |x i ) represents the label y i The input x i The probability of being correctly identified; Wherein, γ represents the first preset parameter, L Hardtrip Represents the TriHard Loss function of the difficult sample triplet, L Hardtrip Defined as: Where α is the set threshold, d represents the Euclidean distance between two images, (z) + represents max(z,0), P, K refer to the P pedestrians constituting the triplet and the K images corresponding to each pedestrian, a, p represent positive sample pairs, and a, n represent negative sample pairs; Where β represents the second preset parameter, L c Represents the center loss function Center Loss, L c Defined as: Among them, the initial pedestrian re-identification model includes a fully connected layer and a Softmax Loss function; The step of inputting the training sample data set into the initial person re-identification model, combining the hard sample triplet loss TriHard Loss function, the center loss Center Loss function and the Softmax Loss function to obtain a comprehensive loss function, and training the pre-trained person re-identification model according to the comprehensive loss function includes: Inputting the training sample data set into the pre-trained pedestrian re-identification model, and training the pre-trained pedestrian re-identification model according to the output data of the ReLU activation function, the TriHard Loss function, and the Center Loss function in the pre-trained pedestrian re-identification model; Inputting the output data of the ReLU activation function into a fully connected layer, and training the pre-trained person re-identification model according to the output data of the fully connected layer and a Softmax Loss function; In the process of training the pedestrian re-identification model, a stochastic gradient descent SGD optimizer is used to update parameters.
2. A multi-scale multi-feature fusion pedestrian re-identification device, characterized in that: The device comprises: An input unit, used for inputting the image to be identified into a pre-trained pedestrian re-identification model, wherein the pedestrian re-identification model includes a feature extraction layer, an embedding layer, a global maximum pooling layer GMP, a global average pooling layer GAP, a convolution layer, a batch normalization layer and an activation function; wherein the feature extraction layer is provided with three branches, and the embedding layer pre-stores the number of segmentations set for each branch; Wherein, the structure of the feature extraction layer includes: The first three layers of the feature extraction layer completely inherit the first three layers of the Resnet-50 network. Among the three branches, the structure of the first branch is the same as the fourth and fifth layers of the Resnet-50 network, the structure of the second branch is the same as the fourth and improved fifth layers of the Resnet-50 network, and the structure of the third branch is the same as the improved fourth and improved fifth layers of the Resnet-50 network; wherein the improved fifth layer structure is the fifth layer structure with the downsampling link deleted, and the improved fourth layer structure is the fourth layer structure with the downsampling link deleted; A feature extraction unit, used to obtain feature maps of three different scales through three branches of the feature extraction layer; A splicing unit, used to segment the three feature maps according to the number of segmentations preset by the embedding layer, respectively, to obtain three groups of segmented local feature maps, and to splice each group of local feature maps respectively to obtain multiple feature tensors; Wherein, each group of local feature maps is spliced separately to obtain multiple feature tensors, including: For any group of local feature maps, the number X of the group of local feature maps is determined, and the local feature maps of the group are spliced through X rounds, wherein the i-th round of splicing includes i times of splicing, and the number of local feature maps included in the i-th splicing is respectively X, X-1, X-2, ..., X-i+1, and a feature tensor is obtained each time the splicing is performed. Then, the local feature maps of the group are spliced to obtain feature tensors; The number of splits set for each branch pre-stored in the embedding layer includes: The number of divisions of the first branch is 1, the number of divisions of the second branch is 2, and the number of divisions of the third branch is 3; A conversion unit, used to convert the multiple feature tensors into one-dimensional vectors through the global maximum pooling layer GMP, the global average pooling layer GAP, the convolution layer, the batch normalization layer and the linear rectification ReLU activation function; A result acquisition unit is configured to concatenate the obtained one-dimensional vectors to obtain one-dimensional vectors corresponding to multiple images to be detected, calculate the similarities between the one-dimensional vector of the image to be identified and the one-dimensional vectors of the multiple images to be detected, and determine the image to be detected corresponding to the image to be identified according to the obtained multiple similarities; The device further comprises a training unit, wherein the training unit is used to: Obtain training sample data set; The cross entropy loss Softmax Loss function is used to preliminarily train the initial pedestrian re-identification model to obtain a pre-trained pedestrian re-identification model; Inputting the training sample data set into the pre-trained pedestrian re-identification model, combining the hard sample triplet loss TriHard Loss function, the center loss Center Loss function and the Softmax Loss function to obtain a comprehensive loss function, and training the pre-trained pedestrian re-identification model according to the comprehensive loss function until the comprehensive loss function converges, completing the training of the pedestrian re-identification model, and obtaining a trained pedestrian re-identification model; Wherein, the comprehensive loss function is defined as: L=L softmax +γL Hardtrip +βL c Among them, L softmax Represents the cross entropy loss function Softmax Loss, L softmax Defined as: In the formula, p(y i |x i ) represents the label y i The input x i The probability of being correctly identified; Wherein, γ represents the first preset parameter, L Hardtrip Represents the TriHard Loss function of the difficult sample triplet, L Hardtrip Defined as: Where α is the set threshold, d represents the Euclidean distance between two images, (z) + represents max(z,0), P, K refer to the P pedestrians constituting the triplet and the K images corresponding to each pedestrian, a, p represent positive sample pairs, and a, n represent negative sample pairs; Where β represents the second preset parameter, L c Represents the center loss function Center Loss, L c Defined as: Among them, the initial pedestrian re-identification model includes a fully connected layer and a Softmax Loss function; The step of inputting the training sample data set into the initial person re-identification model, combining the hard sample triplet loss TriHard Loss function, the center loss Center Loss function and the Softmax Loss function to obtain a comprehensive loss function, and training the pre-trained person re-identification model according to the comprehensive loss function includes: Inputting the training sample data set into the pre-trained pedestrian re-identification model, and training the pre-trained pedestrian re-identification model according to the output data of the ReLU activation function, the TriHard Loss function, and the Center Loss function in the pre-trained pedestrian re-identification model; Inputting the output data of the ReLU activation function into a fully connected layer, and training the pre-trained person re-identification model according to the output data of the fully connected layer and a Softmax Loss function; In the process of training the pedestrian re-identification model, a stochastic gradient descent SGD optimizer is used to update parameters.
