Pedestrian re-identification method and device based on attention mechanism and feature fusion strategy

By introducing a module based on attention mechanism and feature fusion into the pedestrian re-identification algorithm, the problem of low accuracy under the influence of occlusion is solved and high-precision pedestrian re-identification under occlusion conditions is achieved.

CN118470752BActive Publication Date: 2024-10-01ZHEJIANG LAB
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410919906.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-07-10
Publication Date
2024-10-01
Estimated Expiration
2044-07-10

AI Technical Summary

Technical Problem

Existing pedestrian re-identification algorithms have low accuracy under occlusion, and it is difficult to effectively identify and match the characteristics of the occlusion area, which affects the re-identification accuracy.

Method used

A method based on attention mechanism and feature fusion strategy is adopted. Through the spatial attention mechanism and feature fusion module, the model is guided to focus on non-occlusion areas, extract contextual information, and improve the accuracy of pedestrian re-identification.

Benefits of technology

The accuracy of pedestrian re-identification is significantly improved under occlusion conditions, and it can better match the same target person with different shapes and occlusion levels in different images.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118470752B_ABST
    Figure CN118470752B_ABST
Patent Text Reader

Abstract

A pedestrian re-identification method and device based on an attention mechanism and a feature fusion strategy, the method comprising: (1) selecting a pedestrian re-identification dataset, a training set, a query set and a prototype image set; (2) constructing a branch structure on the output feature Conv4_2 of ResNet, including a global branch, a binary branch and a trisection branch; (3) constructing a feature enhancement structure based on an attention mechanism and a feature fusion strategy in the global branch to extract features; (4) constructing a feature enhancement structure based on an attention mechanism and a feature fusion strategy in the binary branch to extract features; (5) constructing a feature enhancement structure based on an attention mechanism and a feature fusion strategy in the trisection branch to extract features; (6) calculating the loss based on global features and local features; (7) inputting the image in the query set into the trained network, concatenating the output features of the three branches, calculating the distance between the features of the image to be queried in the query set and the features of the image in the prototype image set, and realizing pedestrian re-identification.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer vision, and in particular to a pedestrian re-identification method and device based on an attention mechanism and a feature fusion strategy. Background Art

[0002] Person re-identification (Re-ID) focuses on identifying the target person from images taken by multiple cameras. Re-ID has a wide range of application scenarios. In the field of intelligent security, Re-ID is used to identify pedestrians in surveillance video streams, in the commercial field, Re-ID is used to count and analyze pedestrian flow, and in the transportation field, Re-ID is used to analyze pedestrian behavior.

[0003] In recent years, with the continuous development of deep learning technology, deep learning-based Re-ID has become a hot research direction in the field of computer vision. The challenges faced by Re-ID algorithms in terms of accuracy are mainly reflected in: human posture changes, complex background interference and occlusion problems. How to improve the re-identification accuracy of Re-ID algorithms by alleviating the occlusion problem in Re-ID is the focus of many researchers. Summary of the invention

[0004] The present invention aims to overcome the above-mentioned shortcomings of the prior art and provide a method and device based on an attention mechanism and a feature fusion strategy. The present invention effectively alleviates the occlusion problem in Re-ID and improves the accuracy of pedestrian re-identification through an attention mechanism and a feature fusion strategy.

[0005] The objective of the present invention is achieved through the following technical solutions:

[0006] The first aspect of the present invention relates to a pedestrian re-identification method based on an attention mechanism and a feature fusion strategy, the basic recognition framework of which is MGN, and the innovation is that a module based on an attention mechanism and feature fusion is introduced into the global branch, the binary branch, and the tripartite branch of the model, which guides the model to focus on the non-occluded area of ​​the target to be identified with the help of the spatial attention mechanism, and guides the model to extract contextual information with the help of the feature fusion strategy, thereby alleviating the occlusion problem in the pedestrian re-identification process and improving the accuracy of pedestrian re-identification. Unless otherwise defined, the technologies and terms involved in the present invention are the conventional expressions in the art.

[0007] The pedestrian re-identification method based on the attention mechanism and feature fusion strategy includes the following steps:

[0008] (1) Select a person re-identification dataset, including a training set, a query set, and a prototype image set;

[0009] (2) Select the backbone network ResNet and build a branch structure on the output feature Conv4_2 of ResNet, including global branch, binary branch and tripartite branch;

[0010] (3) Construct a feature enhancement structure based on the attention mechanism and feature fusion strategy in the global branch to extract features;

[0011] (4) Construct a feature enhancement structure based on the attention mechanism and feature fusion strategy in the binary branch to extract features;

[0012] (5) Construct a feature enhancement structure based on the attention mechanism and feature fusion strategy in the three branches to extract features;

[0013] (6) Calculate the loss based on global features and local features, including triplet loss and Softmax loss;

[0014] (7) Input the images in the query set into the trained network, concatenate the output features of the three branches, calculate the distance between the features of the query image in the query set and the features of the prototype image set, and realize person re-identification.

[0015] The construction process of the global branch structure described in step (2) is as follows: the backbone network output feature Conv4_2 of size (C, H, W) is passed to two convolution structures; the first convolution structure contains a convolution layer with a convolution kernel size of (C1, 1, 1) and a step size of 1, followed by a batch normalization function (BN) and an activation function ReLU, and the output feature x g1 The size of is (C1, H, W); the second convolutional layer contains a convolutional layer with a kernel size of (C2, 1, 1) and a stride of 2, followed by a BN layer and a ReLU layer, and the output feature x g2 The dimensions are (C2, H / 2, W / 2).

