Vehicle re-identification method based on self-guided feature mining network
By using a self-guided feature mining network, combined with a multi-head self-attention mechanism and a triplet loss function, the problems of background interference and fine-grained feature extraction in vehicle re-identification are solved, achieving more efficient vehicle identification accuracy.
Patent Information
- Application Number
- CN202310638550.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-06-01
- Publication Date
- 2025-10-24
- Estimated Expiration
- 2043-06-01
AI Technical Summary
Existing vehicle re-identification technologies rely on license plate recognition, which has problems such as high image accuracy requirements, background interference, and difficulty in mining fine-grained features. In addition, existing methods increase computational overhead.
A self-guided feature mining network is adopted, including a backbone network, a global branch, a noise patch filtering branch, and a salient feature extraction branch. Through a multi-head self-attention mechanism and a triplet loss function, vehicle features are extracted and background interference is eliminated to mine fine-grained features.
Without increasing computational overhead, it improves the accuracy of vehicle re-identification, effectively eliminates background interference, and mines fine-grained features, thereby enhancing the recognition effect.
Smart Images

Figure CN116704451B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of vehicle re-identification, and particularly relates to a vehicle re-identification method based on a self-guided feature mining network. BACKGROUND
[0002] Before the rise of deep learning technology, traditional vehicle re-identification can only be achieved by continuously capturing vehicle images and identifying vehicles by using license plates as the unique ID of vehicle identity. This technology excessively relies on vehicle license plates, and has high image accuracy requirements. In some illegal and criminal events, license plates are often obscured, removed or even forged, and it is very inefficient to rely on manpower to perform vehicle re-identification.
[0003] At present, the vehicle re-identification based on deep learning usually extracts the features of the entire input image, and then extracts the similarity of the features to find the most similar vehicle image. This way of extracting the features of the entire image has two problems, one is the interference of the image background on feature extraction, and the other is the difficulty in mining fine-grained features. The existing method to solve the first problem is to additionally train a background segmentation model, first segment the background of the vehicle image, and then extract the features of the vehicle image without the background. The existing method to solve the second problem is to mark the details such as the vehicle lights and emblems, and then use an additional positioning network to find the positions of these marked positions before feature extraction.
[0004] The existing solutions to the above two problems both need to additionally introduce a network model, dividing the vehicle re-identification task into two steps, and increasing the computational overhead of feature extraction. SUMMARY
[0005] The purpose of the present application is to solve the above-mentioned defects in the prior art, and to provide a vehicle re-identification method based on a self-guided feature mining network. This method can simultaneously extract features, eliminate the interference of the image background, and mine fine-grained features, without the need for additional network model assistance or the use of other label information other than image ID.
[0006] The purpose of the present application can be achieved by adopting the following technical solutions:
[0007] A vehicle re-identification method based on a self-guided feature mining network, the vehicle re-identification method comprising the following steps:
[0008] S1, constructing a self-guided feature mining network, the self-guided feature mining network comprising a backbone network and a global branch, a noise patch filtering branch, and a salient feature extraction branch;
[0009] S2, inputting a vehicle image dataset, and training the self-guided feature mining network;
[0010] S3, using the trained self-guided feature mining network to perform vehicle re-identification.
[0011] Further, the connection relationship from input to output in the backbone network is as follows:
[0012] the image patching layer, the Cls embedding layer, the position encoding embedding layer, the DP layer Dropout, the first conversion layer, the second conversion layer, the third conversion layer, the fourth conversion layer, the fifth conversion layer, the sixth conversion layer, the seventh conversion layer, the eighth conversion layer, the ninth conversion layer, the tenth conversion layer, and the eleventh conversion layer;
[0013] The image patching layer divides the input image into image patches; the Cls embedding layer adds feature Cls; the position encoding layer adds corresponding position encodings to the feature Cls and the image patches; the first conversion layer, the second conversion layer, the third conversion layer, the fourth conversion layer, the fifth conversion layer, the sixth conversion layer, the seventh conversion layer, the eighth conversion layer, the ninth conversion layer, the tenth conversion layer, and the eleventh conversion layer are conversion layers with the same structure, and the specific structure of the conversion layer is as follows:
[0014] The connection from the input layer to the output layer is: the Norm layer Norm_layer1, the Attn layer Attention1, the DP layer Dropout1, the Norm layer Norm_layer2, the MLP layer MLP1, and the DP layer Dropout2.
[0015] Further, the connection relationship from input to output in the global branch is as follows:
[0016] The input of the global branch is transmitted to the twelfth conversion layer, the twelfth conversion layer connects the global feature, the global feature is connected to the triple loss function layer and the BNNECK layer respectively, the BNNECK layer is connected to the cross-entropy loss function layer, the output of the triple loss function layer and the output of the cross-entropy loss function layer are added as the output of the global branch;
[0017] The global branch extracts global image features, supplements the feature information that may be lost by the noise patch filtering branch and the salient feature extraction branch, and enables the self-guided feature mining network to extract complete vehicle feature information.
[0018] Further, the connection relationship from input to output in the noise patch filtering branch is as follows:
[0019] The input of the noise patch filtering branch is transmitted to the thirteenth conversion layer, the thirteenth conversion layer is connected to the noise patch filtering layer, the noise patch filtering layer is respectively connected to the first noise patch filtering feature and the first global average pool, the first noise patch filtering feature is respectively connected to the first triple loss function layer and the first BNNECK layer, the first BNNECK layer is connected to the first cross-entropy loss function layer, the first global average pool is connected to the second noise patch filtering feature, the second noise patch filtering feature is respectively connected to the second triple loss function layer and the second BNNECK layer, the second BNNECK layer is connected to the second cross-entropy loss function layer, and the sum of the first triple loss function layer and the first cross-entropy loss function layer is added to the sum of the second triple loss function layer and the second cross-entropy loss function layer, and then added as the output of the noise patch filtering branch;
[0020] The noise patch filtering branch helps the self-guided feature mining network to filter the background patch without using the background label information, so as to eliminate the interference of the background on the vehicle feature extraction.
[0021] Further, the connection relationship from the input to the output in the significant feature extraction branch is as follows:
[0022] The input of the significant feature extraction branch is transmitted to the fourteenth conversion layer, the fourteenth conversion layer is connected to the significant feature extraction layer, the significant feature extraction layer is respectively connected to the first significant feature extraction feature and the second global average pool, the first significant feature extraction feature is respectively connected to the third triple loss function layer and the third BNNECK layer, the third BNNECK layer is connected to the third cross-entropy loss function layer, the second global average pool is connected to the second significant feature extraction feature, the second significant feature extraction feature is respectively connected to the fourth triple loss function layer and the fourth BNNECK layer, the fourth BNNECK layer is connected to the fourth cross-entropy loss function layer, the sum of the third triple loss function layer and the third cross-entropy loss function layer is added to the sum of the fourth triple loss function layer and the fourth cross-entropy loss function layer, and then added as the output of the significant feature extraction branch.
[0023] The significant feature extraction branch helps the self-guided feature mining network to find the key parts of the vehicle without using the vehicle component label, so as to enhance the distinguishability of the fine-grained features and better identify similar vehicles.
[0024] Further, in the noise patch filtering layer,
[0025] The score matrix A of the self-attention head is calculated by the multi-head self-attention mechanism of the Attn layer Attention13 in the thirteenth conversion layer. (N+1) A=[a0;a1;a2;...a i ...a N ]
[0026] wherein i=0, 1, 2...N is the position code of the embedding layer of the backbone network image position, the position code 0 corresponds to the position code of the feature Cls embedded by the embedding layer of the backbone network Cls, the position code i=1, 2...N corresponds to the position code of the i-th image patch of the image block layer of the backbone network, a i The N+1-dimensional vector composed of the attention score of the image patch with position code i and the feature Cls with position code 0, the N image patches with position code 1 to N, respectively, is expressed as follows:
[0027] a i = [a i,0 ; a i,1 ; a i,2 ;... a i,j ....; a i,N ]
[0028] wherein j=0, 1, 2...N, a i,j represents the attention score value of the image patch with position code i and the image patch with position code j;
[0029] The multi-head self-attention of the Attn layer Attention13 in the thirteenth conversion layer has K feature attention heads. For any one of the K feature attention heads, a score matrix A can be calculated. The average score matrix Aavg is obtained by averaging the score matrices of all feature attention heads. The average score matrix Aavg has the same expression as the score matrix A, except that the values in the matrix are different.
[0030] According to a0 in the average score matrix Aavg, the attention scores of the feature Cls and the image patches with position codes 1, 2...N are obtained. The N average attention scores are sorted from large to small, and M position codes with larger average attention scores are selected, wherein M is a positive integer less than N.
[0031] The feature Cls with position code 0 is input to the first noise patch filtering feature, and the image patches corresponding to the M position codes with larger average attention scores are input to the first global average pooling.
[0032] Further, in the significant feature extraction layer,
[0033] The score matrix A of the self-attention head is calculated by the multi-head self-attention mechanism of the Attn layer Attention14 in the fourteenth conversion layer, A∈R (N+1) *(N+1) is as follows: A=[a0;a1;a2;...a i ...;a N ]
[0034] wherein i=0, 1, 2...N is the position encoding of the embedding layer of the backbone network image position encoding, the position encoding 0 corresponds to the position encoding of the feature Cls embedded by the embedding layer of the backbone network Cls, the position encoding i=1, 2...N corresponds to the position encoding of the i-th image patch of the image patch layer of the backbone network, a i The N+1-dimensional vector composed of the attention score of the image patch with position encoding i and the feature Cls with position encoding 0, the N image patches with position encoding 1 to N, respectively, is expressed as follows:
[0035] a i = [a i,0 ; a i,1 ; a i,2 ;... a i,j ....; a i,N ]
[0036] wherein j=0, 1, 2...N, a i,j represents the attention score value of the image patch with position encoding i and the image patch with position encoding j;
[0037] The multi-head self-attention of the Attention13 layer in the fourteenth conversion layer has K feature attention heads. For any one of the K feature attention heads, a score matrix A can be calculated, and K score matrices A are obtained for the K feature attention heads.
[0038] According to the score matrix A l , the attention scores of the feature Cls and the image patches with position encoding 1, 2...N are obtained, the N attention scores are sorted from large to small, and the position encoding with the largest attention score is selected, wherein A l represents the l-th feature attention head, l∈(1, 2...K), and K position encodings are obtained for the K feature attention heads.
[0039] The feature Cls with position encoding 0 is input to the second noise patch filtering feature, and the image patches corresponding to the K position encodings are input to the second global average pool.
[0040] Further, the step S2 process is as follows:
[0041] S21, construct a vehicle re-identification dataset, use PK sampling method (from Hao Luo, Bag of Tricks and A Strong Baseline for Deep Person Re-identification, published in Proceedings of the IEEE / CVF Conference on Computer Vision and Pattern Recognition (CVPR) Workshops, 2019, PK sampling method refers to selecting P classes of vehicles when selecting a batch of data input to the neural network, and K images are selected for each class of vehicle), batch sampling of the dataset, PK sampling method randomly samples P classes of vehicles in the dataset for each batch of images input to the self-guided feature mining network, K images are selected for each class of vehicle, and then the vehicle images are input to the self-guided feature mining network in batches to obtain global features, first noise patch filtering features, second noise patch filtering features, first significant feature extraction features, and second significant feature extraction features; wherein the reason for using the PK sampling method is that when calculating the triplet loss, it is necessary to find the positive sample image and the negative sample image of the anchor image in a batch of images, therefore, P classes of vehicles are needed to form negative samples, and K images of each class of vehicle form positive samples.
[0042] S22, respectively input the global features, the first noise patch filtering features, the second noise patch filtering features, the first significant feature extraction features, and the second significant feature extraction features obtained in step S21 into the triplet loss function layer, the first triplet loss function layer, the second triplet loss function layer, the third triplet loss function layer, and the fourth triplet loss function layer to calculate the triplet loss, in a batch, select an image as an anchor image, the images belonging to the same vehicle ID as the anchor image are called positive samples, and the images not belonging to the same vehicle ID as the anchor image are called negative samples;
[0043] The function definition of the triplet loss is as follows:
[0044] L triplet (c,p,n)=log(1+exp(max(D cp )-min(D cn )))
[0045] Wherein, c represents the anchor image, p represents the image constituting the positive sample with c, n represents the image constituting the negative sample with c, D cp represents the distance between the anchor image and the positive sample, D cn represents the distance between the anchor image and the negative sample, max(D cp ) represents the maximum value, and min(Dcn ) represents the minimum value; calculating the triplet loss function can narrow the distance of similar images in feature space, while increasing the distance of similar images of different classes in feature space, thereby improving the accuracy of the self-guided feature mining network in re-identification;
[0046] S23, respectively, the global feature, the first noise patch filtering feature, the second noise patch filtering feature, the first significant feature extraction feature, the second significant feature extraction feature obtained in step S21 are input into the cross-entropy loss function layer, the first cross-entropy loss function layer, the second cross-entropy loss function layer, the third cross-entropy loss function layer, and the fourth cross-entropy loss function layer to calculate the cross-entropy loss;
[0047] The function definition of the cross-entropy loss is as follows:
[0048] Wherein, x represents the real label of the image, x t represents the real label of the image, y represents the probability value of the model identifying the image label, y t represents the probability value of the model identifying the image as the tth ID, Q represents the number of ID categories of the image data set; the cross-entropy loss function is used to identify whether the image belongs to the same category, and the self-guided feature mining network is optimized to identify the images of the same category as much as possible.
[0049] S24, the total loss function value is obtained by adding the triplet loss function and the cross-entropy loss function:
[0050] L Loss (F0)=L triplet (c,p,n)+L ID (x,y)
[0051] Wherein F0 represents the feature of the input image, L triplet (c,p,n) represents the triplet loss of the image with the input image feature F0, L ID (x,y) represents the cross-entropy loss of the image with the input image feature F0, L Loss (F0) represents the overall loss of the image with the input image feature F0; the combination of the triplet loss and the cross-entropy loss can optimize the distribution of the features in the feature space, and the features output by the self-guided feature mining network can better distinguish other image features;
[0052] S25, the global feature, the first noise patch filtering feature, the second noise patch filtering feature, the first significant feature extraction feature, and the second significant feature extraction feature obtained in step S21 are respectively calculated to obtain the overall loss function expression as follows:
[0053] L Total =λ1LLoss (F1) + λ2L Loss (F2) + λ3L Loss (F3)
[0054] + λ4L Loss (F4) + λ5L Loss (F5)
[0055] wherein λ1, λ2, λ3, λ4, λ5 represent the first, second, third, fourth, fifth weight of the loss function in the overall loss function, F1 represents the global feature, F2 represents the first noise patch filtering feature, F3 represents the second noise patch filtering feature, F4 represents the first salient feature extraction feature, and F5 represents the second salient feature extraction feature; the loss purposes of calculating the global feature, the first noise patch filtering feature, the second noise patch filtering feature, the first salient feature extraction feature, and the second salient feature extraction feature are to make different parameter optimizations for the global branch, the noise patch filtering branch, and the salient feature extraction branch, and to make overall parameter optimization for the backbone network; the reasons for using the first, second, third, fourth, and fifth weights are that the input data sizes corresponding to the global feature, the first noise patch filtering feature, the second noise patch filtering feature, the first salient feature extraction feature, and the second salient feature extraction feature are different.
[0056] Further, the step S3 is as follows:
[0057] The images in the gallery are sequentially input into the self-guided feature mining network that has been trained and converged to obtain the global feature, the first noise patch filtering feature, the second noise patch filtering feature, the first salient feature extraction feature, and the second salient feature extraction feature. The global feature obtained by using the gallery input image is represented as the feature of the gallery input image. The query image is input into the self-guided feature mining network that has been trained and converged to obtain the global feature, the first noise patch filtering feature, the second noise patch filtering feature, the first salient feature extraction feature, and the second salient feature extraction feature. The global feature obtained by using the query image is represented as the feature of the query image. The features of the query image are sequentially compared with the features of the images in the gallery by using a distance measurement function to calculate the distances between the query image and the images in the gallery. The calculation results of the distances between the query image and the images in the gallery are arranged in order from small to large. According to the arrangement results, the 10 images with the smallest distances are selected from the gallery as the re-identification results. The reason for using only the global feature to represent the feature of the query image instead of combining the global feature, the first noise patch filtering feature, the second noise patch filtering feature, the first salient feature extraction feature, and the second salient feature extraction feature is that using a lower-dimensional feature can reduce the time and calculation overhead in feature similarity calculation, and using a lower-dimensional feature occupies less storage space.
[0058] Further, the distance metric function adopts a Euclidean distance function or a cosine distance function. Because the distance between two images cannot be directly calculated, the features of the images are extracted to represent the images. The extracted features are a vector, and the Euclidean distance or the cosine distance can be used to represent the distance between two vectors, and the feature vector is used to represent the image, so the Euclidean distance function or the cosine distance function is used as the distance metric function to calculate the distance between the images.
[0059] The present application has the following advantages and effects relative to the prior art:
[0060] (1) The present application extracts image features while eliminating the interference of the image background, mines image fine-grained features, and extracts more distinctive features to improve the accuracy of vehicle re-identification.
[0061] (2) The present application proposes a noise patch filtering branch, realizes no-label filtering of the image background, eliminates the interference of the background, integrates the noise patch filtering branch into the backbone network, and eliminates the background interference while extracting features.
[0062] (3) The present application proposes a salient feature extraction branch, mines fine-grained features without labeling the position of the vehicle, integrates the salient feature extraction branch into the backbone network, and mines fine-grained features while extracting features. BRIEF DESCRIPTION OF DRAWINGS
[0063] The drawings described herein are used to provide further understanding of the present application, constitute a part of the present application, and the illustrative embodiments of the present application and the description thereof are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0064] Figure 1 is a flowchart of a vehicle re-identification method based on a self-guided feature mining network disclosed in the present application;
[0065] Figure 2 is a structure diagram of a vehicle re-identification method based on a self-guided feature mining network disclosed in the present application;
[0066] Figure 3 is a backbone network structure diagram of a vehicle re-identification method based on a self-guided feature mining network disclosed in the present application;
[0067] Figure 4 is a global branch structure diagram of a vehicle re-identification method based on a self-guided feature mining network disclosed in the present application;
[0068] Figure 5 is a noise patch filtering branch structure diagram of a vehicle re-identification method based on a self-guided feature mining network disclosed in the present application;
[0069] Figure 6is a significant feature extraction branch structure diagram of a vehicle re-identification method based on a self-guided feature mining network disclosed in the present application;
[0070] Figure 7 is a visual result comparison example diagram of the embodiment method of the present application with and without using noise patch filtering branches;
[0071] Figure 8 is a visual result comparison example diagram of the embodiment method of the present application with and without using significant feature extraction branches;
[0072] Figure 9 is a re-identification result diagram of a vehicle re-identification method based on a self-guided feature mining network disclosed in the present application. DETAILED DESCRIPTION
[0073] In order to make the purposes, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be described clearly and completely below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, rather than all the embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative labor fall within the scope of protection of the present application.
[0074] Embodiment 1
[0075] This embodiment is from a disclosed data set named VehicleID, which contains 221763 pictures of 26267 vehicles, of which 110178 pictures of 13134 vehicles are used as a training set, and the remaining pictures are divided into 3 different test subsets, corresponding to a Large test set, a Middle test set and a Small test set.
[0076] This embodiment is implemented by the process shown in Figure 1 As shown in the figure,
[0077] In the experimental environment, the experimental environment of the embodiment only needs a general hardware configuration and a graphics processing unit (GPU) that can improve the calculation speed to perform accelerated operation. The model is built and trained using the Pytorch deep learning framework, and the Compute Unified Device Architecture (CUDA) is used to enable the GPU to solve complex calculation problems. Specifically, the hardware and software configuration used in the embodiment is as follows: the GPU version is GeForce RTX 3090; the CPU version is Intel(R) Xeon(R) Silver 4216 CPU@2.10GHz; the operating system version is CentOS 8.3.2011; the Python version is 3.9; and the CUDA version is 11.2.
[0078] A vehicle re-identification method based on a self-guided feature mining network includes the following steps:
[0079] Step S1, a self-guided feature mining network is constructed, which includes a backbone network and a global branch, a noise patch filtering branch, and a salient feature extraction branch, as shown in Figure 2 , and specifically as follows:
[0080] The backbone network is as shown in Figure 3 , and the specific structure is as follows:
[0081] The connection from the input layer to the output layer is as follows: image block layer, Cls embedding layer, position coding embedding layer, DP layer Dropout, first conversion layer, second conversion layer, third conversion layer, fourth conversion layer, fifth conversion layer, sixth conversion layer, seventh conversion layer, eighth conversion layer, ninth conversion layer, tenth conversion layer, eleventh conversion layer; and the specific structure of the conversion layer is as follows:
[0082] The connection from the input layer to the output layer is as follows: Norm layer Norm_layer1, Attn layer Attention1, DP layer Dropout1, Norm layer Norm_layer2, MLP layer MLP1, DP layer Dropout2.
[0083] The global branch is as shown in Figure 4 , and the specific structure is as follows:
[0084] The connection from the input to the output is as follows:
[0085] The input of the global branch is passed to the twelfth conversion layer, the twelfth conversion layer is connected to the global features, the global features are connected to the triplet loss function layer and the BNNECK layer respectively, the BNNECK layer is connected to the cross entropy loss function layer, and the output of the triplet loss function layer is added to the output of the cross entropy loss function layer as the output of the global branch.
[0086] Noise patch filtering branch such as Figure 5 As shown, the specific structure is as follows:
[0087] The connection relationship from input to output is as follows:
[0088] The input of the noise patch filtering branch is passed to the thirteenth conversion layer, the thirteenth conversion layer is connected to the noise patch filtering layer, the noise patch filtering layer is respectively connected to the first noise patch filtering feature and the first global average pool, the first noise patch filtering feature is respectively connected to the first triplet loss function layer and the first BNNECK layer, the first BNNECK layer is connected to the first cross entropy loss function layer, the first global average pool is connected to the second noise patch filtering feature, the second noise patch filtering feature is respectively connected to the second triplet loss function layer and the second BNNECK layer, the second BNNECK layer is connected to the second cross entropy loss function layer, the sum of the first triplet loss function layer and the first cross entropy loss function layer is added to the sum of the second triplet loss function layer and the second cross entropy loss function layer as the output of the noise patch filtering branch.
[0089] The salient feature extraction branch is as follows Figure 6 As shown, the specific structure is as follows:
[0090] The connection relationship from input to output is as follows:
[0091] The input of the salient feature extraction branch is passed to the fourteenth conversion layer, the fourteenth conversion layer is connected to the salient feature extraction layer, the salient feature extraction layer is respectively connected to the first salient feature extraction feature and the second global average pool, the first salient feature extraction feature is respectively connected to the third triplet loss function layer and the third BNNECK layer, the third BNNECK layer is connected to the third cross entropy loss function layer, the second global average pool is connected to the second salient feature extraction feature, the second salient feature extraction feature is respectively connected to the fourth triplet loss function layer and the fourth BNNECK layer, the fourth BNNECK layer is connected to the fourth cross entropy loss function layer, the sum of the third triplet loss function layer and the third cross entropy loss function layer is added to the sum of the fourth triplet loss function layer and the fourth cross entropy loss function layer as the output of the salient feature extraction branch.
[0092] Use the noise patch filtering branch to perform noise patch filtering. The specific process is as follows: The score matrix A∈R of the self-attention head is calculated by the multi-head self-attention mechanism of the Attn layer Attention13 in the thirteenth conversion layer(N+1)*(N+1) As follows:
[0093] A = [a0; a1; a2;... a i ... ; a N ]
[0094] Wherein, i = 0, 1, 2... N is the position code embedded by the main network image position code embedding layer, the position code 0 corresponds to the position code of the feature Cls embedded by the main network Cls embedding layer, and the position code i = 1, 2... N corresponds to the position code of the i-th image patch of the main network image block layer, a i The N+1-dimensional vector composed of the attention score of the image patch with position code i and the feature Cls with position code 0, the N image patches with position code 1 to N, respectively, is expressed as follows:
[0095] a i = [a i,0 ; a i,1 ; a i,2 ;..a i,j ....; a i,N ]
[0096] Wherein, j = 0, 1, 2... N, a i,j Indicates the attention score value of the image patch with position code i and the image patch with position code j;
[0097] The multi-head self-attention of the Attn layer Attention13 in the thirteenth conversion layer has K feature attention heads. For any one of the K feature attention heads, a score matrix A can be calculated. The average score matrix Aavg is obtained by averaging the score matrices of all feature attention heads. The average score matrix Aavg has the same expression as the score matrix A, except that the values in the matrix are different.
[0098] According to a0 in the average score matrix Aavg, the attention scores of the feature Cls and the image patches with position codes 1, 2... N are obtained. The N average attention scores are sorted from large to small, and M position codes with larger average attention scores are selected, wherein M is a positive integer less than N.
[0099] The feature Cls with position code 0 is input to the first noise patch filtering feature, and the image patches corresponding to the M position codes with larger average attention scores are input to the first global average pool.
[0100] The visualization result of the noise patch filtering is shown in Figure 7 .
[0101] The specific process of using the salient feature extraction branch to extract salient features is as follows:
[0102] The score matrix A ∈ R (N+1)*(N+1) As follows:
[0103] A = [a0; a1; a2;... a i ...; a N ]
[0104] Wherein, i = 0, 1, 2...N is the position encoding embedded by the image position encoding embedding layer of the backbone network, the position encoding 0 corresponds to the position encoding of the feature Cls embedded by the Cls embedding layer of the backbone network, the position encoding i = 1, 2...N corresponds to the position encoding of the i-th image patch of the image patch layer of the backbone network, a i The attention score of the image patch with position encoding i and the feature Cls with position encoding 0, the image patch with position encoding 1 to N is represented by an N+1-dimensional vector, and the expression is as follows:
[0105] a i = [a i,0 ; a i,1 ; a i,2 ;..a i,j ....; a i,N ]
[0106] Wherein, j = 0, 1, 2...N, a i,j represents the attention score value of the image patch with position encoding i and the image patch with position encoding j;
[0107] The multi-head self-attention of the Attn layer Attention13 in the fourteenth conversion layer has K common feature attention heads, and for any one of the K feature attention heads, a score matrix A can be calculated, and the K feature attention heads obtain K score matrices A;
[0108] According to the score matrix A l , the attention score of the feature Cls and the image patch with position encoding 1, 2...N is obtained, the N attention scores are sorted from large to small, and the position encoding with the maximum attention score is selected, wherein A l represents the l-th feature attention head, l ∈ (1, 2...K), and the K feature attention heads obtain K position encodings;
[0109] The feature Cls with position encoding 0 is input to the second noise patch filtering feature, and the image patch corresponding to the K position encodings is input to the second global average pool.
[0110] The visualization result of the significant feature extraction is as follows: Figure 8as shown.
[0111] Step S2, input the vehicle image dataset, train the self-guided feature mining network, as follows:
[0112] S21, construct a vehicle re-identification dataset, use the PK sampling method (from Hao Luo, Bag of Tricks and A Strong Baseline for Deep Person Re-identification, published in Proceedings of the IEEE / CVF Conference on Computer Vision and Pattern Recognition (CVPR) Workshops, 2019, the PK sampling method refers to selecting P classes of vehicles when selecting a batch of data input to the neural network, and selecting K images for each class of vehicle), and batch sample the dataset. The PK sampling method randomly samples P classes of vehicles in the dataset for each batch of images input to the self-guided feature mining network, selects K images for each class of vehicle, and then inputs the vehicle images in batches to the self-guided feature mining network to obtain global features, first noise patch filtering features, second noise patch filtering features, first salient feature extraction features, and second salient feature extraction features.
[0113] S22, input the global features, first noise patch filtering features, second noise patch filtering features, first salient feature extraction features, and second salient feature extraction features obtained in S21 into the triplet loss function layer, the first triplet loss function layer, the second triplet loss function layer, the third triplet loss function layer, and the fourth triplet loss function layer to calculate the triplet loss. In a batch, a selected image is an anchor image, images belonging to the same vehicle ID as the anchor image are positive samples, and images not belonging to the same vehicle ID as the anchor image are negative samples.
[0114] The function definition of the triplet loss is as follows:
[0115] L triplet (c,p,n)=log(1+exp(max(D cp )-min(D cn )))
[0116] Wherein, c represents the anchor image, p represents the image constituting the positive sample with c, n represents the image constituting the negative sample with c, D cp represents the distance between the anchor image and the positive sample, D cn represents the distance between the anchor image and the negative sample, max(D cp ) represents the maximum value, and min(Dcn ) represents the minimum value;
[0117] S23, respectively, the global features, the first noise patch filtering features, the second noise patch filtering features, the first salient feature extraction features, the second salient feature extraction features obtained by S21 are input into the cross entropy loss function layer, the first cross entropy loss function layer, the second cross entropy loss function layer, the third cross entropy loss function layer, the fourth cross entropy loss function layer to calculate the cross entropy loss;
[0118] The function definition of cross entropy loss is as follows:
[0119]
[0120] Wherein, x represents the real label of the image, x t represents the real label of the image as the tth ID, y represents the probability value of the model identifying the image label, y t represents the probability value of the model identifying the image as the tth ID, Q represents the number of ID categories of the image data set;
[0121] S24, the total loss function value is obtained by adding the triplet loss function and the cross entropy loss function:
[0122] L Loss (F0)=L triplet (c,p,n)+L ID (x,y)
[0123] Wherein F0 represents the feature of the input image, L triplet (c,p,n) represents the triplet loss of the image whose input image feature is F0, L ID (x,y) represents the cross entropy loss of the image whose input image feature is F0, L Loss (F0) represents the overall loss of the image whose input image feature is F0.
[0124] S25, the global features, the first noise patch filtering features, the second noise patch filtering features, the first salient feature extraction features, the second salient feature extraction features obtained by S21 are respectively calculated to obtain the overall loss function expression as follows:
[0125] L Total =λ1L Loss (F1)+λ2L Loss (F2)+λ3L Loss (F3)
[0126] +λ4L Loss (F4)+λ5L Loss (F5)
[0127] Wherein λ1, λ2, λ3, λ4, λ5 represent the first, second, third, fourth and fifth weights of the loss function in the overall loss function, F1 represents the global feature, F2 represents the first noise patch filtering feature, F3 represents the second noise patch filtering feature, F4 represents the first salient feature extraction feature, and F5 represents the second salient feature extraction feature.
[0128] Step S3, using the trained self-guided feature mining network for vehicle re-identification, sequentially inputting the images in the gallery into the self-guided feature mining network that has been trained and converged to obtain the global feature, the first noise patch filtering feature, the second noise patch filtering feature, the first salient feature extraction feature, and the second salient feature extraction feature. The global feature obtained by using the gallery input image is denoted as the feature of the gallery input image. The query image is input into the self-guided feature mining network that has been trained and converged to obtain the global feature, the first noise patch filtering feature, the second noise patch filtering feature, the first salient feature extraction feature, and the second salient feature extraction feature. The global feature obtained by using the query image is denoted as the feature of the query image. The features of the query image and the features of the images in the gallery are sequentially calculated using a distance measurement function (Euclidean distance function or cosine distance function) to calculate the distance between the query image and the images in the gallery. The calculation results of the distance between the query image and the images in the gallery are arranged in order from small to large, and the 10 images with the smallest distance are selected from the gallery as the re-identification result according to the arrangement result.
[0129] The vehicle re-identification result is as shown in Figure 9 .
[0130] The experimental results of Example 1 show that, compared with the results of not using the noise patch filtering branch and the salient feature extraction branch of the self-guided feature mining network, the results of using the noise patch filtering branch and the salient feature extraction branch are improved by 3.2 in the Rank-1 index on the Small test subset, improved by 2.9 in the Rank-1 index on the Middle test subset, and improved by 2.7 in the Rank-1 index on the Large test subset, further verifying the effectiveness of the present application.
[0131] Example 2
[0132] In this embodiment, the data set is publicly available and is named VERI-Wild data set. The data set contains 416314 images of 40671 vehicles, and the images are from 174 cameras that continuously take pictures for one month. The test set is also divided into three test subsets, Large test set, Middle test set, and Small test set.
[0133] This embodiment is implemented by the process as shown in Figure 1 , as shown in the figure,
[0134] In the experimental environment, only general hardware configuration and a graphics processing unit (GPU) capable of improving computing speed are required for accelerated operation in the experimental environment of the embodiment. The model is built and trained using the Pytorch deep learning framework, and the Compute Unified Device Architecture (CUDA) is used to enable the GPU to solve complex computing problems. Specifically, the hardware and software configuration used in the embodiment is as follows: the GPU version is GeForce RTX 3090; the CPU version is Intel(R) Xeon(R) Silver 4216 CPU@2.10GHz; the operating system version is CentOS 8.3.2011; the Python version is 3.9; and the CUDA version is 11.2.
[0135] A vehicle re-identification method based on a self-guided feature mining network includes the following steps:
[0136] Step S1, a self-guided feature mining network is constructed, which includes a backbone network and a global branch, a noise patch filtering branch, and a salient feature extraction branch, as shown in Figure 2 The specific structure is as follows:
[0137] The backbone network is as shown in Figure 3 The specific structure is as follows:
[0138] The connection from the input layer to the output layer is as follows: image block layer, Cls embedding layer, position encoding embedding layer, DP layer Dropout, first conversion layer, second conversion layer, third conversion layer, fourth conversion layer, fifth conversion layer, sixth conversion layer, seventh conversion layer, eighth conversion layer, ninth conversion layer, tenth conversion layer, eleventh conversion layer; the specific structure of the conversion layer is as follows:
[0139] The connection from the input layer to the output layer is as follows: Norm layer Norm_layer1, Attn layer Attention1, DP layer Dropout1, Norm layer Norm_layer2, MLP layer MLP1, DP layer Dropout2.
[0140] The global branch is as shown in Figure 4 The specific structure is as follows:
[0141] The connection from the input to the output is as follows:
[0142] The input of the global branch is transmitted to the twelfth conversion layer, the twelfth conversion layer connects global features, the global features are respectively connected to the triple loss function layer and the BNNECK layer, the BNNECK layer is connected to the cross-entropy loss function layer, and the output of the triple loss function layer and the output of the cross-entropy loss function layer are added as the output of the global branch.
[0143] The noise patch filtering branch is as shown in Figure 5 The specific structure is as follows:
[0144] The connection relationship from the input to the output is as follows:
[0145] The input of the noise patch filtering branch is transmitted to the thirteenth conversion layer, the thirteenth conversion layer connects the noise patch filtering layer, the noise patch filtering layer is respectively connected to the first noise patch filtering feature and the first global average pool, the first noise patch filtering feature is respectively connected to the first triple loss function layer and the first BNNECK layer, the first BNNECK layer is connected to the first cross-entropy loss function layer, the first global average pool is connected to the second noise patch filtering feature, the second noise patch filtering feature is respectively connected to the second triple loss function layer and the second BNNECK layer, the second BNNECK layer is connected to the second cross-entropy loss function layer, and the sum of the first triple loss function layer and the first cross-entropy loss function layer and the sum of the second triple loss function layer and the second cross-entropy loss function layer are added again as the output of the noise patch filtering branch.
[0146] The significant feature extraction branch is as shown in Figure 6 The specific structure is as follows:
[0147] The connection relationship from the input to the output is as follows:
[0148] The input of the significant feature extraction branch is transmitted to the fourteenth conversion layer, the fourteenth conversion layer connects the significant feature extraction layer, the significant feature extraction layer is respectively connected to the first significant feature extraction feature and the second global average pool, the first significant feature extraction feature is respectively connected to the third triple loss function layer and the third BNNECK layer, the third BNNECK layer is connected to the third cross-entropy loss function layer, the second global average pool is connected to the second significant feature extraction feature, the second significant feature extraction feature is respectively connected to the fourth triple loss function layer and the fourth BNNECK layer, the fourth BNNECK layer is connected to the fourth cross-entropy loss function layer, and the sum of the third triple loss function layer and the third cross-entropy loss function layer and the sum of the fourth triple loss function layer and the fourth cross-entropy loss function layer are added again as the output of the significant feature extraction branch.
[0149] The noise patch filtering is performed using the noise patch filtering branch, and the specific process is as follows: the score matrix A of the self-attention head is calculated by the multi-head self-attention mechanism of the Attn layer Attention 13 in the thirteenth conversion layer (N+1)*(N+1) As follows:
[0150] A=[a0;a1;a2;...a i ...;a N ]
[0151] Wherein, i=0, 1, 2...N is the position encoding embedded by the image position encoding embedding layer of the backbone network, the position encoding 0 corresponds to the position encoding of the feature Cls embedded by the Cls embedding layer of the backbone network, and the position encoding i=1, 2...N corresponds to the position encoding of the i th image patch of the image block layer of the backbone network, a i The attention score of the image patch with position encoding i and the feature Cls with position encoding 0, the N image patches with position encoding 1 to N, respectively, is represented by an N+1-dimensional vector, and the expression is as follows:
[0152] a i =[a i,0 ;a i,1 ;a i,2 ;..a i,j ....;a i,N ]
[0153] Wherein, j=0, 1, 2...N, a i,j represents the attention score value of the image patch with position encoding i and the image patch with position encoding j;
[0154] The multi-head self-attention of the Attn layer Attention 13 in the thirteenth conversion layer has K feature attention heads in common, and for any one of the K feature attention heads, a score matrix A can be calculated, and the average score matrix Aavg is obtained by averaging the score matrices of all feature attention heads. The average score matrix Aavg has the same expression as the score matrix A, and the difference lies in that the values in the matrix are different;
[0155] According to a0 in the average score matrix Aavg, the attention scores of the feature Cls and the image patches with position encodings 1, 2...N are obtained, the N average attention scores are sorted from large to small, and M position encodings with larger average attention scores are selected, wherein M is a positive integer less than N;
[0156] The feature with position encoding 0 is input into the first noise patch filtering feature, and the image patches corresponding to the M position encodings with larger average attention scores are input into the first global average pool.
[0157] The significant feature extraction branch is used for significant feature extraction, and the specific process is as follows:
[0158] The score matrix A of the self-attention head is calculated by the multi-head self-attention mechanism of the Attn layer Attention 14 in the fourteenth conversion layer (N+1)*(N+1) As follows:
[0159] A=[a0;a1;a2;...a i ...;a N ]
[0160] Wherein, i=0, 1, 2...N is the position encoding embedded by the image position encoding embedding layer of the backbone network, the position encoding 0 corresponds to the position encoding of the feature Cls embedded by the Cls embedding layer of the backbone network, the position encoding i=1, 2...N corresponds to the position encoding of the i-th image patch of the image patch layer of the backbone network, and a i The attention score of the image patch with position encoding i and the feature Cls with position encoding 0, the N image patches with position encoding 1 to N, respectively, is represented by an N+1-dimensional vector, and the expression is as follows:
[0161] a i =[a i,0 ;a i,1 ;a i,2 ;..a i,j ....;a i,N ]
[0162] Wherein, j=0, 1, 2...N, a i,j Indicates the attention score value of the image patch with position encoding i and the image patch with position encoding j;
[0163] The Attn layer Attention 13 in the fourteenth conversion layer has K feature attention heads in common, and for any one of the K feature attention heads, a score matrix A can be calculated, and K score matrices A are obtained for the K feature attention heads;
[0164] According to the score matrix A l , the attention score of the feature Cls and the image patch with position encoding 1, 2...N is obtained, the N attention scores are sorted from large to small, and the position encoding with the maximum attention score is selected, wherein A l Indicates the l-th feature attention head, l∈(1, 2...K), and K position encodings are obtained for the K feature attention heads;
[0165] The feature Cls with position encoding 0 is input to the second noise patch filtering feature, and the image patch corresponding to the K position encodings is input to the second global average pool.
[0166] Step S2, input the vehicle image dataset, train the self-guided feature mining network, as follows:
[0167] S21, construct a vehicle re-identification dataset, use the PK sampling method (from Hao Luo, Bag of Tricks and A Strong Baseline for Deep Person Re-identification, published in Proceedings of the IEEE / CVF Conference on Computer Vision and Pattern Recognition (CVPR) Workshops, 2019, the PK sampling method refers to selecting P classes of vehicles when selecting a batch of data input to the neural network, and selecting K images for each class of vehicle), and batch sample the dataset. The PK sampling method randomly samples P classes of vehicles in the dataset for each batch of images input to the self-guided feature mining network, selects K images for each class of vehicle, and then inputs the vehicle images in batches to the self-guided feature mining network to obtain global features, first noise patch filtering features, second noise patch filtering features, first salient feature extraction features, and second salient feature extraction features.
[0168] S22, input the global features, first noise patch filtering features, second noise patch filtering features, first salient feature extraction features, and second salient feature extraction features obtained in S21 into the triplet loss function layer, the first triplet loss function layer, the second triplet loss function layer, the third triplet loss function layer, and the fourth triplet loss function layer to calculate the triplet loss. In a batch, a selected image is an anchor image, images belonging to the same vehicle ID as the anchor image are positive samples, and images not belonging to the same vehicle ID as the anchor image are negative samples.
[0169] The function definition of the triplet loss is as follows:
[0170] L triplet (c,p,n)=log(1+exp(max(D cp )-min(D cn )))
[0171] Where c represents the anchor image, p represents the image that constitutes a positive sample with c, n represents the image that constitutes a negative sample with c, D cp represents the distance between the anchor image and the positive sample, D cn represents the distance between the anchor image and the negative sample, max(D cp ) represents the maximum value, and min(D cnrepresents the minimum value;
[0172] S23, respectively, the global features, the first noise patch filtering features, the second noise patch filtering features, the first salient feature extraction features, the second salient feature extraction features obtained by S21 are input into the cross entropy loss function layer, the first cross entropy loss function layer, the second cross entropy loss function layer, the third cross entropy loss function layer, the fourth cross entropy loss function layer to calculate the cross entropy loss;
[0173] The function definition of cross entropy loss is as follows:
[0174]
[0175] Wherein, x represents the real label of the image, x t represents the real label of the image as the tth ID, y represents the probability value of the model identifying the image label, y t represents the probability value of the model identifying the image as the tth ID, Q represents the number of ID categories of the image data set;
[0176] S24, the total loss function value is obtained by adding the triplet loss function and the cross entropy loss function:
[0177] L Loss (F0)=L triplet (c,p,n)+L ID (x,y)
[0178] Wherein F0 represents the feature of the input image, L triplet (c,p,n) represents the triplet loss of the image with input image feature F0, L ID (x,y) represents the cross entropy loss of the image with input image feature F0, L Loss (F0) represents the overall loss of the image with input image feature F0.
[0179] S25, the global features, the first noise patch filtering features, the second noise patch filtering features, the first salient feature extraction features, the second salient feature extraction features obtained by S21 are respectively calculated to obtain the overall loss function expression as follows:
[0180] L Total =λ1L Loss (F1)+λ2L Loss (F2)+λ3L Loss (F3)
[0181] +λ4L Loss (F4)+λ5L Loss (F5)
[0182] Wherein λ1, λ2, λ3, λ4, λ5 represent the first, second, third, fourth and fifth weights of the loss function in the overall loss function, F1 represents the global feature, F2 represents the first noise patch filtering feature, F3 represents the second noise patch filtering feature, F4 represents the first salient feature extraction feature, and F5 represents the second salient feature extraction feature.
[0183] Step S3, using the trained self-guided feature mining network for vehicle re-identification, sequentially inputting the images in the gallery into the self-guided feature mining network that has been trained and converged to obtain the global feature, the first noise patch filtering feature, the second noise patch filtering feature, the first salient feature extraction feature and the second salient feature extraction feature, and the global feature obtained by using the gallery input image is represented as the feature of the gallery input image. The query image is input into the self-guided feature mining network that has been trained and converged to obtain the global feature, the first noise patch filtering feature, the second noise patch filtering feature, the first salient feature extraction feature and the second salient feature extraction feature, and the global feature obtained by using the query image is represented as the feature of the query image. The features of the query image and the features of the images in the gallery are sequentially calculated using a distance measurement function (Euclidean distance function or cosine distance function) to calculate the distance between the query image and the images in the gallery, and the calculation results of the distance between the query image and the images in the gallery are arranged in order from small to large, and the 10 images with the smallest distance are selected from the gallery as the re-identification result according to the arrangement result.
[0184] The experimental results of the embodiment 2 show that, compared with the case where the self-guided feature mining network does not use the noise patch filtering branch and the salient feature extraction branch, the case where the self-guided feature mining network uses the noise patch filtering branch and the salient feature extraction branch has an improvement of 9.6 in the mAP index on the Small test subset, an improvement of 11.2 in the Rank-1 index on the Middle test subset, and an improvement of 12.6 in the Rank-1 index on the Large test subset, further verifying the effectiveness of the present application.
[0185] The above embodiments are preferred embodiments of the present application, but the embodiments of the present application are not limited by the above embodiments, and any changes, modifications, substitutions, combinations and simplifications made without departing from the spirit and principles of the present application shall be equivalent replacement modes and shall be included in the protection scope of the present application.
Claims
1. A vehicle re-identification method based on self-guided feature mining network, characterized in that, The vehicle re-identification method comprises the following steps: S1, a self-guided feature mining network is constructed, the self-guided feature mining network comprises a backbone network and a global branch, a noise patch filtering branch and a salient feature extraction branch; wherein the connection relationship from input to output in the noise patch filtering branch is as follows: The input of the noise patch filtering branch is transmitted to the thirteenth conversion layer, the thirteenth conversion layer is connected with the noise patch filtering layer, the noise patch filtering layer is respectively connected with the first noise patch filtering feature and the first global average pool, the first noise patch filtering feature is respectively connected with the first triple loss function layer and the first BNNECK layer, the first BNNECK layer is connected with the first cross-entropy loss function layer, the first global average pool is connected with the second noise patch filtering feature, the second noise patch filtering feature is respectively connected with the second triple loss function layer and the second BNNECK layer, the second BNNECK layer is connected with the second cross-entropy loss function layer, the sum of the first triple loss function layer and the first cross-entropy loss function layer is added to the sum of the second triple loss function layer and the second cross-entropy loss function layer, and then the sum is added as the output of the noise patch filtering branch; In the noise patch filtering layer, the score matrix A of the self-attention head is calculated by the multi-head self-attention mechanism of the Attention 13 layer in the thirteenth conversion layer (N+1)*(N+1) As follows: A = [a0; a1; a2;... an;... ; a i ... ; a N ] wherein i=0, 1, 2...N is the position encoding of the backbone network image position encoding embedding layer, the position encoding 0 corresponds to the position encoding of the feature Cls embedded by the backbone network Cls embedding layer, the position encoding i=1, 2...N corresponds to the position encoding of the i-th image patch of the backbone network image patch layer, a i The N+1-dimensional vector composed of the attention score of the image patch with position encoding i and the feature Cls with position encoding 0, N image patches with position encoding 1 to N respectively, is expressed as follows: a i = [a i,0 ; a i,1 ; a i,2 ;..a i,j ....; a i,N ] where j = 0, 1, 2...N, a i,j denotes the attention score value of the image patch with position encoding i and the image patch with position encoding j; The multi-head self-attention of the Attn layer Attention13 in the thirteenth conversion layer has K feature attention heads in common, for any one of the K feature attention heads, a score matrix A can be calculated, the average score matrix Aavg is obtained by averaging the score matrices of all feature attention heads, the average score matrix Aavg has the same expression as the score matrix A, and the difference lies in that the values in the matrix are different; According to the feature Cls and the attention score of the image patch of the position encoding 1, 2...N in the average score matrix Aavg, the N average attention scores are sorted from large to small, and M position encodings with larger average attention scores are selected, wherein M is a positive integer less than N; The feature Cls with the position encoding of 0 is input to the first noise patch filtering feature, and the image patch corresponding to the M position encodings with larger average attention scores is input to the first global average pool; S2, input vehicle image data set, train the self-guided feature mining network; S3, use the trained self-guided feature mining network for vehicle re-identification.
2. The vehicle re-identification method based on self-guided feature mining network according to claim 1, characterized in that: The connection relationship from input to output in the backbone network is as follows: Image block layer, Cls embedding layer, position encoding embedding layer, DP layer Dropout, first conversion layer, second conversion layer, third conversion layer, fourth conversion layer, fifth conversion layer, sixth conversion layer, seventh conversion layer, eighth conversion layer, ninth conversion layer, tenth conversion layer, eleventh conversion layer; Among them, the first conversion layer, the second conversion layer, the third conversion layer, the fourth conversion layer, the fifth conversion layer, the sixth conversion layer, the seventh conversion layer, the eighth conversion layer, the ninth conversion layer, the tenth conversion layer and the eleventh conversion layer are conversion layers with the same structure, and the specific structure of the conversion layer is as follows: The connections from input to output in the global branch are as follows: 3.The vehicle re-identification method based on self-guided feature mining network according to claim 1, characterized in that, The connections from input to output in the global branch are as follows: The input of the global branch is transmitted to the twelfth conversion layer, the twelfth conversion layer connects the global features, the global features are respectively connected to the triple loss function layer and the BNNECK layer, the BNNECK layer is connected to the cross-entropy loss function layer, and the output of the triple loss function layer and the output of the cross-entropy loss function layer are added as the output of the global branch. 4.The vehicle re-identification method based on self-guided feature mining network according to claim 1, characterized in that, The connections from input to output in the global branch are as follows: The input of the global branch is transmitted to the twelfth conversion layer, the twelfth conversion layer connects the global features, the global features are respectively connected to the triple loss function layer and the BNNECK layer, the BNNECK layer is connected to the cross-entropy loss function layer, and the output of the triple loss function layer and the output of the cross-entropy loss function layer are added as the output of the global branch. 5.The vehicle re-identification method based on mining network with self-bootstrapped features according to claim 4, characterized in that, In the significant feature extraction layer, The score matrix A e R is calculated by the multi-head self-attention mechanism of the Attention 14 layer in the fourteenth conversion layer (N+1)*(N+1) As follows: A = [a0; ai ; a2;... an ; a i ... ; an ; a N ] Among them, i=0, 1, 2...N is the position code embedded in the backbone network image position code embedding layer, position code 0 corresponds to the position code of the feature Cls embedded in the backbone network Cls embedding layer, position code i=1, 2...N corresponds to the position code of the i-th image patch in the backbone network image block layer, a i Represents an N+1-dimensional vector consisting of the image patch with position encoding i, the feature Cls with position encoding 0, and the attention scores of N image patches with position encodings 1 to N. The expression is as follows: a i = [a i,0 ; a i,1 ; a i,2 ;..a i,j ....; a i,N ] where j = 0, 1, 2...N, a i,j denotes the attention score value of the image patch with position code i and the image patch with position code j; In the fourteenth conversion layer, the multi-head self-attention of the Attn layer Attention13 has K feature attention heads, and for any one of the K feature attention heads, a score matrix A can be calculated, and K score matrices A are obtained for the K feature attention heads; According to the score matrix A l a0 gets the attention scores of the feature Cls and the image patches with position codes 1, 2...N, sorts the N attention scores from large to small, and selects the position code with the largest attention score, where A l represents the lth feature attention head, l∈(1,2...K), K feature attention heads get K position encodings; The feature Cls with position encoding of 0 is input to the second noise patch filtering feature, and the K image patches corresponding to the position encoding are input to the second global average pool. 6.The vehicle re-identification method based on mining a network using a self-guided feature according to claim 1, wherein, The step S2 process is as follows: S21, construct a vehicle re-identification dataset, use the PK sampling method to batch sample the dataset, the PK sampling method randomly samples P classes of vehicles in the dataset for each batch of images input to the self-guided feature mining network, selects K images for each class of vehicle, and then inputs the vehicle images in batches to the self-guided feature mining network to obtain global features, first noise patch filtering features, second noise patch filtering features, first significant feature extraction features, and second significant feature extraction features; S22, input the global feature, the first noise patch filtering feature, the second noise patch filtering feature, the first salient feature extraction feature and the second salient feature extraction feature obtained in step S21 into a triplet loss function layer, a first triplet loss function layer, a second triplet loss function layer, a third triplet loss function layer and a fourth triplet loss function layer to calculate a triplet loss, in a batch, select an image as an anchor image, images belonging to the same vehicle ID as the anchor image are called positive samples, and images not belonging to the same vehicle ID as the anchor image are called negative samples; The function definition of the triplet loss is as follows: L triplet (c,p, n) = log(l + exp(max(D cp )-min(D cn ))) where c denotes an anchor image, p denotes an image that forms a positive sample with c, n denotes an image that forms a negative sample with c, D cp denotes a distance between the anchor image and the positive sample, D cn denotes a distance between the anchor image and the negative sample, max(D cp ) denotes a maximum value, min(D cn ) denotes a minimum value; S23, input the global feature, the first noise patch filtering feature, the second noise patch filtering feature, the first salient feature extraction feature and the second salient feature extraction feature obtained in step S21 into a cross-entropy loss function layer, a first cross-entropy loss function layer, a second cross-entropy loss function layer, a third cross-entropy loss function layer and a fourth cross-entropy loss function layer to calculate a cross-entropy loss; The function definition of the cross-entropy loss is as follows: wherein x represents a real label of the image, x t represents a real label of the image being the tth ID, y represents a probability value of the model identifying the image label, y t represents a probability value of the model identifying the image being the tth ID, Q represents the number of ID categories of the image dataset; S24, add the triplet loss function and the cross-entropy loss function to obtain a total loss function value: L Loss (F0) = L triplet (c, p, n) + L ID (x, y) where F0represents the input image features, L triplet (c, p, n) represents the triplet loss for images with input image features F0, L ID (x, y) represents the cross-entropy loss for images with input image features F0, L Loss (F0) represents the overall loss for images with input image features F0. S25, calculate the loss of the global feature, the first noise patch filtering feature, the second noise patch filtering feature, the first salient feature extraction feature and the second salient feature extraction feature obtained in step S21 to obtain an overall loss function expression as follows: L Total = λ1L Loss (F1)+λ2L Loss (F2)+λ3L Loss (F3) + λ4L Loss (F4) + λ5L Loss (F5) Wherein λ1, λ2, λ3, λ4, λ5 represent the first, second, third, fourth and fifth weights of the loss function in the overall loss function, F1 represents the global feature, F2 represents the first noise patch filtering feature, F3 represents the second noise patch filtering feature, F4 represents the first salient feature extraction feature, and F5 represents the second salient feature extraction feature. 7.The vehicle re-identification method based on mining network with self-bootstrapped features according to claim 1, wherein, The step S3 process is as follows: Input the images in the gallery into the self-guided feature mining network which has been trained and converged in sequence to obtain the global feature, the first noise patch filtering feature, the second noise patch filtering feature, the first salient feature extraction feature and the second salient feature extraction feature, the global feature obtained by using the gallery input image is represented as the feature of the gallery input image; input the query image into the self-guided feature mining network which has been trained and converged to obtain the global feature, the first noise patch filtering feature, the second noise patch filtering feature, the first salient feature extraction feature and the second salient feature extraction feature, the global feature obtained by using the query image is represented as the feature of the query image; sequentially calculate the distance between the query image and the images in the gallery by using the distance measurement function on the feature of the query image and the feature of the images in the gallery, arrange the calculation results of the distance between the query image and the images in the gallery from small to large in order, and select the 10 images with the smallest distance from the gallery as the re-identification result according to the arrangement result. 8.The vehicle re-identification method based on mining a network with self-bootstrapped features according to claim 7, wherein, The distance measurement function adopts the Euclidean distance function or the cosine distance function.
Citation Information
Patent Citations
Vehicle attribute identification method and device based on neural network, equipment and medium
CN109635656A
Vehicle re-identification method, system, device, and medium
CN110516583A