Lightweight pedestrian re-identification method and system based on random color discarding and attention
Through random color discarding and attention mechanism, combined with embedded cascade self-attention module, the problem of insufficient robustness caused by color deviation in pedestrian re-identification is solved, and the recognition effect and model robustness are improved.
Patent Information
- Application Number
- CN202410950010.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-16
- Publication Date
- 2024-09-13
- Estimated Expiration
- 2044-07-16
AI Technical Summary
Existing pedestrian re-identification methods have insufficient recognition robustness and generalization due to deviations in color features in complex environments, increasing the possibility of misrecognition and reducing recognition.
A lightweight pedestrian re-identification method based on random color discarding and attention is used, image grayscale processing is performed through the LAGT algorithm, combined with embedded cascade self-attention modules (SSAM and CSAM) to extract features, and label smoothing is used Identity loss for model optimization training.
It effectively suppresses the negative impact of color deviation on the recognition effect, balances the weight of the neural network on color and non-color features, and improves the recognition effect and the robustness of the model, especially in complex backgrounds and occlusion situations.
Smart Images

Figure CN118506407B
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of pedestrian re-identification, and in particular to a lightweight pedestrian re-identification method and system based on random color discarding and attention. Background Art
[0002] With the rapid development of deep learning technology, significant progress has been made in the field of person re-identification. Residual network (ResNet) has been applied to the field of person re-identification and has achieved remarkable results. ResNet solves the gradient vanishing problem in deep network training by introducing residual connections, making the network easier to optimize.
[0003] The robustness and generalization of the recognition methods in the existing technology are not high. In order to improve the robustness and generalization of the recognition system, some data enhancement strategies such as color enhancement are widely used. Color information, as an important distinguishing feature of pedestrians, can enrich the expression of pedestrian characteristics, especially when facing complex scenes such as lighting changes. The pedestrian re-identification system that integrates color information has more obvious advantages than traditional methods in complex environments. However, in some cases, the color deviation generated by the color features limits the model from making correct predictions to a certain extent, which is mainly reflected in two aspects: first, the color difference between the images of the same pedestrian increases the possibility of misidentification; second, the color deviation weakens the feature difference between different pedestrian images, reducing the system's recognition. At present, there is little research on reducing color deviation to improve the robustness of the model. Summary of the invention
[0004] In order to solve the deficiencies mentioned in the above background technology, the object of the present invention is to provide a lightweight pedestrian re-identification method and system based on random color discarding and attention.
[0005] In a first aspect, the purpose of the present invention can be achieved by the following technical solution: a lightweight pedestrian re-identification method based on random color discarding and attention, the method comprising the following steps:
[0006] receiving image data, and preprocessing the image data to obtain preprocessed image data;
[0007] The preprocessed image data is input into the pre-established OSNet embedded with a cascaded self-attention module, features are extracted, and image features are output;
[0008] Classify the image features through the fully connected layer, map the image features to the corresponding category labels, and obtain the classified image features;
[0009] The classified image features are used to calculate the identity loss with label smoothing, and the gradient is updated through back-propagation to optimize and train the pre-established lightweight person re-identification network model to obtain the optimized lightweight person re-identification network model.
[0010] A test set of the pedestrian re-identification dataset is obtained, and the test set of the pedestrian re-identification dataset is input into the optimized lightweight pedestrian re-identification network model, and the lightweight pedestrian re-identification result is output.
[0011] In combination with the first aspect, in some implementations of the first aspect, the method further includes: the process of preprocessing the image data includes:
[0012] Data enhancement: Random flipping, random erasing, and LAGT-based random color discarding strategies are used to obtain preprocessed image data.
[0013] In combination with the first aspect, in some implementations of the first aspect, the method further includes: the LAGT-based random color discarding strategy grayscales the image using an aggregated grayscale transformation, and the calculation process is as follows:
[0014]
[0015] in, , and represents the red, green, and blue channels, , , , and Represent the pixel values at specific positions of the red channel, green channel, and blue channel respectively, and the weight coefficient is expressed as , is the height of the image, The width of the image.
[0016] In combination with the first aspect, in some implementations of the first aspect, the method further includes: an implementation process of the LAGT is as follows:
[0017] During data loading, a random identity sampler is used to randomly select Each identity selects Zhang Xingren, the image training batch size is , the set is represented as ,in represents the first images, Indicates The sample labels of the images are given by LAGT with probability Convert the original image into a grayscale image, randomly select a rectangular area from the original image, and replace the grayscale value of the corresponding position area of the grayscale image with the original image. Given an original pedestrian picture , with probability After performing aggregate grayscale transformation, the corresponding AGT image is defined as:
[0018]
[0019] Original Image Size :
[0020]
[0021] in, is the height of the image, is the width of the image;
[0022] Area of the AGT rectangle :
[0023]
[0024] in, , is the minimum and maximum value of the ratio of the AGT image area to the original image area;
[0025] Aspect ratio of the AGT rectangle and high He Kuan :
[0026]
[0027]
[0028]
[0029] in , The maximum and minimum values of the aspect ratio of the grayscale transformation rectangle;
[0030] In the original image Initialize a point randomly , the following conditions are met:
[0031]
[0032] is the height of the image, is the width of the image;
[0033] The selected LAGT regions are :
[0034]
[0035] For each , the selected LAGT region rect for:
[0036]
[0037] The LAGT algorithm can finally be expressed as:
[0038]
[0039] in, Yes The pixels in the corresponding rectangle of the image are given to image, is the sample after LAGT transformation.
[0040] In combination with the first aspect, in certain implementations of the first aspect, the method further includes: the embedded cascaded self-attention module includes SSAM and CSAM.
[0041] In combination with the first aspect, in some implementations of the first aspect, the method further includes: the intermediate feature map extracted by the SSAM from the pre-processed image data is ,in is the number of feature channels, is the size of the intermediate feature map, Perform a 1×1 convolution operation and get , , ,in ,right , , After the reshaping operation, the spatial self-attention affinity matrix is obtained , ,in , the process is expressed as follows:
[0042]
[0043] in Indicates the space Position to The attention weight of each position is and After multiplying the embedded attention weights, they are superimposed with the original feature map pixels to obtain the spatial self-attention weighted feature map :
[0044]
[0045] in is a hyperparameter that adjusts the influence of SSAM, and weights the feature map of spatial self-attention Processed through CSAM.
[0046] In combination with the first aspect, in some implementations of the first aspect, the method further includes: the CSAM inputs a feature map with spatial self-attention weights , after the reshaping operation, the channel self-attention affinity matrix is obtained , , the process is expressed as follows:
[0047]
[0048] in Indicates channel For Channel The attention weight for , initialize a Same size and all values The maximum matrix , the new channel self-attention weight affinity matrix is , ,Will and After multiplying the embedded attention weights, The corresponding position pixels are superimposed to obtain the channel self-attention weighted feature map ;
[0049]
[0050] in It is a hyperparameter that adjusts the impact of CSAM;
[0051] The feature map weighted by channel self-attention After passing through the OSNet backbone network, the image features are obtained.
[0052] In combination with the first aspect, in some implementations of the first aspect, the method further includes: using the classified image features to calculate the identity loss with label smoothing L ID The calculation process:
[0053]
[0054] in represents the pedestrian category, represents the number of pedestrian images in the training set, is the true label, is the predicted logical value of the network.
[0055] In a second aspect, in order to achieve the above-mentioned object, the present invention discloses a lightweight pedestrian re-identification system based on random color discarding and attention, comprising:
[0056] An image processing module, used for receiving image data, preprocessing the image data, and obtaining preprocessed image data;
[0057] The feature extraction module is used to input the pre-processed image data into the pre-established OSNet embedded with the cascaded self-attention module, extract features, and output image features;
[0058] The image classification module is used to classify image features through the fully connected layer, map the image features to corresponding category labels, and obtain classified image features;
[0059] The model training module is used to calculate the identity loss with label smoothing using the classified image features, update the gradient through back propagation, optimize and train the pre-established lightweight person re-identification network model, and obtain the optimized lightweight person re-identification network model;
[0060] The pedestrian re-identification module is used to obtain a test set of the pedestrian re-identification dataset, input the test set of the pedestrian re-identification dataset into the optimized lightweight pedestrian re-identification network model, and output the lightweight pedestrian re-identification result.
[0061] A terminal device includes a memory, a processor, and a computer program stored in the memory and capable of running on the processor. The memory stores a computer program capable of running on the processor. When the processor loads and executes the computer program, the lightweight pedestrian re-identification method based on random color discarding and attention as described above is adopted.
[0062] Beneficial effects of the present invention:
[0063] The present invention adopts OSNet as the backbone network of the model, which greatly reduces the number of parameters;
[0064] For pedestrians wearing the same color clothing, when the background color and the pedestrian color are very different, the present invention can effectively suppress the negative impact of color deviation on the recognition effect through the LAGT algorithm, encourage the model to discover and focus on feature information that is not related to color, balance the weights of the neural network on color features and non-color features, and improve the baseline recognition effect;
[0065] For pedestrian images with complex backgrounds and occlusions, the present invention can effectively aggregate the pedestrians themselves through the cascaded self-attention module and suppress irrelevant backgrounds, thereby making the extracted features more refined and discriminative, thereby improving the Baseline recognition effect. BRIEF DESCRIPTION OF THE DRAWINGS
[0066] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, for those skilled in the art, other drawings can be obtained based on these drawings without creative work.
[0067] Figure 1 It is a schematic flow chart of the method of the present invention;
[0068] Figure 2 The overall framework diagram of the lightweight pedestrian re-identification network based on random color discarding and self-attention of the present invention;
[0069] Figure 3 Examples of the original sample and the LAGT sample of the present invention;
[0070] Figure 4 SSAM used in the present invention;
[0071] Figure 5 CSAM used in the present invention;
[0072] Figure 6 The retrieval results of the model trained using RGB images and original grayscale transformed images on the Market-1501 dataset;
[0073] Figure 7 This is an example of a pedestrian image with a green background in the dataset;
[0074] Figure 8 The retrieval results of the model trained using RGB images and original grayscale transformed images for green background pedestrian images on the Market-1501 dataset;
[0075] Fig. 9 Retrieval results of the model trained on RGB images and grayscale images with different grayscale transformations on the Market-1501 dataset;
[0076] Fig.10 This is the visual comparison result of the pedestrian re-identification under color deviation of the present invention;
[0077] Fig.11 This is the visual comparison result of the pedestrian re-identification under complex background and occlusion of the present invention;
[0078] Fig.12 It is a schematic diagram of the system structure of the present invention. DETAILED DESCRIPTION
[0079] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0080] Embodiment 1:
[0081] The following is an introduction to the relevant terms involved in the embodiments of the present application:
[0082] Grayscale transformation refers to a method of changing the grayscale value of each pixel in the source image point by point according to a certain target condition and a certain transformation relationship. The purpose is to improve the image quality and make the image display effect clearer. Image grayscale transformation processing is a very basic and direct spatial domain image processing method in image enhancement processing technology, and is also an important part of image digitization software and image display software.
[0083] The self-attention mechanism is a special attention mechanism that allows the model to consider the relationship between each element in the sequence and all other elements when processing a sequence. This mechanism can help the model better understand the contextual information in the sequence, so as to process sequence data more accurately. (Sequence data is a data type in which the elements exist in a specific order. Each element has a specific position, and the order relationship between the positions has an important impact on the meaning of the data and how it is processed)
[0084] like Figure 1 As shown, a lightweight pedestrian re-identification method based on random color discarding and attention is characterized in that the method comprises the following steps:
[0085] receiving image data, and preprocessing the image data to obtain preprocessed image data;
[0086] The process of preprocessing image data includes:
[0087] Data enhancement: Random flipping, random erasing, and random color discarding strategies based on LAGT are used to obtain preprocessed image data.
[0088] The random color discarding strategy based on LAGT uses aggregated grayscale transformation to grayscale the image. The calculation process is as follows:
[0089]
[0090] in, , and represents the red, green, and blue channels, , , , and Represent the pixel values at specific positions of the red channel, green channel, and blue channel respectively, and the weight coefficient is expressed as .
[0091] The LAGT algorithm is implemented as follows: During the data loading process, a random identity sampler is used to randomly select Each identity selects Zhang Xingren, the image training batch size is . This set is represented by ,in represents the first images, Indicates The sample labels of the images. LAGT is based on probability Convert the original image into a grayscale image, randomly select a rectangular area from the original image, and replace the grayscale value of the corresponding position area of the grayscale image with the original image. , with probability Perform aggregate grayscale transformation, and the corresponding AGT image is defined as:
[0092]
[0093] Original Image Size :
[0094]
[0095] in, is the height of the image, The width of the image.
[0096] Area of the AGT rectangle :
[0097]
[0098] in, , are the minimum and maximum values of the ratio of the AGT image area to the original image area.
[0099] Aspect ratio of the AGT rectangle and high He Kuan :
[0100]
[0101]
[0102]
[0103] in , The maximum and minimum values of the aspect ratio of the grayscale transformation rectangle.
[0104] In the original image Initialize a point randomly , the following conditions are met:
[0105]
[0106] is the height of the image, is the width of the image;
[0107] The selected LAGT regions are :
[0108]
[0109] For each , the selected LAGT region is:
[0110]
[0111] The LAGT algorithm can finally be expressed as:
[0112]
[0113] in, Yes The pixels in the corresponding rectangle of the image are given to image, is the sample after LAGT transformation. The original sample and LAGT sample are as follows Figure 3 shown.
[0114] The preprocessed image data is input into the pre-established OSNet embedded with a cascaded self-attention module, features are extracted, and image features are output;
[0115] The embedded cascade self-attention modules include SSAM and CSAM, respectively. Figure 4 , 5 As shown;
[0116] SSAM can help the network aggregate semantically related features in space and highlight individual features, making the network pay more attention to the details of pedestrians.
[0117] The intermediate feature map extracted by the neural network is ,in is the number of feature channels, is the size of the intermediate feature map. Perform a 1×1 convolution operation and get , , In the process of inferring the attention matrix, channel dimensionality reduction can extract more refined and abstract feature representations, reducing the complexity of calculation without affecting the performance of the network. .right , , After the reshape operation, the spatial self-attention affinity matrix is obtained , ,in , the process is expressed as follows:
[0118]
[0119] in Indicates the space Position to The attention weight of each position. and After multiplying the embedded attention weights, they are superimposed with the original feature map pixels to obtain the spatial self-attention weighted feature map :
[0120]
[0121] in is a hyperparameter that adjusts the impact of SSAM.
[0122] CSAM can help the network learn the correlation information between channels and further extract effective feature representations between different channels in the image.
[0123] For input feature maps with spatial self-attention weights , after the reshape operation, the channel self-attention affinity matrix is obtained , , the process is expressed as follows:
[0124]
[0125] in Indicates channel For Channel The attention weight of . , we use the Normalize method to initialize a Same size and all values The maximum matrix , the new channel self-attention weight affinity matrix is , This method effectively avoids the maximum activation value from being affected by noise or outliers. By subtracting the maximum activation value from each channel, it encourages other channels to provide complementary information, increases the model's perceptual diversity for different feature channels, and thus improves the robustness of the model. and After multiplying the embedded attention weights, The corresponding position pixels are superimposed to obtain the channel self-attention weighted feature map :
[0126]
[0127] in is a hyperparameter that adjusts the impact of CSAM.
[0128] After passing through the OSNet backbone network with a cascaded self-attention module, the output feature map is of size b×512×16×8, where b is the batch size, 512 is the number of channels, 16 is the feature map height, and 8 is the feature map width.
[0129] Classify the image features through the fully connected layer, map the image features to the corresponding category labels, and obtain the classified image features;
[0130] The feature score of size b×N, where N is the number of categories;
[0131] The classified image features are used to calculate the identity loss with label smoothing, and the gradient is updated through back-propagation to optimize and train the pre-established lightweight person re-identification network model to obtain the optimized lightweight person re-identification network model.
[0132] Use the classified image features to calculate the identity loss with label smoothing L ID The calculation process:
[0133]
[0134] in represents the pedestrian category, represents the number of pedestrian images in the training set, is the true label, is the predicted logical value of the network.
[0135] Label smoothing changed The structure:
[0136]
[0137] in , encouraging the model not to trust the training set too much and increase generalization ability.
[0138] Obtain a pedestrian re-identification dataset, input the pedestrian re-identification dataset into the optimized lightweight pedestrian re-identification network model, and output the lightweight pedestrian re-identification result.
[0139] The test was conducted on two major pedestrian re-identification datasets, Market-1501 and DukeMTMC-reID. The AMSGrad optimizer was used, the initial learning rate was set to 0.0015, and the cosine annealing strategy was used to update the learning rate. The batch size and weight decay were 64 and 5e-4, respectively. The training epoch was set to 250, the probability of the LAGT algorithm was adjusted to 0.6, and the hyperparameters affected by the SSAM and CSAM modules were and is 1, label-smoothed ID Loss is used for supervision, and cosine distance is used for pedestrian matching.
[0140] Specifically, the present invention is further described below by way of embodiments:
[0141] The experimental environment parameters are shown in Table 1.
[0142] Table 1
[0143]
[0144] In the experiment, the present invention selects OSNet pre-trained on ImageNet as the Baseline. In order to verify the influence of LAGT and SAM used alone and in combination on the network model, ablation experiments are performed on the two datasets of Market-1501 and DukeMTMC-reID. The results are shown in Table 2. As can be seen from Table 2, LAGT and SAM have a certain improvement on the Baseline. When the two modules are added to the Baseline at the same time, LAGT weakens the negative impact of color deviation on model recognition, and SAM enables the model to extract more fine-grained features in space and channels. Therefore, the network achieves the best recognition performance. In the Market-1501 dataset, Rank-1 and mAP reach 95.5% and 87.7% respectively, which is 0.7% and 1.0% higher than the Baseline. In the DukeMTMC-reID dataset, Rank-1 and mAP reach 89.2% and 77.2% respectively, which is 0.8% and 0.5% higher than the Baseline. In addition, our network is relatively light, with only 2.8M parameters, which is convenient for application and deployment.
[0145] Table 2
[0146]
[0147] In order to verify the effectiveness of the present invention, we compared it with the previous person re-identification methods in recent years on the Market-1501 and DukeMTMC-reID datasets, including PCB+RPP based on local feature extraction, HA-CNN based on attention mechanism, Mancs, AANet, and IANet. In addition, we also selected some other methods with better performance for comparison, such as BDB, BoT, etc. The statistical results are shown in Table 3.
[0148] As can be seen from Table 3, the Rank-1 index of the present invention reached 95.5% and 89.2% on the two data sets, and the mAP index reached 87.7% and 77.2% respectively. The present invention only focuses on the extraction of global features. Compared with the PCB+RPP network for local feature extraction, the Rank-1 and mAP on Market-1501 increased by 2.4% and 6.7%, respectively, and on DukeMTMC-reID increased by 6.3% and 9.7%, respectively. Compared with the complex attribute attention network AANet, the Rank-1 and mAP on Market-1501 increased by 1.6% and 4.3%, respectively, and on DukeMTMC-reID increased by 1.5% and 2.9%, respectively. Compared with the powerful baseline BoT method that only focuses on global features, the present invention has the advantage of small parameters, and the Rank-1 and mAP on Market-1501 increased by 1.0% and 1.8%, respectively, and on DukeMTMC-reID increased by 2.8% and 0.8%, respectively.
[0149] Table 3
[0150]
[0151] Table 4 shows the comparison results of the parameters of the network of the present invention and the mainstream network. It can be seen from the table that the network of this paper adds LAGT and SAM modules on the basis of OSNet, which effectively improves the recognition performance of the model with only a small increase in parameters and calculation time. Compared with the ResNet network, the model parameters of the present invention are streamlined, the computing resources consumed are less, the training time of the model is shortened, the model can adapt to the task more quickly, and the efficiency of the model in practical applications is improved. Compared with OSNet, the present invention improves the recognition accuracy and generalization ability of pedestrians while only increasing the number of parameters by 0.6M, indicating that the designed network has good lightweight.
[0152] Table 4
[0153]
[0154] The dataset contains a variety of complex and variable color deviations, which makes the model less robust when dealing with color changes. To solve this problem, it is particularly important to balance the weights between color features and other key discriminant features. Figure 6 The retrieval results of the model trained with RGB images and grayscale images on the Market-1501 dataset are shown respectively. It can be seen from the figure that when there is a color deviation between the query image and the library image, it will affect the retrieval result. After ignoring the color information, the retrieval effect of the sample is improved to a certain extent.
[0155] Based on this problem, training images with local grayscale images are generated by random color discarding, which improves the robustness of the model to color deviation. The key step in the RCD strategy is to replace the local color image with its corresponding local grayscale image in the image. The grayscale transformation used is:
[0156]
[0157] in, , , Represent the red, green, and blue channels respectively. As can be seen from the formula, in order to reflect the sensitivity of the human eye to different colors, different conversion weights are set for the red, green, and blue channels. This conversion strategy is more in line with the intuitive image of human vision, but there are the following problems in the pedestrian re-identification task based on deep learning networks:
[0158] (1) Different from the human eye’s sensitivity to color, the network model has the same recognition ability for the information of the three color channels. Therefore, the color weight allocation strategy based on the human eye’s visual perception characteristics has certain limitations.
[0159] (2) In the pedestrian dataset, according to people’s dressing habits, there are fewer pedestrians wearing green, while green features often appear in the background information of the image, such as Figure 7 As shown in the figure, trees and lawns are the green background information of pedestrian images. When the green channel is assigned the largest transition weight, the model's generalization ability for background information will be increased while the generalization ability for pedestrians themselves will be ignored, resulting in recognition bias.
[0160] To address this problem, corresponding experimental verification was carried out, such as Figure 8 As shown in the figure, when the color features of the image background and the color features of the pedestrians deviate greatly, especially for green background images, when the original grayscale transformation strategy is adopted, the larger transformation weight of the green channel will improve the model's generalization ability for the background, ignoring the generalization ability for the pedestrians themselves, thereby introducing deviations and reducing the recognition effect.
[0161] According to the above analysis, the present invention will design a color discarding strategy that is more suitable for the learning model based on RCD, change the original grayscale transformation, and the new transformation method should meet the following three requirements:
[0162] (1) Reduce the differences in the three color channels of the network model, weaken the negative impact of color deviation on recognition, and avoid generating additional deviations;
[0163] (2) After color conversion, the more stable structure and texture features of the original image should be retained to reduce distortion.
[0164] (3) The improved grayscale transformation method does not change the learning strategy, can avoid overfitting during training, and save computing resources, achieving the goal of being lightweight and effective.
[0165] Based on the analysis of the grayscale transformation principle described above, the weighted average method is used to optimize the grayscale transformation strategy by carefully balancing the transformation weights assigned to the red, green, and blue channels. Pedestrian image size, Aggregated Grayscale Transformation (AGT) formula is as follows:
[0166]
[0167] in, , and represents the red, green, and blue channels, , . , and Represents the pixel value at a specific position of the red channel, green channel, and blue channel respectively. The weight coefficient is expressed as , is a constant balancing factor, choose In the above formula, uniform weights are assigned to the three channels during the conversion from RGB image to grayscale image.
[0168] In order to preliminarily verify the effectiveness of the improvement, the retrieval results of the model trained on Market-1501 using RGB images and grayscale images generated by different grayscale transformations are shown, as follows: Fig. 9 As shown, , , The retrieval results are shown when the input is an RGB image, after the original grayscale transformation, and after the average grayscale transformation of this paper. The results show that AGT does not introduce additional deviations while eliminating color deviations, and retains the stable structural texture features of RGB images. The recognition effect is better than the original grayscale transformation.
[0169] Embodiment 2: In the second aspect, as Fig.12 As shown, in order to achieve the above-mentioned purpose, the present invention discloses a lightweight pedestrian re-identification system based on random color discarding and attention, comprising:
[0170] The image processing module 11 is used to receive image data and pre-process the image data to obtain pre-processed image data;
[0171] A feature extraction module 12 is used to input the pre-processed image data into a pre-established OSNet embedded with a cascaded self-attention module, extract features, and output image features;
[0172] An image classification module 13 is used to classify image features through a fully connected layer, map the image features to corresponding category labels, and obtain classified image features;
[0173] The model training module 14 is used to calculate the identity loss with label smoothing using the classified image features, update the gradient by back propagation, optimize and train the pre-established lightweight person re-identification network model, and obtain the optimized lightweight person re-identification network model;
[0174] The pedestrian re-identification module 15 is used to obtain a test set of the pedestrian re-identification data set, input the test set of the pedestrian re-identification data set into the optimized lightweight pedestrian re-identification network model, and output the lightweight pedestrian re-identification result.
[0175] Based on the same inventive concept, the present invention also provides a computer device, which includes: one or more processors, and a memory for storing one or more computer programs; the program includes program instructions, and the processor is used to execute the program instructions stored in the memory. The processor may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components, etc. It is the computing core and control core of the terminal, which is used to implement one or more instructions, specifically for loading and executing one or more instructions in a computer storage medium to implement the above method.
[0176] It should be further explained that, based on the same inventive concept, the present invention also provides a computer storage medium, on which a computer program is stored, and the computer program is executed by the processor to execute the above method. The storage medium can adopt any combination of one or more computer-readable media. The computer-readable medium can be a computer-readable signal medium or a computer-readable storage medium. The computer-readable storage medium can be, for example, but not limited to, an electrical, magnetic, optical, electrical, magnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples (non-exhaustive list) of computer-readable storage media include: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present invention, a computer-readable storage medium can be any tangible medium containing or storing a program, which can be used by an instruction execution system, device or device or used in combination with it.
[0177] In the description of this specification, the description with reference to the terms "one embodiment", "example", "specific example", etc. means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present disclosure. In this specification, the schematic representation of the above terms does not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described can be combined in any one or more embodiments or examples in a suitable manner.
[0178] The above shows and describes the basic principles, main features and advantages of the present disclosure. Those skilled in the art should understand that the present disclosure is not limited by the above embodiments, and the above embodiments and descriptions are only for explaining the principles of the present disclosure. Without departing from the spirit and scope of the present disclosure, the present disclosure may have various changes and improvements, and these changes and improvements fall within the scope of the present disclosure to be protected.
Claims
1. A lightweight pedestrian re-identification method based on random color discarding and attention, characterized in that: The method comprises the following steps: receiving image data, and preprocessing the image data to obtain preprocessed image data; The process of preprocessing the image data comprises: Data enhancement: Random flipping, random erasing, and random color discarding strategies based on LAGT are used to obtain preprocessed image data. The LAGT-based random color discarding strategy uses aggregated grayscale transformation to grayscale the image. The calculation process is as follows: in, , and represents the red, green, and blue channels, , , , and Represent the pixel values at specific positions of the red channel, green channel, and blue channel respectively, and the weight coefficient is expressed as , is the height of the image, is the width of the image; The implementation process of LAGT is as follows: During data loading, a random identity sampler is used to randomly select Each identity selects Zhang Xingren, the image training batch size is , the set is represented as ,in represents the first images, Indicates The sample labels of the images are given by LAGT with probability Convert the original image into a grayscale image, randomly select a rectangular area from the original image, and replace the grayscale value of the corresponding position area of the grayscale image with the original image. Given an original pedestrian picture , with probability After performing aggregate grayscale transformation, the corresponding AGT image is defined as: Original Image Size : in, is the height of the image, is the width of the image; Area of the AGT rectangle : in, , is the minimum and maximum value of the ratio of the AGT image area to the original image area; AGT rectangle aspect ratio and high He Kuan : in , The maximum and minimum values of the aspect ratio of the grayscale transformation rectangle; In the original image Initialize a point randomly , the following conditions are met: is the height of the image, is the width of the image; The selected LAGT regions are : For each , the selected LAGT region rect for: The LAGT algorithm can finally be expressed as: in, Yes The pixels in the corresponding rectangle of the image are given to image, is the sample after LAGT transformation; The preprocessed image data is input into the pre-established OSNet embedded with a cascaded self-attention module, features are extracted, and image features are output; The embedded cascaded self-attention modules include SSAM and CSAM; The intermediate feature map extracted by SSAM from the preprocessed image data is: ,in is the number of feature channels, is the size of the intermediate feature map, Perform a 1×1 convolution operation and get , , ,in ,right , , After the reshaping operation, the spatial self-attention affinity matrix is obtained , ,in , the process is expressed as follows: in Indicates the space Position to The attention weight of each position is and After multiplying the embedded attention weights, they are superimposed with the original feature map pixels to obtain the spatial self-attention weighted feature map : in is a hyperparameter that adjusts the influence of SSAM, and weights the feature map of spatial self-attention Processing through CSAM; The CSAM takes as input a feature map with spatial self-attention weights , after the reshaping operation, the channel self-attention affinity matrix is obtained , , the process is expressed as follows: in Indicates channel For Channel The attention weight for , initialize a Same size and all values The maximum matrix , the new channel self-attention weight affinity matrix is , ,Will and After multiplying the embedded attention weights, The corresponding position pixels are superimposed to obtain the channel self-attention weighted feature map ; in It is a hyperparameter that adjusts the impact of CSAM; The feature map weighted by channel self-attention After passing through the OSNet backbone network, the image features are obtained; Classify the image features through the fully connected layer, map the image features to the corresponding category labels, and obtain the classified image features; The classified image features are used to calculate the identity loss with label smoothing, and the gradient is updated through back-propagation to optimize and train the pre-established lightweight person re-identification network model to obtain the optimized lightweight person re-identification network model. A test set of the pedestrian re-identification dataset is obtained, and the test set of the pedestrian re-identification dataset is input into the optimized lightweight pedestrian re-identification network model, and the lightweight pedestrian re-identification result is output.
2. The lightweight pedestrian re-identification method based on random color discarding and attention according to claim 1 is characterized in that: The classified image features are used to calculate the identity loss with label smoothing L ID The calculation process: in represents the pedestrian category, represents the number of pedestrian images in the training set, is the true label, is the predicted logical value of the network.
3. A lightweight pedestrian re-identification system based on random color discarding and attention, characterized by: include: An image processing module, used for receiving image data, preprocessing the image data, and obtaining preprocessed image data; The process of preprocessing the image data comprises: Data enhancement: Random flipping, random erasing, and random color discarding strategies based on LAGT are used to obtain preprocessed image data. The LAGT-based random color discarding strategy uses aggregated grayscale transformation to grayscale the image. The calculation process is as follows: in, , and represents the red, green, and blue channels, , , , and Represent the pixel values at specific positions of the red channel, green channel, and blue channel respectively, and the weight coefficient is expressed as , is the height of the image, is the width of the image; The implementation process of LAGT is as follows: During data loading, a random identity sampler is used to randomly select Each identity selects Zhang Xingren, the image training batch size is , the set is represented as ,in represents the first images, Indicates The sample labels of the images are given by LAGT with probability Convert the original image into a grayscale image, randomly select a rectangular area from the original image, and replace the grayscale value of the corresponding position area of the grayscale image with the original image. Given an original pedestrian picture , with probability After performing aggregate grayscale transformation, the corresponding AGT image is defined as: Original Image Size : in, is the height of the image, is the width of the image; Area of the AGT rectangle : in, , is the minimum and maximum value of the ratio of the AGT image area to the original image area; AGT rectangle aspect ratio and high He Kuan : in , The maximum and minimum values of the aspect ratio of the grayscale transformation rectangle; In the original image Initialize a point randomly , the following conditions are met: is the height of the image, is the width of the image; The selected LAGT regions are : For each , the selected LAGT region rect for: The LAGT algorithm can finally be expressed as: in, Yes The pixels in the corresponding rectangle of the image are given to image, is the sample after LAGT transformation; The feature extraction module is used to input the pre-processed image data into the pre-established OSNet embedded with the cascaded self-attention module, extract features, and output image features; The embedded cascaded self-attention modules include SSAM and CSAM; The intermediate feature map extracted by SSAM from the preprocessed image data is: ,in is the number of feature channels, is the size of the intermediate feature map, Perform a 1×1 convolution operation and get , , ,in ,right , , After the reshaping operation, the spatial self-attention affinity matrix is obtained , ,in , the process is expressed as follows: in Indicates the space Position to The attention weight of each position is and After multiplying the embedded attention weights, they are superimposed with the original feature map pixels to obtain the spatial self-attention weighted feature map : in is a hyperparameter that adjusts the influence of SSAM, and weights the feature map of spatial self-attention Processing through CSAM; The CSAM takes as input a feature map with spatial self-attention weights , after the reshaping operation, the channel self-attention affinity matrix is obtained , , the process is expressed as follows: in Indicates channel For Channel The attention weight for , initialize a Same size and all values The maximum matrix , the new channel self-attention weight affinity matrix is , ,Will and After multiplying the embedded attention weights, The corresponding position pixels are superimposed to obtain the channel self-attention weighted feature map ; in It is a hyperparameter that adjusts the impact of CSAM; The feature map weighted by channel self-attention After passing through the OSNet backbone network, the image features are obtained; The image classification module is used to classify image features through the fully connected layer, map the image features to corresponding category labels, and obtain classified image features; The model training module is used to calculate the identity loss with label smoothing using the classified image features, update the gradient through back propagation, optimize and train the pre-established lightweight person re-identification network model, and obtain the optimized lightweight person re-identification network model; The pedestrian re-identification module is used to obtain a test set of the pedestrian re-identification dataset, input the test set of the pedestrian re-identification dataset into the optimized lightweight pedestrian re-identification network model, and output the lightweight pedestrian re-identification result.
4. A terminal device, comprising a memory, a processor, and a computer program stored in the memory and capable of running on the processor, characterized in that: The memory stores a computer program that can be run on the processor. When the processor loads and executes the computer program, the lightweight pedestrian re-identification method based on random color discarding and attention described in any one of claims 1 to 2 is adopted.