[0016] The construction process of the binary branch structure described in step (2) is as follows: the backbone network output feature Conv4_2 of size (C, H, W) is passed to two convolution structures respectively; the first convolution structure contains a convolution layer with a convolution kernel size of (C1, 1, 1) and a step size of 1, followed by BN and ReLU, and the output feature x p21 The size of is (C1, H, W); the second convolutional layer contains a convolutional layer with a kernel size of (C2, 1, 1) and a stride of 1, followed by BN and ReLU, and the output feature x p22 The dimensions are (C2, H, W).

[0017] The construction process of the three-branch structure described in step (2) is as follows: the backbone network output feature Conv4_2 of size (C, H, W) is passed to two convolution structures respectively; the first convolution structure contains a convolution layer with a convolution kernel size of (C1, 1, 1) and a step size of 1, followed by BN and ReLU, and the output feature x p31 The size of is (C1, H, W); the second convolutional layer contains a convolutional layer with a kernel size of (C2, 1, 1) and a stride of 1, followed by BN and ReLU, and the output feature x p32 The dimensions are (C2, H, W).

[0018] The processing flow of the feature enhancement structure based on the attention mechanism and feature fusion strategy described in step (3) is as follows:

[0019] (3.1) The backbone network output feature Conv4_2 (C, H, W) is passed into the spatial attention structure, which includes a convolution layer with a kernel size of (1, 1, 1), a step size of 1, and a Sigmoid activation function to generate a spatial attention structure output weight of size (1, H, W); at the same time, Conv4_2 is passed into two convolution modules to generate a feature of size (C1, H, W), which is multiplied element by element with the output weight of the above spatial attention structure to generate the spatial attention weighted feature S g0 (C1, H, W);

[0020] (1)

[0021] Among them, G 0 Represents two convolution modules, including convolutional layers, BN and ReLU, A 0 represents the spatial attention structure, x 0 Represents the output feature Conv4_2 of the backbone network, S g0 Represents the spatial attention weighted features of the output;

[0022] (3.2) The first layer feature x of the above global branch g1 Pass it to the convolution layer, BN layer and ReLU layer with a convolution kernel of (C1, 1, 1) and a step size of 1 to generate an output feature of size (C1, H, W); combine this output feature with the above-mentioned spatial attention weighted feature S g0 Sum each element to get the output feature F g1 ;

[0023] (2)

[0024] Among them, G 11 Represents the convolution module, including convolution layer, BN and ReLU, x g1Represents the first layer output features of the global branch;

[0025] (3.3) x g1 (C1, H, W) is passed into the spatial attention structure, which includes a convolutional layer with a kernel size of (1, 1, 1), a stride of 2, and a Sigmoid activation function to generate the output weights of the spatial attention structure with a size of (1, H / 2, W / 2); at the same time, Pass in a convolution module with a convolution kernel of (C2, 1, 1) and a stride of 2 to generate a feature of size (C2, H / 2, W / 2), which is multiplied element-wise with the output weights of the above spatial attention structure to generate a spatial attention weighted feature. ;

[0026] (3)

[0027] Among them, G 12 Represents the convolution module, including convolution layer, BN and ReLU, A 1 Represents the spatial attention structure;

[0028] (3.4) The second layer feature x of the global branch g2 Pass it to the convolution layer, BN layer and ReLU layer with a convolution kernel of (C2, 1, 1) and a step size of 1 to generate an output feature of size (C2, H / 2, W / 2); combine this output feature with the above-mentioned spatial attention weighted feature S g1 Sum each element to get the output feature F g2 ;

[0029] (4)

[0030] Among them, G 2 Represents the convolution module, including convolution layer, BN and ReLU;

[0031] (3.5) For the above output features Perform the global maximum pooling operation to obtain the corresponding global features, expressed as ;Will The convolution layer with a convolution kernel of (256, 1, 1) is passed in for dimensionality reduction to generate output features .

[0032] The processing flow of the feature enhancement structure based on the attention mechanism and feature fusion strategy described in step (4) is as follows:

[0033] (4.1) The difference between the feature enhancement structure based on the attention mechanism and feature fusion strategy in step (4) and the feature enhancement structure based on the attention mechanism and feature fusion strategy in step (3) is that the step size of all convolution structures is 1, and the output feature is generated on this basis. ;

[0034] (4.2) Make a bisection cut in the height direction of the output feature of the binary branch to generate two binary feature maps. Perform a global maximum pooling operation on each binary feature map to obtain the corresponding binary local features, which are passed to the convolution layer with a convolution kernel of (256, 1, 1) for dimensionality reduction processing to generate local features, which are expressed as and ; For the above output features Perform the global maximum pooling operation to obtain the corresponding binary branch global features, expressed as ;Will The convolution layer with a convolution kernel of (256, 1, 1) is passed in for dimensionality reduction to generate output features .

[0035] The processing flow of the feature enhancement structure based on the attention mechanism and feature fusion strategy described in step (5) is as follows:

[0036] (5.1) The difference between the feature enhancement structure based on the attention mechanism and feature fusion strategy in step (5) and the feature enhancement structure based on the attention mechanism and feature fusion strategy in step (3) is that the step size of all convolution structures is 1, and the output feature is generated on this basis. ;

