A pedestrian re-identification method and system based on a dual attention network
By constructing a dual attention network, combining channel and spatial attention mechanisms, and optimizing the loss function, the problem of noise influence in unsupervised pedestrian re-identification is solved, achieving higher recognition accuracy and stability.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- QILU UNIVERSITY OF TECHNOLOGY (SHANDONG ACADEMY OF SCIENCES)
- Filing Date
- 2024-12-27
- Publication Date
- 2026-05-08
AI Technical Summary
Existing unsupervised pedestrian re-identification methods cannot fully eliminate the influence of noise when processing noise information in images due to the inability of a single attention mechanism, resulting in insufficient recognition accuracy and stability.
A dual attention network is adopted, including first and second attention modules, which enhance feature extraction through channel and spatial attention mechanisms respectively. The model parameters are optimized by combining triplet loss and cross-entropy loss functions, and the dual attention network is constructed for training.
It improves the accuracy and stability of pedestrian re-identification, enhances the performance of the model, and significantly outperforms traditional methods, especially in recognition performance on diverse datasets.
Smart Images

Figure CN119942636B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer vision technology, and in particular to a method and system for pedestrian re-identification based on a dual attention network. Background Technology
[0002] With the rapid development of science and technology, processing large amounts of video and image data has become crucial. Since large-scale processing cannot be achieved manually, computer-based pedestrian re-identification tasks have emerged.
[0003] Given an image of a person to query, a person re-identification system retrieves and visualizes images of identical individuals within a dataset. Traditional person re-identification systems primarily rely on supervised learning, requiring significant manual annotation and hindering large-scale deployment. Therefore, unsupervised learning methods have become increasingly popular. Unsupervised learning methods can assign pseudo-labels through methods such as clustering, even without labeled data, and then train a neural network for recognition.
[0004] In most existing unsupervised training methods, the important information in an image is usually captured by single attention mechanism or feature learning. However, a single enhancement method cannot completely eliminate the influence of noise information. Summary of the Invention
[0005] In view of this, the present invention provides a pedestrian re-identification method and system based on a dual attention network to improve the accuracy and stability of re-identification and enhance model performance.
[0006] In a first aspect, the present invention provides a person re-identification method based on a dual attention network, the method comprising:
[0007] Step 1: Extract image data from the pedestrian re-identification dataset and standardize the extracted image data to obtain the processed training set and test set;
[0008] Step 2: Construct the basic convolutional network for person re-identification;
[0009] Step 3: Construct a dual attention module, which includes a first attention module and a second attention module;
[0010] Step 4: Insert the dual attention module into the basic convolutional network to obtain the dual attention network;
[0011] Step 5: Train the dual attention network using the processed training set, and verify the trained dual attention network using the processed test set to achieve pedestrian re-identification.
[0012] Optionally, step 2 includes:
[0013] The basic convolutional network is a deep residual network containing multiple residual blocks. Each residual block contains multiple residual units, and each residual unit includes two 3×3 convolutional layers activated by the ReLU activation function. The main structure of the basic convolutional network is as follows: input layer, initial convolutional layer, max pooling layer, first residual block, second residual block, third residual block, fourth residual block, global average pooling layer, fully connected layer, and output layer. The first residual block contains 3 residual units, each with 256 output channels; the second residual block contains 4 residual units, each with 512 output channels; the third residual block contains 6 residual units, each with 1024 output channels; and the fourth residual block contains 3 residual units, each with 2048 output channels.
[0014] Optionally, the first attention module in step 3 includes:
[0015] First, the input image feature map x is processed by adaptive average pooling and 1×1 convolution to obtain the feature y, whose expression is: Subsequently, the feature y undergoes a 1×1 convolution and the activation function Softmax to obtain the channel weighting coefficients A1, the expression of which is: ;
[0016] Then, an identity matrix A0 and a parameter matrix A2 are constructed to adjust the weighting coefficients for each channel; the final weighting coefficient matrix is: Multiply the feature y by the weighted coefficient matrix, and then successively pass it through 1×1 convolution, ReLU activation function, 1×1 convolution and Sigmoid activation function to obtain the final weighted matrix. Its expression is: ;
[0017] Finally, the feature map x is multiplied by the weighting matrix y' to obtain the final weighted feature x'.
[0018] Optionally, the second attention module in step 3 includes channel attention and spatial attention;
[0019] For spatial attention, the input channel number d, the number of groups g, and the image are... Next, the image channels are first grouped according to a preset number of groups. The number of channels processed in each group is the input channel number d divided by the group number g, resulting in the grouped features. Next, global average pooling is performed on the images of each group in both the height and width directions, using the following formula: ,in H represents the input feature of the c-th channel, and H and W represent the height and width of the feature, respectively. The two pooling results are concatenated, and then weighted by 1×1 convolution, the sigmoid activation function, and group normalization to generate two channel weighting coefficients, respectively. and The weighting coefficients are used to represent the importance of the image in the height and width directions; finally, the weighting coefficients are multiplied by the original feature map to obtain a new weighted feature map. The specific formula is as follows: ;
[0020] For channel attention, the grouped features The feature map of the image is extracted by processing it through 3×3 convolution. Next, the feature maps were analyzed separately. and feature map Global average pooling and softmax operations are performed to obtain feature maps. and feature map The specific formula for Softmax is: ,in This is the pooling result of the c-th channel. This is the pooling result of the i-th channel; subsequently, the feature map... and feature map The feature map is obtained by reshaping. and feature map The coefficients are combined using matrix multiplication to generate a weighted matrix. The specific formula is as follows: Finally, the resulting weighted matrix Features after applying the Sigmoid activation function and after grouping Multiplying and reshaping yields the final weighted feature map. .
[0021] Optionally, step 4 includes:
[0022] The number of input channels for the first attention module is set to 256 and 2048 respectively, and then inserted after the first and fourth residual blocks of the basic convolutional network. The number of input channels for the second attention module is set to 512 and 1024 respectively, and then inserted after the second and third residual blocks of the basic convolutional network. The basic convolutional network after inserting the first and second attention modules is the final dual attention network, which is used to achieve pedestrian re-identification.
[0023] Optionally, step 5 includes:
[0024] The processed training set is input into the dual attention network for training. By combining the first attention module and the second attention module, key channel information and spatial information in the image are captured. During training, triplet loss and cross-entropy loss functions are used to optimize the model parameters.
[0025] The formula for the triplet loss is: ;
[0026] in Indicates sample and Euclidean distance; The anchor image is the reference image selected from the image library; These are positive sample images, meaning images belonging to the same person as the anchor image; These are negative sample images, meaning images belonging to different people than the anchor image; is a hyperparameter representing the minimum distance difference between positive and negative samples;
[0027] The formula for the cross-entropy loss function is: ;
[0028] Where N represents the total number of images in the dataset; Represents the true label of image i; , where represents the predicted probability that the input image belongs to each category; U represents the total number of categories. Represents the features of the input image;
[0029] The final loss function formula is: ;
[0030] in These are weighting coefficients that balance the two types of losses;
[0031] The model's performance is demonstrated by plotting a graph of the recognition accuracy index; the model's performance on the test set is visualized by showing the results of matching the test image with the top K images.
[0032] Secondly, the present invention provides a pedestrian re-identification system based on a dual attention network, the system comprising:
[0033] The data processing module is used to extract image data from the pedestrian re-identification dataset and to standardize the extracted image data to obtain the processed training set and test set.
[0034] The model building module is used to build the basic convolutional network for person re-identification; a dual attention module is built, which includes a first attention module and a second attention module; the dual attention module is inserted into the basic convolutional network to obtain the dual attention network;
[0035] The model training module is used to train the dual attention network based on the processed training set.
[0036] The results visualization module is used to validate the trained dual attention network using the processed test set to achieve pedestrian re-identification.
[0037] Thirdly, embodiments of the present invention provide a computer-readable storage medium comprising a stored program, wherein, when the program is executed, it controls the device on which the computer-readable storage medium is located to execute the pedestrian re-identification method based on a dual attention network in the first aspect or any possible implementation thereof.
[0038] Fourthly, embodiments of the present invention provide an electronic device, including: one or more processors; a memory; and one or more computer programs, wherein the one or more computer programs are stored in the memory, and the one or more computer programs include instructions that, when executed by the device, cause the device to perform the pedestrian re-identification method based on a dual attention network in the first aspect or any possible implementation of the first aspect.
[0039] The technical solution provided by this invention includes the following steps: extracting image data from a pedestrian re-identification dataset and standardizing the extracted image data to obtain processed training and test sets; constructing a basic convolutional network for pedestrian re-identification; constructing a dual attention module, which includes a first attention module and a second attention module; inserting the dual attention module into the basic convolutional network to obtain a dual attention network; training the dual attention network based on the processed training set; and verifying the trained dual attention network using the processed test set to achieve pedestrian re-identification. This method improves the accuracy and stability of re-identification by introducing dual attention into the basic convolutional network and enhancing key information in the image multiple times, thereby comprehensively improving model performance. Attached Figure Description
[0040] To more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0041] Figure 1 A flowchart of the pedestrian re-identification method provided in an embodiment of the present invention;
[0042] Figure 2 A schematic diagram of a dual attention network provided in an embodiment of the present invention;
[0043] Figure 3 A schematic diagram of a pedestrian re-identification system provided in an embodiment of the present invention;
[0044] Figure 4 This is a schematic diagram of an electronic device provided in an embodiment of the present invention. Detailed Implementation
[0045] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0046] It should be understood that the described embodiments are merely some, not all, of the embodiments of the present invention. All other embodiments obtained by those skilled in the art based on the embodiments of the present invention without inventive effort are within the scope of protection of the present invention.
[0047] The terminology used in the embodiments of this invention is for the purpose of describing particular embodiments only and is not intended to limit the invention. The singular forms “a,” “the,” and “the” used in the embodiments of this invention are also intended to include the plural forms unless the context clearly indicates otherwise.
[0048] It should be understood that the term "and / or" used in this article is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, or B existing alone. Additionally, the character " / " in this article generally indicates that the preceding and following related objects have an "or" relationship.
[0049] Depending on the context, the word "if" as used here can be interpreted as "when," "when," "in response to determination," or "in response to detection." Similarly, depending on the context, the phrase "if determination" or "if detection (of the stated condition or event)" can be interpreted as "when determination," "in response to determination," "when detection (of the stated condition or event)," or "in response to detection (of the stated condition or event)."
[0050] Figure 1 A flowchart of the pedestrian re-identification method provided in the embodiments of the present invention is shown below. Figure 1 As shown, the method includes:
[0051] Step 1: Extract image data from the pedestrian re-identification dataset and standardize the extracted image data to obtain the processed training and test sets.
[0052] In this embodiment of the invention, image data is extracted from the publicly available pedestrian re-identification dataset Market-1501. This dataset consists of 1501 pedestrians captured by 6 cameras and 32668 detected pedestrian bounding boxes. Each image includes photos of pedestrians from different perspectives, under different lighting conditions, and against different backgrounds to ensure data diversity and generalization ability.
[0053] The extracted image data is standardized to facilitate input into the model for training. All images are scaled to a uniform size, and image enhancement techniques such as rotation, translation, flipping, and color dithering are applied to increase data diversity and improve model robustness. To reduce bias during training, data standardization and normalization are used to ensure that the mean of each pixel value or channel is zero and the variance is one, helping the model converge faster.
[0054] Step 2: Construct the basic convolutional network for pedestrian re-identification.
[0055] In this embodiment of the invention, step 2 includes:
[0056] The basic convolutional network is a deep residual network containing multiple residual blocks. Each residual block contains multiple residual units, and each residual unit includes two 3×3 convolutional layers activated by the ReLU activation function. The main structure of the basic convolutional network is as follows: input layer, initial convolutional layer, max pooling layer, first residual block, second residual block, third residual block, fourth residual block, global average pooling layer, fully connected layer, and output layer. The first residual block contains 3 residual units, each with 256 output channels; the second residual block contains 4 residual units, each with 512 output channels; the third residual block contains 6 residual units, each with 1024 output channels; and the fourth residual block contains 3 residual units, each with 2048 output channels.
[0057] Step 3: Construct a dual attention module, which includes a first attention module and a second attention module.
[0058] In this embodiment of the invention, the first attention module in step 3 includes:
[0059] First, the input image feature map x is processed by adaptive average pooling and 1×1 convolution to obtain the feature y, whose expression is: Subsequently, the feature y undergoes a 1×1 convolution and the activation function Softmax to obtain the channel weighting coefficients A1, the expression of which is: ;
[0060] Then, an identity matrix A0 and a parameter matrix A2 are constructed to adjust the weighting coefficients for each channel; the final weighting coefficient matrix is: Multiply the feature y by the weighted coefficient matrix, and then successively pass it through 1×1 convolution, ReLU activation function, 1×1 convolution and Sigmoid activation function to obtain the final weighted matrix. Its expression is: ;
[0061] Finally, the feature map x is multiplied by the weighting matrix y' to obtain the final weighted feature x'.
[0062] In this embodiment of the invention, the second attention module in step 3 includes channel attention and spatial attention;
[0063] For spatial attention, the input channel number d, the number of groups g, and the image are... Next, the image channels are first grouped according to a preset number of groups. The number of channels processed in each group is the input channel number d divided by the group number g, resulting in the grouped features. Next, global average pooling is performed on the images of each group in both the height and width directions, using the following formula: ,in H represents the input feature of the c-th channel, and H and W represent the height and width of the feature, respectively. The two pooling results are concatenated, and then weighted by 1×1 convolution, the sigmoid activation function, and group normalization to generate two channel weighting coefficients, respectively. and The weighting coefficients are used to represent the importance of the image in the height and width directions; finally, the weighting coefficients are multiplied by the original feature map to obtain a new weighted feature map. The specific formula is as follows: ;
[0064] For channel attention, the grouped features The feature map of the image is extracted by processing with 3×3 convolution. Next, the feature maps were analyzed separately. and feature map Global average pooling and softmax operations are performed to obtain feature maps. and feature map The specific formula for Softmax is: ,in This is the pooling result of the c-th channel. This is the pooling result of the i-th channel; subsequently, the feature map... and feature map The feature map is obtained by reshaping. and feature map The coefficients are combined using matrix multiplication to generate a weighted matrix. The specific formula is as follows: Finally, the resulting weighted matrix Features after applying the Sigmoid activation function and after grouping Multiplying and reshaping yields the final weighted feature map. .
[0065] Step 4: Insert the dual attention module into the basic convolutional network to obtain the dual attention network.
[0066] In embodiments of the present invention, such as Figure 2 As shown, step 4 includes:
[0067] The number of input channels for the first attention module is set to 256 and 2048 respectively, and then inserted after the first and fourth residual blocks of the basic convolutional network. The number of input channels for the second attention module is set to 512 and 1024 respectively, and then inserted after the second and third residual blocks of the basic convolutional network. The basic convolutional network after inserting the first and second attention modules is the final dual attention network, which is used to achieve pedestrian re-identification.
[0068] Step 5: Train the dual attention network using the processed training set, and verify the trained dual attention network using the processed test set to achieve pedestrian re-identification.
[0069] In this embodiment of the invention, step 5 includes:
[0070] The processed training set is input into the dual attention network for training. By combining the first attention module and the second attention module, key channel information and spatial information in the image are captured. During training, triplet loss and cross-entropy loss functions are used to optimize the model parameters.
[0071] The formula for the triplet loss is: ;
[0072] in Indicates sample and Euclidean distance; The anchor image is the reference image selected from the image library; These are positive sample images, meaning images belonging to the same person as the anchor image; These are negative sample images, meaning images belonging to different people than the anchor image; is a hyperparameter representing the minimum distance difference between positive and negative samples;
[0073] The formula for the cross-entropy loss function is: ;
[0074] Where N represents the total number of images in the dataset; Represents the true label of image i; , where represents the predicted probability that the input image belongs to each category; U represents the total number of categories. Represents the features of the input image;
[0075] The final loss function formula is: ;
[0076] in The weights are used to balance the two types of losses. This loss function and gradient descent algorithm are then used to continuously optimize the model and improve its performance.
[0077] The model's performance is demonstrated by plotting a graph of the recognition accuracy index; the model's performance on the test set is visualized by showing the results of matching the test image with the top K images.
[0078] In this embodiment of the invention, the experimental results of comparing the proposed method with other methods are shown in Table 1. Bottom-up Clustering Approach (BUC), Softened Similarity Learning (SSL), Generative and Contrastive Learning (GCL), and Camera-Aware Proxies (CAP) are all pedestrian re-identification algorithms. mAP represents the average accuracy of the evaluation model in matching the query target with the returned results when querying a large number of pedestrian images. R1, R5, and R10 represent the probabilities of the search target existing in the first 1, 5, and 10 positions of the sorted list returned by the algorithm. As shown in Table 1, the proposed method has significant advantages over other methods.
[0079] Table 1
[0080] .
[0081] Figure 3 This is a schematic diagram of a pedestrian re-identification system provided in an embodiment of the present invention, as shown below. Figure 3 As shown, the system includes: a data processing module, a model building module, a model training module, and a results visualization module.
[0082] The data processing module is connected to the model building module; the model building module is connected to the model training module; and the model training module is connected to the results visualization module.
[0083] The data processing module extracts image data from the pedestrian re-identification dataset and standardizes the extracted image data to obtain processed training and test sets. The model building module constructs the basic convolutional network for pedestrian re-identification and builds a dual attention module, which includes a first attention module and a second attention module. The dual attention module is then inserted into the basic convolutional network to obtain the dual attention network. The model training module trains the dual attention network using the processed training set. The result visualization module validates the trained dual attention network using the processed test set to achieve pedestrian re-identification.
[0084] Traditional convolutional neural networks often neglect to enhance important spatial and channel information in images, or simply introduce a single attention mechanism, failing to capture crucial information comprehensively. This invention improves model performance by introducing dual attention into different residual blocks within a deep residual network, thereby enhancing key information in the image multiple times.
[0085] The various steps in the embodiments of the present invention can be performed by electronic devices. These electronic devices include, but are not limited to, mobile phones, tablet computers, portable PCs, and desktop computers.
[0086] The technical solution provided by this invention includes the following steps: extracting image data from a pedestrian re-identification dataset and standardizing the extracted image data to obtain processed training and test sets; constructing a basic convolutional network for pedestrian re-identification; constructing a dual attention module, which includes a first attention module and a second attention module; inserting the dual attention module into the basic convolutional network to obtain a dual attention network; training the dual attention network based on the processed training set; and verifying the trained dual attention network using the processed test set to achieve pedestrian re-identification. This method improves the accuracy and stability of re-identification by introducing dual attention into the basic convolutional network and enhancing key information in the image multiple times, thereby comprehensively improving model performance.
[0087] This invention provides a computer-readable storage medium including a stored program, wherein, when the program is running, it controls the electronic device containing the computer-readable storage medium to execute the above-described embodiment of the pedestrian re-identification method based on a dual attention network.
[0088] Figure 4 A schematic diagram of an electronic device provided in an embodiment of the present invention, such as... Figure 4As shown, the electronic device 21 includes a processor 211, a memory 212, and a computer program 213 stored in the memory 212 and executable on the processor 211. When the computer program 213 is executed by the processor 211, it implements the pedestrian re-identification method based on the dual attention network in the embodiment. To avoid repetition, it will not be described in detail here.
[0089] Electronic device 21 includes, but is not limited to, processor 211 and memory 212. Those skilled in the art will understand that... Figure 4 This is merely an example of electronic device 21 and does not constitute a limitation on electronic device 21. It may include more or fewer components than shown, or combine certain components, or different components. For example, electronic device may also include input / output devices, network access devices, buses, etc.
[0090] The processor 211 may be a Central Processing Unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor.
[0091] The memory 212 can be an internal storage unit of the electronic device 21, such as a hard disk or RAM of the electronic device 21. The memory 212 can also be an external storage device of the electronic device 21, such as a plug-in hard disk, Smart Media Card (SMC), Secure Digital (SD) card, or FlashCard equipped on the electronic device 21. Furthermore, the memory 212 can include both internal and external storage units of the electronic device 21. The memory 212 is used to store computer programs and other programs and data required by network devices. The memory 212 can also be used to temporarily store data that has been output or will be output.
[0092] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working processes of the systems, devices, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.
[0093] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.
Claims
1. A person re-identification method based on a dual attention network, characterized in that, The method includes: Step 1: Extract image data from the pedestrian re-identification dataset and standardize the extracted image data to obtain the processed training set and test set; Step 2: Construct the basic convolutional network for person re-identification; Step 3: Construct a dual attention module, which includes a first attention module and a second attention module; Step 4: Insert the dual attention module into the basic convolutional network to obtain the dual attention network; Step 5: Train the dual attention network using the processed training set, and verify the trained dual attention network using the processed test set to achieve pedestrian re-identification. The first attention module in step 3 includes: First, the input image feature map x is processed by adaptive average pooling and 1×1 convolution to obtain the feature y, whose expression is: Subsequently, the feature y undergoes a 1×1 convolution and the activation function Softmax to obtain the channel weighting coefficients A1, the expression of which is: ; Then, an identity matrix A0 and a parameter matrix A2 are constructed to adjust the weighting coefficients for each channel; the final weighting coefficient matrix is: Multiply the feature y by the weighted coefficient matrix, and then successively pass it through 1×1 convolution, ReLU activation function, 1×1 convolution and Sigmoid activation function to obtain the final weighted matrix. Its expression is: ; Finally, the feature map x is multiplied by the weighting matrix y' to obtain the final weighted feature x'.
2. The method according to claim 1, characterized in that, Step 2 includes: The basic convolutional network is a deep residual network containing multiple residual blocks. Each residual block contains multiple residual units, and each residual unit includes two 3×3 convolutional layers activated by the ReLU activation function. The main structure of the basic convolutional network is as follows: input layer, initial convolutional layer, max pooling layer, first residual block, second residual block, third residual block, fourth residual block, global average pooling layer, fully connected layer, and output layer. The first residual block contains 3 residual units, each with 256 output channels; the second residual block contains 4 residual units, each with 512 output channels; the third residual block contains 6 residual units, each with 1024 output channels; and the fourth residual block contains 3 residual units, each with 2048 output channels.
3. The method according to claim 1, characterized in that, The second attention module in step 3 includes channel attention and spatial attention; For spatial attention, the input channel number d, the number of groups g, and the image are... Next, the image channels are first grouped according to a preset number of groups. The number of channels processed in each group is the input channel number d divided by the group number g, resulting in the grouped features. Next, global average pooling is performed on the images of each group in both the height and width directions, using the following formula: ,in H represents the input feature of the c-th channel, and H and W represent the height and width of the feature, respectively. The two pooling results are concatenated, and then weighted by 1×1 convolution, the sigmoid activation function, and group normalization to generate two channel weighting coefficients, respectively. and The weighting coefficients are used to represent the importance of the image in the height and width directions; finally, the weighting coefficients are multiplied by the original feature map to obtain a new weighted feature map. The specific formula is as follows: ; For channel attention, the grouped features The feature map of the image is extracted by processing with 3×3 convolution. Next, the feature maps were analyzed separately. and feature map Global average pooling and softmax operations are performed to obtain feature maps. and feature map The specific formula for Softmax is: ,in This is the pooling result of the c-th channel. This is the pooling result of the i-th channel; subsequently, the feature map... and feature map The feature map is obtained by reshaping. and feature map The coefficients are combined using matrix multiplication to generate a weighted matrix. The specific formula is as follows: Finally, the resulting weighted matrix Features after applying the Sigmoid activation function and after grouping Multiplying and reshaping yields the final weighted feature map. .
4. The method according to claim 1, characterized in that, Step 4 includes: The number of input channels for the first attention module is set to 256 and 2048 respectively, and then inserted after the first and fourth residual blocks of the basic convolutional network. The number of input channels for the second attention module is set to 512 and 1024 respectively, and then inserted after the second and third residual blocks of the basic convolutional network. The basic convolutional network after inserting the first and second attention modules is the final dual attention network, which is used to achieve pedestrian re-identification.
5. The method according to claim 1, characterized in that, Step 5 includes: The processed training set is input into the dual attention network for training. By combining the first attention module and the second attention module, key channel information and spatial information in the image are captured. During training, triplet loss and cross-entropy loss functions are used to optimize the model parameters. The formula for the triplet loss is: ; in Indicates sample and Euclidean distance; The anchor image is the reference image selected from the image library; These are positive sample images, meaning images belonging to the same person as the anchor image; These are negative sample images, meaning images belonging to different people than the anchor image; is a hyperparameter representing the minimum distance difference between positive and negative samples; The formula for the cross-entropy loss function is: ; Where N represents the total number of images in the dataset; Represents the true label of image i; , where represents the predicted probability that the input image belongs to each category; U represents the total number of categories. Represents the features of the input image; The final loss function formula is: ; in These are weighting coefficients, used to balance the two types of losses; The model's performance is demonstrated by plotting a graph of the recognition accuracy index; the model's performance on the test set is visualized by showing the results of matching the test image with the top K images.
6. A pedestrian re-identification system based on a dual attention network, characterized in that, The system is used to implement the person re-identification method based on a dual attention network as described in claim 1, and the system includes: The data processing module is used to extract image data from the pedestrian re-identification dataset and to standardize the extracted image data to obtain the processed training set and test set. The model building module is used to build the basic convolutional network for person re-identification; a dual attention module is built, which includes a first attention module and a second attention module; the dual attention module is inserted into the basic convolutional network to obtain the dual attention network; The model training module is used to train the dual attention network based on the processed training set. The results visualization module is used to validate the trained dual attention network using the processed test set to achieve pedestrian re-identification.
7. A computer-readable storage medium, characterized in that, The computer-readable storage medium includes a stored program, wherein, when the program is executed, it controls the device on which the computer-readable storage medium is located to perform the pedestrian re-identification method based on a dual attention network as described in any one of claims 1 to 5.
8. An electronic device, characterized in that, include: One or more processors; Memory; And one or more computer programs, wherein the one or more computer programs are stored in the memory, the one or more computer programs including instructions that, when executed by the device, cause the device to perform the pedestrian re-identification method based on a dual attention network as described in any one of claims 1 to 5.
Citation Information
Patent Citations
Truck picture re-identification method based on double-layer attention network
CN115035476A
Method of semantically segmenting input image, apparatus for semantically segmenting input image, method of pre-training apparatus for semantically segmenting input image, training apparatus for pre-training apparatus for semantically segmenting input image, and computer-program product
US20210406582A1