[0037] (5.2) Make a three-equal cut in the height direction of the output feature of the three-branch to generate three three-branch feature maps. Perform a global maximum pooling operation on each three-branch feature map to obtain the corresponding three-branch local features, which are respectively passed into the convolution layer with a convolution kernel of (256, 1, 1) for dimensionality reduction processing to generate local features, which are expressed as , and ; For the above output features Perform the global maximum pooling operation to obtain the corresponding three-branch global features, expressed as ;Will The convolution layer with a convolution kernel of (256, 1, 1) is passed in for dimensionality reduction to generate output features .

[0038] The loss function described in step (6) is as follows:

[0039]

[0040] (5)

[0041] Among them, N represents the number of samples in each batch during training, C represents the number of sample categories, and fi represents the number of samples involved in the softmax loss calculation. , , , , , , and ; yi represents the category label corresponding to fi, Wyi represents the weight, and T represents the transposition; represents the boundary between positive sample pairs and negative sample pairs, , and Represents the feature vectors corresponding to anchor samples, positive samples, and negative samples, whose features come from , and .

[0042] The specific form of the output features described in step (7) is:

[0043] (6)

[0044] A second aspect of the present invention relates to a person re-identification system based on an attention mechanism and a feature fusion strategy, comprising:

[0045] The pedestrian re-identification dataset selection module is used to select the pedestrian re-identification dataset, training set, query set and prototype image set;

[0046] The branch structure building module is used to select the backbone network ResNet and build a branch structure on the output feature Conv4_2 of ResNet, including global branch, binary branch and tri-branch;

[0047] The global branch feature extraction module is used to construct a feature enhancement structure based on the attention mechanism and feature fusion strategy in the global branch to extract features;

[0048] The binary branch feature extraction module is used to construct a feature enhancement structure based on the attention mechanism and feature fusion strategy in the binary branch to extract features;

[0049] The three-branch feature extraction module is used to construct a feature enhancement structure based on the attention mechanism and feature fusion strategy in the three-branch to extract features;

[0050] The loss calculation module is used to calculate the loss based on global features and local features, including triple loss and Softmax loss;

[0051] The pedestrian re-identification module is used to input the images in the query set into the trained network, splice the output features of the three branches, calculate the distance between the features of the query image in the query set and the image features of the prototype image set, and realize pedestrian re-identification.

[0052] The third aspect of the present invention relates to a pedestrian re-identification device based on an attention mechanism and a feature fusion strategy, comprising a memory and one or more processors, wherein the memory stores executable code, and when the one or more processors execute the executable code, they are used to implement the pedestrian re-identification method based on an attention mechanism and a feature fusion strategy of the present invention.

[0053] The fourth aspect of the present invention relates to a computer-readable storage medium having a program stored thereon, which, when executed by a processor, implements the pedestrian re-identification method based on an attention mechanism and a feature fusion strategy of the present invention.

[0054] The innovation of this invention is to improve the accuracy of pedestrian re-identification under occlusion conditions with the help of spatial attention mechanism and feature fusion strategy.

[0055] The advantages of the present invention are: a feature enhancement module based on the spatial attention mechanism and feature fusion strategy is constructed in the basic pedestrian re-identification framework, which guides the model to focus on the unobstructed areas in the image, guides the model to extract contextual information, and enhances the feature expression effect, so that the model can better match the same target person in different forms and different degrees of occlusion in different images, thereby improving the accuracy of re-identification. BRIEF DESCRIPTION OF THE DRAWINGS

[0056] Figure 1 It is a flow chart of the present invention.

[0057] Figure 2 It is a schematic diagram of the feature enhancement module in the present invention.

[0058] Figure 3 This is the evaluation result of the present invention on the Market-1501 dataset.

[0059] Figure 4 This is the evaluation result of the present invention on the DukeMTMC-ReID dataset.

[0060] Figure 5 It is a system structure diagram of the present invention. DETAILED DESCRIPTION

[0061] 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.

[0062] It should be noted that, in the absence of conflict, the features in the following embodiments and implementations may be combined with each other.

[0063] Example 1

[0064] Figure 1 It is a flowchart of a pedestrian re-identification method based on an attention mechanism and a feature fusion strategy of the present invention. The pedestrian re-identification method based on an attention mechanism and a feature fusion strategy of the present invention has a specific implementation process as follows:

[0065] Step 1: Select a person re-identification dataset. The datasets used in this application are Market-1501 and DukeMTMC-ReID. According to the division method of Market-1501, all data are divided into a training set (751 IDs, 12936 frames of images), a query set (750 IDs, 3368 frames of images), and a prototype image set (750 IDs, 19732 images). According to the division method of DukeMTMC-ReID, all data are divided into a training set (702 IDs, 16522 frames of images), a query set (702 IDs, 2228 frames of images), and a prototype image set (702 IDs, 17661 frames of images).

[0066] Step 2: Use the backbone network ResNet-50 to process the input image, extract features, and the backbone network outputs features x 0 The dimensions are (C, H, W).

[0067] Step 3: The output feature x of the backbone network 0 The output features of the global branch are represented by x g1 and x g2 , the output feature of the binary branch is represented as x p21 and x p22 , the output feature of the three-branch is represented as x p31 and x p32 .

[0068] Step 4: Use the feature enhancement structures based on the attention mechanism and feature fusion strategy in the global branch, the binary branch, and the tripartite branch to further process the output features of the backbone network. Each branch contains a feature enhancement structure based on the attention mechanism and feature fusion strategy, refer to Figure 2 The specific processing flow is as follows:

[0069] (4.1) The feature x 0 The spatial attention structure is passed in, which includes a convolution layer with a kernel size of (1, 1, 1) and a Sigmoid activation function to generate the spatial attention structure output weights with a size of (1, H, W); at the same time, the feature x 0Pass two convolution modules to generate features of size (C1, H, W). Multiply this output feature by the output weight of the above spatial attention structure element by element to generate the spatial attention weighted feature S g0 .

[0070] (1)

[0071] Among them, G 0 Represents two convolution modules, including convolutional layers, BN and ReLU, A 0 represents the spatial attention structure, x 0 represents the output features of the backbone network, S g0 Represents the spatial attention weighted features of the output.

[0072] (4.2) The first-layer features x of the global branch g1 It is passed to the convolution layer with a convolution kernel of (C1, 1, 1) and a stride of 1, the BN layer, and the ReLU layer to generate an output feature of size (C1, H, W). This output feature is combined with the above spatial attention weighted feature S g0 Sum each element to get the output feature F g1 .

[0073] (2)

[0074] Among them, G 11 Represents the convolution module, including convolution layer, BN and ReLU, x g1 Represents the first layer output features of the global branch.

[0075] (4.3) Output feature x of the first layer of the global branch g1 The spatial attention structure is passed in, which includes a convolutional layer with a kernel size of (1, 1, 1), a stride of 2, and a Sigmoid activation function to generate the spatial attention structure output weights of size (1, H / 2, W / 2); at the same time, Pass in a convolution module with a convolution kernel of (C2, 1, 1) and a stride of 2 to generate a feature of size (C2, H / 2, W / 2), which is multiplied element-wise with the output weights of the above spatial attention structure to generate a spatial attention weighted feature. (C2, H / 2, W / 2).

[0076] (3)

[0077] Among them, G 12 Represents the convolution module, including convolution layer, BN and ReLU, A 1 Represents the spatial attention structure.

[0078] (4.4) The second-level features x of the global branch are g2 Pass it to the convolution layer, BN layer and ReLU layer with a convolution kernel of (C2, 1, 1) and a step size of 1 to generate an output feature of size (C2, H / 2, W / 2); combine this output feature with the above-mentioned spatial attention weighted feature S g1 Sum each element to get the output feature F g2 .

[0079] (4)

[0080] Among them, G 2 Represents a convolutional module, including convolutional layers, BN, and ReLU.

[0081] (4.5) For the above output features Perform the global maximum pooling operation to obtain the corresponding global features, expressed as Will The convolution layer with a convolution kernel of (256, 1, 1) is passed in for dimensionality reduction to generate output features .

[0082] (4.5) The feature fusion structure based on the attention mechanism in the global branch is different from that in the other two branches. The first layer output feature x in the global branch g1 The size of the second layer output feature x g2 The output feature size of the first layer and the second layer in the remaining two branches are the same. Therefore, a convolutional layer with a stride of 2 is used in the global branch to fuse feature layers of different sizes, while the convolutional structures involved in the remaining two branches have a stride of 1. On this basis, the output features are generated respectively. and . Output features in the binary branch The height direction of the image is bisected to generate two binary feature maps. The global maximum pooling operation is performed on each binary feature map to obtain the corresponding binary local features, which are respectively passed into the convolution layer with a convolution kernel of (256, 1, 1) for dimensionality reduction processing to generate local features, which are expressed as and ; For the above output features Perform the global maximum pooling operation to obtain the corresponding binary branch global features, expressed as ;Will The convolution layer with a convolution kernel of (256, 1, 1) is passed in for dimensionality reduction to generate output features The output feature of the three-branch is divided into three equal parts in the height direction to generate three three-branch feature maps. The global maximum pooling operation is performed on each three-branch feature map to obtain the corresponding three-branch local features, which are respectively passed into the convolution layer with a convolution kernel of (256, 1, 1) for dimensionality reduction processing to generate local features, which are expressed as , and ; For the above output features Perform the global maximum pooling operation to obtain the corresponding three-branch global features, expressed as ;Will The convolution layer with a convolution kernel of (256, 1, 1) is passed in for dimensionality reduction to generate output features .

[0083] Step 5: Calculate the loss of the model training process. The loss function consists of two parts, Softmax loss and triplet loss.

[0084]

[0085] (5)

[0086] Among them, N represents the number of samples in each batch during training, C represents the number of sample categories, and fi represents the number of samples involved in the softmax loss calculation. , , , , , , and ; yi represents the category label corresponding to fi, Wyi represents the weight, and T represents the transposition; represents the boundary between positive sample pairs and negative sample pairs, , and Represents the feature vectors corresponding to anchor samples, positive samples, and negative samples, whose features come from , and .

[0087] Step 6: Model inference, test the recognition effect of the model. Input the images in the Market-1501 and DukeMTMC-ReID query sets into the trained network respectively, concatenate the output features of the three branches, output the results of model re-recognition, and evaluate the re-recognition effect on the evaluation program. The evaluation indicators used are mean Average Precision (mAP) and Rank-1 of Cumulative Matching Characteristics (CMCs). The evaluation results on the Market-1501 and DukeMTMC-ReID datasets are shown in Figure 2. Figure 3 and Figure 4 Among them, the output feature expression after splicing is:

[0088] (6)

[0089] exist Figure 3 and Figure 4 In the figure, mAP and Rank-1 represent the average precision and first-place hit rate of the re-identification results, respectively. EANet, GLAD, Attention-driven net, AACN, MPR+LOMO+XQDA, AANet, and Ours represent the partial pooling and segmentation-based method, the global-local alignment method, the attention mechanism-driven method, the attention-aware combination method, the multi-component representation method, the attribute attention method, and the method of the present invention, respectively.

[0090] Example 2

[0091] Reference Figure 5 This embodiment relates to a pedestrian re-identification system based on an attention mechanism and a feature fusion strategy, to implement the pedestrian re-identification method based on an attention mechanism and a feature fusion strategy of Embodiment 1, including:

[0092] The pedestrian re-identification dataset selection module is used to select the pedestrian re-identification dataset, training set, query set and prototype image set;

[0093] The branch structure building module is used to select the backbone network ResNet and build a branch structure on the output feature Conv4_2 of ResNet, including global branch, binary branch and tri-branch;

[0094] The global branch feature extraction module is used to construct a feature enhancement structure based on the attention mechanism and feature fusion strategy in the global branch to extract features;

[0095] The binary branch feature extraction module is used to construct a feature enhancement structure based on the attention mechanism and feature fusion strategy in the binary branch to extract features;

[0096] The three-branch feature extraction module is used to construct a feature enhancement structure based on the attention mechanism and feature fusion strategy in the three-branch to extract features;

[0097] The loss calculation module is used to calculate the loss based on global features and local features, including triple loss and Softmax loss;

[0098] The pedestrian re-identification module is used to input the images in the query set into the trained network, splice the output features of the three branches, calculate the distance between the features of the query image in the query set and the image features of the prototype image set, and realize pedestrian re-identification.

[0099] Example 3

[0100] This embodiment relates to a computer-readable storage medium on which a program is stored. When the program is executed by a processor, the pedestrian re-identification method based on the attention mechanism and feature fusion strategy of Example 1 is implemented.

[0101] Example 4

[0102] The present embodiment relates to a pedestrian re-identification device based on an attention mechanism and a feature fusion strategy, including a memory and one or more processors, wherein the memory stores executable code, and when the one or more processors execute the executable code, they are used to implement the pedestrian re-identification method based on an attention mechanism and a feature fusion strategy of Example 1.

[0103] At the hardware level, the pedestrian re-identification device based on the attention mechanism and feature fusion strategy includes a processor, an internal bus, a network interface, a memory, and a non-volatile memory, and of course may also include hardware required for other services. The processor reads the corresponding computer program from the non-volatile memory into the memory and then runs it to achieve the above Figure 1 Of course, in addition to the software implementation, the present invention does not exclude other implementations, such as logic devices or a combination of software and hardware, etc., that is, the execution subject of the following processing flow is not limited to each logic unit, but can also be hardware or logic devices.

[0104] For the improvement of a technology, it can be clearly distinguished whether it is a hardware improvement (for example, improvement of the circuit structure of diodes, transistors, switches, etc.) or a software improvement (improvement of the method flow). However, with the development of technology, many improvements of the method flow today can be regarded as direct improvements of the hardware circuit structure. Designers almost always obtain the corresponding hardware circuit structure by programming the improved method flow into the hardware circuit. Therefore, it cannot be said that the improvement of a method flow cannot be implemented with a hardware entity module. For example, a programmable logic device (PLD) (such as a field programmable gate array (FPGA)) is such an integrated circuit whose logical function is determined by the user's programming of the device. Designers can "integrate" a digital system on a PLD by programming themselves, without having to ask chip manufacturers to design and make dedicated integrated circuit chips. Moreover, nowadays, instead of manually making integrated circuit chips, this kind of programming is mostly implemented by "logic compiler" software, which is similar to the software compiler used when developing and writing programs, and the original code before compilation must also be written in a specific programming language, which is called hardware description language (HDL). There is not only one kind of HDL, but many kinds, such as ABEL (Advanced Boolean Expression Language), AHDL (Altera Hardware Description Language), Confluence, CUPL (Cornell University Programming Language), HDCal, JHDL (Java Hardware Description Language), Lava, Lola, MyHDL, PALASM, RHDL (Ruby Hardware Description Language), etc. The most commonly used ones are VHDL (Very-High-Speed ​​Integrated Circuit Hardware Description Language) and Verilog. Those skilled in the art should also know that it is only necessary to program the method flow slightly in the above-mentioned hardware description languages ​​and program it into the integrated circuit, and then it is easy to obtain the hardware circuit that implements the logic method flow.

[0105] The controller may be implemented in any suitable manner, for example, the controller may take the form of a microprocessor or processor and a computer-readable medium storing a computer-readable program code (e.g., software or firmware) executable by the (micro)processor, a logic gate, a switch, an application-specific integrated circuit (ASIC), a programmable logic controller, and an embedded microcontroller, examples of which include but are not limited to the following microcontrollers: ARC 625D, Atmel AT91SAM, Microchip PIC18F26K20, and Silicone Labs C8051F320, and the memory controller may also be implemented as part of the control logic of the memory. It is also known to those skilled in the art that, in addition to implementing the controller in a purely computer-readable program code manner, the controller may be implemented in the form of a logic gate, a switch, an application-specific integrated circuit, a programmable logic controller, and an embedded microcontroller by logically programming the method steps. Therefore, such a controller may be considered as a hardware component, and the devices for implementing various functions included therein may also be considered as structures within the hardware component. Or even, the devices for implementing various functions may be considered as both software modules for implementing the method and structures within the hardware component.

[0106] The systems, devices, modules or units described in the above embodiments may be implemented by computer chips or entities, or by products with certain functions. A typical implementation device is a computer. Specifically, the computer may be, for example, a personal computer, a laptop computer, a cellular phone, a camera phone, a smart phone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or a combination of any of these devices.

[0107] For the convenience of description, the above device is described as being divided into various units according to their functions. Of course, when implementing the present invention, the functions of each unit can be implemented in the same or multiple software and / or hardware.

[0108] It will be appreciated by those skilled in the art that embodiments of the present invention may be provided as methods, systems, or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Furthermore, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0109] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0110] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0111] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.

[0112] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.

[0113] The memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.

[0114] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.

[0115] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.

[0116] It should be understood by those skilled in the art that the embodiments of the present invention may be provided as methods, systems or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment or an embodiment combining software and hardware aspects. Moreover, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0117] The present invention may be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types. The present invention may also be practiced in distributed computing environments where tasks are performed by remote processing devices connected through a communication network. In a distributed computing environment, program modules may be located in local and remote computer storage media, including storage devices.

[0118] Each embodiment of the present invention is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.

[0119] The above description is only an embodiment of the present invention and is not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and variations. Any modification, equivalent substitution, improvement, etc. made within the spirit and principle of the present invention should be included in the scope of the claims of the present invention.

Claims

1. A person re-identification method based on attention mechanism and feature fusion strategy, characterized in that: The following steps are involved: (1) Select a person re-identification dataset, including a training set, a query set, and a prototype image set; (2) Select the backbone network ResNet and build a branch structure on the output feature Conv4_2 of ResNet, including global branch, binary branch and tripartite branch; (3) Construct a feature enhancement structure based on the attention mechanism and feature fusion strategy in the global branch to extract features; The processing flow of the feature enhancement structure based on the attention mechanism and feature fusion strategy is as follows: (3.1) The backbone network output feature Conv4_2 (C, H, W) is passed into the spatial attention structure, which includes a convolution layer with a kernel size of (1, 1, 1), a step size of 1, and a Sigmoid activation function to generate a spatial attention structure output weight of size (1, H, W); at the same time, Conv4_2 is passed into two convolution modules to generate a feature of size (C1, H, W), which is multiplied element by element with the output weight of the above spatial attention structure to generate the spatial attention weighted feature S g0 (C1, H, W); (1) Among them, G0 represents two convolution modules, including convolutional layers, BN and ReLU, A0 represents the spatial attention structure, x0 represents the output feature Conv4_2 of the backbone network, S g0 Represents the spatial attention weighted features of the output; (3.2) The first layer feature x of the above global branch g1 Pass it to the convolution layer, BN layer and ReLU layer with a convolution kernel of (C1, 1, 1) and a step size of 1 to generate an output feature of size (C1, H, W); combine this output feature with the above-mentioned spatial attention weighted feature S g0 Sum each element to get the output feature F g1 ; (2) Among them, G 11 Represents the convolution module, including convolution layer, BN and ReLU, x g1 Represents the first layer output features of the global branch; (3.3) x g1 (C1, H, W) is passed into the spatial attention structure, which includes a convolutional layer with a kernel size of (1, 1, 1), a stride of 2, and a Sigmoid activation function to generate the output weights of the spatial attention structure with a size of (1, H / 2, W / 2); at the same time, Pass in a convolution module with a convolution kernel of (C2, 1, 1) and a stride of 2 to generate a feature of size (C2, H / 2, W / 2), which is multiplied element-wise with the output weights of the above spatial attention structure to generate a spatial attention weighted feature. (C2, H / 2, W / 2); (3) Among them, G 12 Represents the convolution module, including convolution layer, BN and ReLU, and A1 represents the spatial attention structure; (3.4) The second layer feature x of the global branch g2 Pass it to the convolution layer, BN layer and ReLU layer with a convolution kernel of (C2, 1, 1) and a step size of 1 to generate an output feature of size (C2, H / 2, W / 2); combine this output feature with the above-mentioned spatial attention weighted feature S g1 Sum each element to get the output feature F g2 ; (4) Among them, G2 represents the convolution module, including convolution layer, BN and ReLU; (3.5) For the above output features Perform the global maximum pooling operation to obtain the corresponding global features, expressed as ;Will The convolution layer with a convolution kernel of (256, 1, 1) is passed in for dimensionality reduction to generate output features ; (4) In the binary branch, a feature enhancement structure based on the attention mechanism and feature fusion strategy is constructed to extract features. The processing flow of the feature enhancement structure based on the attention mechanism and feature fusion strategy is as follows: (4.1) The difference between the feature enhancement structure based on the attention mechanism and feature fusion strategy in step (4) and the feature enhancement structure based on the attention mechanism and feature fusion strategy in step (3) is that the step size of all convolution structures is 1, and the output feature is generated on this basis. ; (4.2) Make a bisection cut in the height direction of the output feature of the binary branch to generate two binary feature maps. Perform a global maximum pooling operation on each binary feature map to obtain the corresponding binary local features, which are passed to the convolution layer with a convolution kernel of (256, 1, 1) for dimensionality reduction processing to generate local features, which are expressed as and ; For the above output features Perform the global maximum pooling operation to obtain the corresponding binary branch global features, expressed as ;Will The convolution layer with a convolution kernel of (256, 1, 1) is passed in for dimensionality reduction to generate output features ; (5) In the three branches, a feature enhancement structure based on the attention mechanism and feature fusion strategy is constructed to extract features. The processing flow of the feature enhancement structure based on the attention mechanism and feature fusion strategy is as follows: (5.1) The difference between the feature enhancement structure based on the attention mechanism and feature fusion strategy in step (5) and the feature enhancement structure based on the attention mechanism and feature fusion strategy in step (3) is that the step size of all convolution structures is 1, and the output feature is generated on this basis. ; (5.2) Make a three-equal cut in the height direction of the output feature of the three-branch to generate three three-branch feature maps. Perform a global maximum pooling operation on each three-branch feature map to obtain the corresponding three-branch local features, which are respectively passed into the convolution layer with a convolution kernel of (256, 1, 1) for dimensionality reduction processing to generate local features, which are expressed as , and ; For the above output features Perform the global maximum pooling operation to obtain the corresponding three-branch global features, expressed as ;Will The convolution layer with a convolution kernel of (256, 1, 1) is passed in for dimensionality reduction to generate output features ; (6) Calculate the loss based on global features and local features, including triplet loss and Softmax loss; (7) Input the images in the query set into the trained network, concatenate the output features of the three branches, calculate the distance between the features of the query image in the query set and the features of the prototype image set, and realize person re-identification.

2. The pedestrian re-identification method based on attention mechanism and feature fusion strategy according to claim 1 is characterized in that: The construction process of the global branch structure described in step (2) is as follows: the backbone network output feature Conv4_2 of size (C, H, W) is passed to two convolution structures; the first convolution structure contains a convolution layer with a convolution kernel size of (C1, 1, 1) and a stride of 1, followed by a batch normalization function (BN) and an activation function ReLU, and the output feature x g1 The size of is (C1, H, W); the second convolutional layer contains a convolutional layer with a kernel size of (C2, 1, 1) and a stride of 2, followed by a BN layer and a ReLU layer, and the output feature x g2 The dimensions are (C2, H / 2, W / 2).

3. The pedestrian re-identification method based on attention mechanism and feature fusion strategy according to claim 1, characterized in that: The construction process of the binary branch structure described in step (2) is as follows: the backbone network output feature Conv4_2 of size (C, H, W) is passed to two convolution structures respectively; the first convolution structure contains a convolution layer with a convolution kernel size of (C1, 1, 1) and a stride of 1, followed by BN and ReLU, and the output feature x p21 The size of is (C1, H, W); the second convolutional layer contains a convolutional layer with a kernel size of (C2, 1, 1) and a stride of 1, followed by BN and ReLU, and the output feature x p22 The dimensions are (C2, H, W).

4. The pedestrian re-identification method based on attention mechanism and feature fusion strategy according to claim 1, characterized in that: The construction process of the three-branch structure described in step (2) is as follows: the backbone network output feature Conv4_2 of size (C, H, W) is passed to two convolution structures respectively; the first convolution structure contains a convolution layer with a convolution kernel size of (C1, 1, 1) and a stride of 1, followed by BN and ReLU, and the output feature x p31 The size of is (C1, H, W); the second convolutional layer contains a convolutional layer with a kernel size of (C2, 1, 1) and a stride of 1, followed by BN and ReLU, and the output feature x p32 The dimensions are (C2, H, W).

5. The pedestrian re-identification method based on attention mechanism and feature fusion strategy according to claim 1, characterized in that: The loss calculation formula in step (6) is as follows: (5) Among them, N represents the number of samples in each batch during training, C represents the number of sample categories, and fi represents the number of samples involved in the softmax loss calculation. and ; yi represents the category label corresponding to fi, Wyi represents the weight, T represents the transposition; represents the boundary between the positive sample pair and the negative sample pair, , and Represents the feature vectors corresponding to anchor samples, positive samples, and negative samples, whose features come from , and .

6. The pedestrian re-identification method based on attention mechanism and feature fusion strategy according to claim 1, characterized in that: The specific form of the output features described in step (7) is: (6)。 7. A person re-identification system based on attention mechanism and feature fusion strategy, characterized in that: include: The pedestrian re-identification dataset selection module is used to select the pedestrian re-identification dataset, training set, query set and prototype image set; The branch structure building module is used to select the backbone network ResNet and build a branch structure on the output feature Conv4_2 of ResNet, including global branch, binary branch and tri-branch; The global branch feature extraction module is used to construct a feature enhancement structure based on the attention mechanism and feature fusion strategy in the global branch to extract features; The processing flow of the feature enhancement structure based on the attention mechanism and feature fusion strategy is as follows: (3.1) The backbone network output feature Conv4_2 (C, H, W) is passed into the spatial attention structure, which includes a convolution layer with a kernel size of (1, 1, 1), a step size of 1, and a Sigmoid activation function to generate a spatial attention structure output weight of size (1, H, W); at the same time, Conv4_2 is passed into two convolution modules to generate a feature of size (C1, H, W), which is multiplied element by element with the output weight of the above spatial attention structure to generate the spatial attention weighted feature S g0 (C1, H, W); (1) Among them, G0 represents two convolution modules, including convolutional layers, BN and ReLU, A0 represents the spatial attention structure, x0 represents the output feature Conv4_2 of the backbone network, S g0 Represents the spatial attention weighted features of the output; (3.2) The first layer feature x of the above global branch g1 Pass it to the convolution layer, BN layer and ReLU layer with a convolution kernel of (C1, 1, 1) and a step size of 1 to generate an output feature of size (C1, H, W); combine this output feature with the above-mentioned spatial attention weighted feature S g0 Sum each element to get the output feature F g1 ; (2) Among them, G 11 Represents the convolution module, including convolution layer, BN and ReLU, x g1 Represents the first layer output features of the global branch; (3.3) x g1 (C1, H, W) is passed into the spatial attention structure, which includes a convolutional layer with a kernel size of (1, 1, 1), a stride of 2, and a Sigmoid activation function to generate the output weights of the spatial attention structure with a size of (1, H / 2, W / 2); at the same time, Pass in a convolution module with a convolution kernel of (C2, 1, 1) and a stride of 2 to generate a feature of size (C2, H / 2, W / 2), which is multiplied element-wise with the output weights of the above spatial attention structure to generate a spatial attention weighted feature. (C2, H / 2, W / 2); (3) Among them, G 12 Represents the convolution module, including convolution layer, BN and ReLU, and A1 represents the spatial attention structure; (3.4) The second layer feature x of the global branch g2 Pass it to the convolution layer, BN layer and ReLU layer with a convolution kernel of (C2, 1, 1) and a step size of 1 to generate an output feature of size (C2, H / 2, W / 2); combine this output feature with the above-mentioned spatial attention weighted feature S g1 Sum each element to get the output feature F g2 ; (4) Among them, G2 represents the convolution module, including convolution layer, BN and ReLU; (3.5) For the above output features Perform the global maximum pooling operation to obtain the corresponding global features, expressed as ;Will The convolution layer with a convolution kernel of (256, 1, 1) is passed in for dimensionality reduction to generate output features ; The binary branch feature extraction module is used to construct a feature enhancement structure based on the attention mechanism and feature fusion strategy in the binary branch to extract features; the processing flow of the feature enhancement structure based on the attention mechanism and feature fusion strategy is as follows: (4.1) The difference between the feature enhancement structure based on the attention mechanism and feature fusion strategy in step (4) and the feature enhancement structure based on the attention mechanism and feature fusion strategy in step (3) is that the step size of all convolution structures is 1, and the output feature is generated on this basis. ; (4.2) Make a bisection cut in the height direction of the output feature of the binary branch to generate two binary feature maps. Perform a global maximum pooling operation on each binary feature map to obtain the corresponding binary local features, which are passed to the convolution layer with a convolution kernel of (256, 1, 1) for dimensionality reduction processing to generate local features, which are expressed as and ; For the above output features Perform the global maximum pooling operation to obtain the corresponding binary branch global features, expressed as ;Will The convolution layer with a convolution kernel of (256, 1, 1) is passed in for dimensionality reduction to generate output features ; The three-branch feature extraction module is used to construct a feature enhancement structure based on the attention mechanism and feature fusion strategy in the three-branch to extract features; the processing flow of the feature enhancement structure based on the attention mechanism and feature fusion strategy is as follows: (5.1) The difference between the feature enhancement structure based on the attention mechanism and feature fusion strategy in step (5) and the feature enhancement structure based on the attention mechanism and feature fusion strategy in step (3) is that the step size of all convolution structures is 1, and the output feature is generated on this basis. ; (5.2) Make a three-equal cut in the height direction of the output feature of the three-branch to generate three three-branch feature maps. Perform a global maximum pooling operation on each three-branch feature map to obtain the corresponding three-branch local features, which are respectively passed into the convolution layer with a convolution kernel of (256, 1, 1) for dimensionality reduction processing to generate local features, which are expressed as , and ; For the above output features Perform the global maximum pooling operation to obtain the corresponding three-branch global features, expressed as ;Will The convolution layer with a convolution kernel of (256, 1, 1) is passed in for dimensionality reduction to generate output features ; The loss calculation module is used to calculate the loss based on global features and local features, including triple loss and Softmax loss; The pedestrian re-identification module is used to input the images in the query set into the trained network, splice the output features of the three branches, calculate the distance between the features of the query image in the query set and the image features of the prototype image set, and realize pedestrian re-identification.

8. A person re-identification device based on attention mechanism and feature fusion strategy, characterized in that: It includes a memory and one or more processors, wherein the memory stores executable code, and when the one or more processors execute the executable code, it is used to implement the pedestrian re-identification method based on the attention mechanism and feature fusion strategy described in any one of claims 1-6.

9. A computer-readable storage medium, characterized in that: A program is stored thereon, and when the program is executed by a processor, the pedestrian re-identification method based on the attention mechanism and feature fusion strategy described in any one of claims 1-6 is implemented.