A pedestrian re-identification method, intelligent terminal and computer-readable storage medium
Through the feature fusion and meta-learning framework of the feature encoder and memory memory, the problem of insufficient generalization ability of the pedestrian re-identification model when there is insufficient data is solved, the recognition accuracy and robustness are improved, and it is suitable for efficient recognition of densely populated areas. .
Patent Information
- Application Number
- CN202110276486.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-03-15
- Publication Date
- 2024-09-27
- Estimated Expiration
- 2041-03-15
AI Technical Summary
Existing pedestrian re-identification models lack generalization ability and robustness, especially when the amount of data is insufficient, it is difficult to maintain high recognition accuracy in practical applications, and the cost of data annotation is high, making it difficult to extend it to real life.
The feature fusion method of feature encoder and memory memory is adopted, few-shot learning is carried out through the meta-learning framework, the memory memory is used to cache features that cannot be recognized during the training process, and the expression ability of the initial features is enhanced through the feature fusion model to improve the recognition accuracy.
It improves the generalization ability and robustness of the pedestrian re-identification model, reduces the dependence on massive data, reduces data annotation costs, and achieves efficient pedestrian identification in densely populated areas.
Smart Images

Figure CN112949534B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of artificial intelligence, and in particular to a pedestrian re-identification method, an intelligent terminal and a computer-readable storage medium. Background Art
[0002] With the increasing development of science and technology and the improvement of public safety awareness, a large number of surveillance cameras are distributed in public places and key traffic roads, such as railway stations, airports, and libraries. The main function of surveillance cameras is to record events that occur in the environment. When some unexpected events occur, they can truly record the process of occurrence. The most important point in recording events is to record people's behavior. In areas with sparse personnel, a certain target can be effectively checked and monitored, but in areas with dense personnel, it is often necessary to identify the behavior of each person one by one, which consumes a lot of manpower and material resources. Moreover, negligence often occurs in the process of identification, resulting in low efficiency. On the other hand, although the distribution of surveillance cameras is relatively dense, there are still certain blind spots, and only some features of the target can be recorded, making it difficult to effectively identify them. To address this problem, pedestrian re-identification technology came into being.
[0003] Person re-identification technology uses a query image to search and match in a massive database to obtain discriminative features to distinguish images from the same person. Currently, person re-identification technology is mainly carried out using supervised learning. To improve the accuracy of recognition, a massive amount of data is required, and data labeling requires a lot of manpower and financial resources. Especially for images collected across cameras, pedestrian association is a very tedious step.
[0004] The technical process of pedestrian re-identification can be divided into two stages, namely feature extraction and feature matching. In the feature extraction stage, a large number of labeled data samples are used to train a neural network as a pedestrian identity classifier. The neural network can extract the features of pedestrians in the image, so the classifier is used as a feature extractor to extract the embedded features of the query image and the image in the database. In the feature matching stage, distance metric functions such as Euclidean distance and cosine distance are used to measure the similarity between the query image and the image in the database, and sort and recall are performed based on the similarity. However, deep learning technology has a strong dependence on the amount of data. When the amount of data is insufficient, although the model can achieve better training effects within the sample, it lacks generalization ability, and the effect in actual application is far from that in training. The high cost of data annotation makes it difficult for supervised methods to be extended to real life. Therefore, how to use a small number of samples to train the model and finally obtain a model with strong generalization ability and robustness is a key issue in the current field of pedestrian re-identification. Summary of the invention
[0005] The main purpose of the present invention is to provide a pedestrian re-identification method, an intelligent terminal and a computer-readable storage medium, aiming to solve the problem that the pedestrian re-identification model in the prior art lacks generalization ability and robustness.
[0006] To achieve the above object, the present invention provides a pedestrian re-identification method, which comprises the following steps:
[0007] Get a query image;
[0008] Inputting the query image into a trained feature encoder, and encoding the query image by the feature encoder to obtain initial features corresponding to the query image;
[0009] The initial feature is combined with each memory feature in a preset memory storage to obtain a query feature corresponding to the query image;
[0010] The comparative similarity between the query feature and a plurality of preset target features is calculated, and the target classification corresponding to the query image is determined according to the comparative similarity.
[0011] Optionally, the pedestrian re-identification method, wherein the step of fusing the initial feature with each memory feature in a preset memory storage to obtain a query feature corresponding to the query image, specifically includes:
[0012] Calculating the memory similarity value between the initial feature and each memory feature in the preset memory storage;
[0013] According to the memory similarity values corresponding to the respective memory features, the memory features and the initial features are fused to obtain the query features corresponding to the query image.
[0014] Optionally, the person re-identification method, wherein before the step of inputting the query image into a trained feature encoder and encoding the query image by the feature encoder to obtain initial features corresponding to the query image, further comprises:
[0015] Acquire a training image set, wherein the training image set includes a plurality of training subsets;
[0016] For each training subset, an anchor training image and a sample image in the training subset are input into a preset initial encoder, and the anchor training image and the sample image are encoded by the initial encoder to obtain an anchor feature corresponding to the anchor training image and a sample feature corresponding to the sample image, wherein the sample image includes a positive training image and / or a negative training image;
[0017] Calculating a training similarity value between the anchor training feature and the sample feature, and determining a predicted label corresponding to the anchor training image based on the training similarity value;
[0018] Based on the predicted labels and the training labels in the training subset, the parameters of the initial encoder are adjusted until the initial encoder converges to obtain the feature encoder.
[0019] Optionally, the pedestrian re-identification method, wherein the encoding of the anchor training image by the initial encoder to obtain the anchor feature corresponding to the anchor training image specifically includes:
[0020] For each training image in the training image set, input the training image into a preset first encoder, and encode the training image by the first encoder to obtain an intermediate feature corresponding to the training image;
[0021] Inputting the intermediate feature into a preset first decoder, and encoding the intermediate feature through the first decoder to obtain a predicted label corresponding to the training image;
[0022] Based on the predicted label and the label feature corresponding to the training image, adjusting parameters of the first encoder and the first decoder until the first encoder and the first decoder converge to obtain a trained second encoder and a second decoder, wherein the label feature is an embedding vector corresponding to the training label corresponding to the training image;
[0023] Based on the second encoder, the anchor training image is encoded to obtain an anchor feature corresponding to the anchor training image.
[0024] Optionally, the person re-identification method, wherein after calculating the training similarity value between the anchor training feature and the sample feature and determining the predicted label corresponding to the anchor training image based on the training similarity value, further comprises:
[0025] Calculating an evaluation value between the predicted label and the training label;
[0026] Determining whether the anchor training image is a low recognition image according to the evaluation value and a preset evaluation threshold;
[0027] If the anchor training image is the low recognition image, the anchor training image and the anchor training image are used as memory features, and the memory features and the training labels corresponding to the memory features are written into the memory storage.
[0028] Optionally, the person re-identification method, wherein the initial encoder is adjusted based on the predicted label and the training label in the training subset until the initial encoder converges to obtain the feature encoder, further comprises:
[0029] Based on the feature encoder, the memory features in the memory storage are updated.
[0030] Optionally, the pedestrian re-identification method, wherein the step of fusing the memory features with the initial features according to the memory similarity values corresponding to the respective memory features to obtain the query features corresponding to the query image, specifically includes:
[0031] Classifying the memory features according to the memory similarity values corresponding to the respective memory features, and determining relevant features among the memory features that are relevant to the initial features;
[0032] The initial features, the relevant features, the training labels corresponding to the relevant features, and the memory similarity values are input into a trained feature fusion model, and the feature fusion model is used to perform feature fusion on the initial features, the relevant features, and the training labels corresponding to the relevant features according to the memory similarity values to obtain the query features corresponding to the query image.
[0033] Optionally, the person re-identification method, wherein the initial features, the relevant features, the training labels corresponding to the relevant features, and the memory similarity values are input into a trained feature fusion model, and the initial features, the relevant features, and the training labels corresponding to the relevant features are fused according to the memory similarity values by the feature fusion model to obtain the query features corresponding to the query image, specifically includes:
[0034] Concatenating the initial features, the relevant features, and the training labels corresponding to the relevant features to obtain a concatenated matrix corresponding to the initial features;
[0035] Inputting the splicing matrix into a feature decoder in the feature fusion model, and adjusting the eigenvalues of the splicing matrix through the feature decoder to obtain a target matrix corresponding to the splicing matrix; and,
[0036] Calculate the weight value corresponding to each of the related features according to the memory similarity value;
[0037] According to the weight values, the inner product of the target matrix is performed to obtain the initial features corresponding to the query image.
[0038] Optionally, in the pedestrian re-identification method, the network structure of the feature decoder is a residual network structure; the residual network structure includes a plurality of convolution modules and residual modules.
[0039] Optionally, in the pedestrian re-identification method, the convolution module includes multiple attention layers.
[0040] In addition, to achieve the above-mentioned purpose, the present invention also provides an intelligent terminal, wherein the intelligent terminal includes: a memory, a processor, and a pedestrian re-identification program stored on the memory and executable on the processor, and when the pedestrian re-identification program is executed by the processor, the steps of the pedestrian re-identification method as described above are implemented.
[0041] In addition, to achieve the above-mentioned purpose, the present invention also provides a computer-readable storage medium, wherein the computer-readable storage medium stores a pedestrian re-identification program, and when the pedestrian re-identification program is executed by a processor, the steps of the pedestrian re-identification method as described above are implemented.
[0042] In the present invention, a query image to be queried is first obtained. Then the query image is input into a trained feature encoder, which can extract and compress the input query image to achieve an encoding effect, thereby obtaining the initial features corresponding to the query image. The initial features are then fused with the memory features in a preset memory storage device. The memory features are features corresponding to the training images that cannot be effectively identified during the training of the model. By fusion with the memory features, the expression of the initial features can be enhanced, thereby improving the distinction between the subsequent target features and the database, thereby achieving the effect of improving the accuracy of recognition. BRIEF DESCRIPTION OF THE DRAWINGS
[0043] Figure 1 This is the first flow chart of a preferred embodiment of the pedestrian re-identification method provided by the present invention;
[0044] Figure 2 is a second flow chart of a preferred embodiment of the pedestrian re-identification method provided by the present invention;
[0045] Figure 3 It is a ResNet series network structure diagram adopted by the encoder of the preferred embodiment of the pedestrian re-identification method provided by the present invention;
[0046] Figure 4 It is a training sample set and a sample set of meta-test in a preferred embodiment of the pedestrian re-identification method provided by the present invention;
[0047] Figure 5 It is the process of storing memory features in the preferred embodiment of the pedestrian re-identification method provided by the present invention;
[0048] Figure 6 This is the process of fusing initial features in a preferred embodiment of the pedestrian re-identification method provided by the present invention;
[0049] Figure 7 Schematic diagram of the operating environment of a preferred embodiment of the intelligent terminal of the present invention. DETAILED DESCRIPTION
[0050] In order to make the purpose, technical solution and advantages of the present invention clearer and more specific, the present invention is further described in detail below with reference to the accompanying drawings and examples. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not used to limit the present invention.
[0051] The pedestrian re-identification method described in the preferred embodiment of the present invention can be executed by a smart terminal, or by a certain software, plug-in, etc. of the smart terminal, and the smart terminal includes terminals such as smart TVs and smart phones. This embodiment takes the pedestrian re-identification software installed in the smart terminal as an example to describe the pedestrian re-identification process. Figure 1 and Figure 2 The pedestrian re-identification method comprises the following steps:
[0052] Step S100, obtaining a query image.
[0053] Specifically, the first pedestrian re-identification software obtains the query image by scanning, importing, etc. The query image in this embodiment refers to an image including pedestrians obtained by a monitoring device such as a camera. Since the image obtained by the monitoring device includes images with and without pedestrians, before obtaining the query image, if the original data is a monitoring video taken by the monitoring device, each frame of the monitoring video is identified to determine whether each frame contains a person recognition. If so, the frame is determined to be a person image including a pedestrian. Pedestrians are then extracted from the person image to obtain a query image containing the entire single pedestrian, thereby extracting the pedestrian in the monitoring video. The pedestrian re-identification software then obtains the query image by scanning, etc.
[0054] Step S200: input the query image into a trained feature encoder, and encode the query image through the feature encoder to obtain initial features corresponding to the query image.
[0055] Specifically, the feature encoder can encode the input data and convert it into another form of data. In terms of feature extraction, the main function of the encoder is to extract and compress the features of the query image, thereby encoding it into a low-dimensional feature vector.
[0056] In this embodiment, the encoder is a mapping function that maps the input data xt, which is the query image in the application, to a lower-dimensional feature vector et, i.e., the query feature. The encoder can be constructed using the current convolutional network structure, and in order to better achieve the encoding effect, the network structure can be selected and adjusted according to the mapping object. The encoder used in this embodiment is preferably a residual network structure as an encoder, such as the ResNet series in the residual network, such as Figure 3 When building an encoder, the neural network for building the encoder can be determined based on the effect of the residual network itself and the characteristics of the mapping object.
[0057] Furthermore, in order to enhance the learning effectiveness of few-shot learning, this embodiment adopts few-shot learning based on a meta-learning framework. The learning process is divided into a meta-learning phase and a meta-test phase, and the corresponding training data set and test set also need special processing. Few-shot learning is usually divided into an N-way K-shot problem. In the pedestrian re-identification scenario, N is the number of pedestrian ID categories, and K refers to the number of K samples under each pedestrian ID. Figure 4 The 6-way 1-shot scenario is shown. The meta-learning training set of 6 pedestrian images of different ID categories and a training image of a known real category (with category annotation) constitutes the input of a small batch. In the meta-test phase, new pedestrian images of 6 ID types and a query image (without category annotation) are given to identify the category of the query image. Therefore, in this embodiment, each training label in the training image set corresponds to multiple training images, for example, it contains six training labels, named pedestrian A, pedestrian B, pedestrian C, pedestrian D, pedestrian E and pedestrian F. The training process is specifically as follows:
[0058] Step A10, obtaining a training image set.
[0059] First, a large number of training images are obtained, and the training images include a training image set of multiple training subsets. In this embodiment, the training adopts a meta-training method, such as a triplet network (Triplet Network) and a Siamese network (Siamese Network). This embodiment takes the triplet network as an example for a specific description. Based on the triplet network, the training subset includes three training images, including an anchor training image, a positive training image and a negative training image. The anchor training image has the same training label as the positive training image, for example, both are pedestrian A, and the other training image has a different training label from the other two training images, for example, pedestrian B. During the training process, it is assumed that the training label corresponding to the anchor training image is unknown, and the positive training image is labeled as x. + , label the negative training image as x -If the network used is a twin network, the training subset contains two image groups, each of which includes an anchor training image. In one image group, the other training image is a positive training image; in the other image group, the other training image is a negative training image. Therefore, the positive training images and negative training images are summarized as sample images, and each training subset includes anchor training images and sample images, and the sample images include positive training images and negative training images.
[0060] Step A20, for each training subset, input the anchor training image and sample image in the training subset into a preset initial encoder, and encode the anchor training image and the sample image through the initial encoder to obtain the anchor feature corresponding to the anchor training image and the sample feature corresponding to the sample image.
[0061] Specifically, for each training subset, the anchor training image and sample image in the training subset are input into a preset initial encoder, and the initial encoder encodes the anchor training image and the sample image respectively to obtain anchor features corresponding to the anchor training image and sample features corresponding to the sample image.
[0062] Furthermore, the initial encoder used in this embodiment is obtained by training a combination of encoders and decoders. Before using the initial encoder, the encoder and decoder are first trained as a combination. In this embodiment, in order to distinguish the encoder and decoder during training, they are named the first encoder and the first decoder.
[0063] For each training image in the training image set, the training image is input into a preset first encoder, and the training image is encoded by the first encoder to obtain an intermediate feature corresponding to the training image.
[0064] The intermediate feature is input into a preset first decoder, and the first decoder then encodes the intermediate feature to obtain a prediction feature corresponding to the intermediate feature, and based on the prediction feature, the prediction label corresponding to the training image is determined.
[0065] Then, based on a preset second loss function, a second loss value between the predicted label and the training label corresponding to the training image is calculated. Then, based on the second loss value, parameters of the first encoder and the first decoder are adjusted until the first encoder and the first decoder converge to obtain a trained second encoder and a second decoder.
[0066] Finally, the second encoder obtained through training is used to encode the anchor training image or the sample training image, so as to obtain the anchor training features corresponding to the anchor training image and the sample training features corresponding to the sample training image.
[0067] Step A30, calculating the training similarity value between the anchor training feature and the sample feature, and determining the predicted label corresponding to the anchor training image based on the training similarity value.
[0068] Specifically, the training similarity value between the anchor training feature and the sample training feature is then calculated. The training similarity value between the two can be calculated using similarity metrics such as cosine similarity value and Euclidean distance. The similarity between the anchor training feature and the sample training feature calculated by these similarity metrics is calculated.
[0069] Still taking the triplet network as an example, the training similarity value between the anchor training feature and the positive training feature is the positive distance, while the negative distance between the anchor training image and the negative training feature is the negative distance.
[0070] Then, the training similarity values are compared, and the training label corresponding to the sample training feature corresponding to the largest training similarity value is generally selected as the predicted label corresponding to the anchor training image.
[0071] Step A40: Based on the predicted labels and the training labels in the training subset, the parameters of the initial encoder are adjusted until the initial encoder converges to obtain the feature encoder.
[0072] Specifically, based on the preset first loss function, the first loss value between the predicted label and the training label is calculated, and then the first loss value is transmitted back to the initial encoder to adjust the parameters of the initial encoder until the initial encoder converges, and the converged initial encoder is used as the feature encoder.
[0073] Since the negative training images and the anchor training images are not of the same category, theoretically the negative distance value should be larger, while the positive distance should be smaller. A margin threshold is set in advance, and the loss value is calculated based on the positive distance, negative distance, and margin threshold. The larger the difference between the positive distance and the negative distance, the more effective it is for the features mapped by the current encoder to distinguish different classification labels. Therefore, the larger the difference between the two, the better. The margin threshold is the minimum margin between the two, and 1 is generally used.
[0074] In the process of training the encoder, based on the anchor training images in each training subset, according to the positive distance and negative distance corresponding to the anchor training image, there will be a predicted label, that is, the label obtained by classifying the anchor training image based on the current encoder. If the difference between the predicted label and the true label for a certain anchor training image is larger, it means that it cannot be accurately identified at present. The true label is the classification label actually corresponding to the anchor training image. Generally, training based on large samples will optimize the part with low accuracy through a large number of samples. However, since this embodiment is to solve a small number of samples, if the samples that cannot be accurately identified are ignored, it will cause a lack of generalization ability.
[0075] Therefore, in this embodiment, if Figure 5 As shown, e is the second encoder, d is the second decoder, M is the memory, and C is the controller, which determines whether the currently observed anchor training image should be stored in the memory module. The memory module does not need back propagation. During the training process, when the recognition result accuracy of a certain anchor training image is low, the anchor training image can be stored in the memory.
[0076] The recognition accuracy of the anchor training image can be evaluated by using an evaluation function, and the evaluation function can be a conventional loss function, such as a cross entropy function: Among them, y is the training label, is the predicted label. Intuitively speaking, the more accurate the prediction of the anchor training image is, the lower the evaluation value obtained by the evaluation function is.
[0077] An evaluation threshold is set in advance, and the evaluation threshold can be used as a confidence level, σ∝-ln(N), where N is the number of types of training labels contained in the training image set, that is, the number of classification categories in the previous text, and σ is the evaluation threshold. If the evaluation value is greater than the evaluation threshold, it means that the prediction execution degree is less than the probability of a tie prediction, that is, the current model has a low classification accuracy for the anchor training image, and the anchor training image is a low recognition image. Therefore, the anchor training image needs to be memorized and stored, so the anchor training image and the anchor training image are used as memory features, and the memory features and the training labels corresponding to the memory features are written into the memory storage device; if the evaluation value is less than the evaluation threshold, the current model has a high classification accuracy for the anchor training image, so it does not need to be stored. The process is as follows:
[0078] M key [index]=e t ;
[0079] M value [index]=l t ;
[0080] Among them, e t Indicates memory characteristics, l t Indicates memory characteristics t The corresponding label, M key Used to store memory features, while M value Used to store the label corresponding to each memory feature. The size of the memory storage M size >batchsize×number of iterations, if ndex>M size , then index = 0, that is, start again from position 0; otherwise index = index + 1.
[0081] In the memory storage process, the storage mode adopted is the key-value storage mode. The key represents the anchor training image, and the value represents the training label corresponding to the anchor training image. Furthermore, in order to improve the utilization efficiency of the memory storage, the anchor training features corresponding to the anchor training image are stored as the key. After obtaining the feature encoder, the anchor training features stored as the key are updated based on the feature encoder so that the memory features in the memory storage that are finally applied are the latest features.
[0082] Step S300: Fusing the initial feature with each memory feature in a preset memory storage device to obtain a query feature corresponding to the query image.
[0083] Specifically, a memory storage is pre-set, and the memory storage is used to store memory features. The memory features in this embodiment refer to training features with poor encoding effects in the process of training the initial encoder to obtain the feature encoder, or training features with poor feature fusion effects in the process of training the model for feature fusion. In other words, the memory features are training features with poor classification effects in the process of model training.
[0084] Since the classification effect of the memory feature is poor, it also means that when there are features similar to the memory feature in the initial feature, the recognition result of the initial feature is likely to be poor. Therefore, in this embodiment, the memory feature is fused with the initial feature to enhance the features in the initial feature that are more similar to the memory feature to obtain the query feature.
[0085] In the first implementation of this embodiment, the memory similarity value between the initial feature and each memory feature in the preset memory storage is calculated first, and for each memory feature, the memory feature is fused according to the size of the memory similarity value between the memory feature and the initial feature. The larger the similarity value, the more fused parts; the smaller the similarity value, the fewer fused parts.
[0086] In the second implementation of this embodiment, the memory features are first screened. Since the memory features with smaller similarity are not very helpful in determining the classification category corresponding to the query image, in this embodiment, the memory features with smaller similarity are first excluded from the memory features to obtain relevant features that are helpful for classifying the query image. The exclusion method can be performed using a classification algorithm such as a K nearest neighbor classification algorithm to divide the memory features into features related to the initial features and features unrelated to the initial features, and the memory features related to the initial features are used as relevant features for subsequent fusion.
[0087] The method of excluding memory features can be achieved by using the distance between the memory features and the initial features. Calculate the distance between the initial feature and each memory feature, and record it as the memory similarity corresponding to the memory feature. The memory similarity calculation method can use Euclidean distance calculation. Then, according to the size of the memory similarity value, select the first K memory features in the memory similarity value as relevant features. It can be expressed as:
[0088] {e 1 ,e 2 ,…,e m}=top k (d(e i ,q t ));
[0089] Among them, e i Represents memory characteristics, q t is the initial feature, d(e i ,q t ) means e i With q t If the Euclidean distance is used, then k=K.
[0090] Then, the initial features, the relevant features, the training labels corresponding to the relevant features, and the memory similarity values are input into a trained feature fusion model, and the feature fusion model is used to perform feature fusion on the initial features, the relevant features, and the training labels corresponding to the relevant features according to the memory similarity values to obtain the query features corresponding to the query image.
[0091] For the set {q t ,e 1 ,…,e m ,l 1 ,…,l m ,d 1 ,…,d m}, in order to unify the way of fusing each initial feature, the initial feature, the related features, and the true label corresponding to each related feature are first concatenated to obtain the concatenated matrix. t(t∈[1,m]) is the relevant feature, l t (t∈[1,m]) is the relevant feature e t The corresponding label embedding feature, d t (t∈[1,m]) is the relevant feature e t The corresponding memory similarity value. The splicing method can be achieved by storing it as a separate data in a certain order. First, a blank matrix is preset. Figure 6 The position relationship shown in the figure is written into the blank matrix with the relevant features, the training labels corresponding to each relevant feature and the initial features, so as to obtain the concatenated matrix, E = [q t ,e 1…m ,l 1…m ].
[0092] Then, the splicing matrix is input into the feature decoder in the feature fusion model, and the feature decoder is used to adjust the eigenvalues of the splicing matrix to obtain a target matrix corresponding to the splicing matrix. Since the selected related features are all features associated with the initial features, the main purpose of feature adjustment on the splicing matrix is to enhance the associated features between the related features and the initial features, so that these associated features can be effectively used in subsequent classification.
[0093] Furthermore, in order to reduce information loss and improve the accuracy of the model, the decoder's network architecture also adopts a residual network architecture. The decoder contains several residual modules and convolution modules. The input of the next convolution module includes the output of the previous convolution module and the residual value of the previous residual module output. The residual network structure includes several convolution modules and residual modules.
[0094] Furthermore, the convolution module in this embodiment may adopt a multi-head attention layer (Multihead Attention), which can realize multi-dimensional attention to the input value, thereby improving the effectiveness of subsequent fusion. Furthermore, in the convolution module, a multi-layer perceptron (Multi-layer Perceptron, MLP) is also applied. The splicing matrix is first input into a multi-attention layer, which compares all elements and returns a new tensor of the same shape; then this new tensor is passed through an activation function layer to calculate the nonlinear activation of the model. Several subsequent multi-head attention layers are repeated multiple times in the form of residuals. During this process, the dimension of the tensor remains unchanged, and finally a target matrix is obtained. The process of obtaining the target matrix is the process of extracting and reprocessing the features of each vector, and what ultimately determines the fusion of each related vector to the initial vector is the correlation between the initial vector and the related vector, which is the memory similarity value mentioned above.
[0095] Therefore, in the process of processing the splicing matrix by the decoder, the memory similarity value is first converted as a whole into a weight value. In this embodiment, a softmax function or the like can be used to implement the normalization of the memory similarity value and map it to a value of (0, 1). Finally, the weight value and the target matrix are inner-producted to obtain the query feature corresponding to the query image.
[0096] In this embodiment, the feature decoder in the feature fusion model can adopt the second decoder mentioned above. If the second decoder mentioned above is adopted, when the first decoder is trained based on the training image, the first decoder will fuse the intermediate features with the memory features when encoding the intermediate features, thereby obtaining the predicted label corresponding to the training image.
[0097] Step S400, calculating the comparative similarity between the query feature and a plurality of preset target features, and determining the target category corresponding to the query image according to the comparative similarity.
[0098] Specifically, a plurality of target features are stored in advance, and the target features are features obtained by processing the target image in the same manner as the query image, including the input feature encoder and performing the memory feature fusion process, wherein the target image is an image corresponding to the target person. For example, the target person includes a pedestrian G. The target image corresponding to the pedestrian G is input into the feature encoder, and the features output by the feature encoder are fused with the memory features to obtain the target features.
[0099] Then calculate the comparative similarity between the query feature and the target feature. Take the 6-way1-shot scenario above as an example, there is one query feature and six target features. Calculate the similarity value between the query feature and each target feature to obtain the comparative similarity corresponding to each target feature. Then, based on the comparative similarity, determine the target feature that is closest to the query feature, and use the labeled category corresponding to the target feature as the target category corresponding to the query feature.
[0100] This embodiment proposes a person re-identification framework based on memory enhancement and end-to-end training, which can perform few-sample learning by utilizing the concept of meta-learning. The task training is not at the data level, but at the task level, so it can also be applied to cross-domain datasets and has strong practical application value. In addition, a memory storage device is used to cache and record previous features. The memory device can be flexibly set and is more suitable for multi-category feature storage in person re-identification. Moreover, this embodiment also constructs a fusion network based on the self-attention mechanism to measure the similarity between the extracted memory storage device memory and the query image features, realizing the integration of feature extraction and matching in the person re-identification reasoning process.
[0101] Furthermore, if Figure 7 Based on the above-mentioned pedestrian re-identification method, the present invention also provides a smart terminal accordingly, and the smart terminal includes a processor 10, a memory 20 and a display 30. Figure 7 Only some components of the smart terminal are shown, but it should be understood that it is not required to implement all the components shown, and more or fewer components may be implemented instead.
[0102] In some embodiments, the memory 20 may be an internal storage unit of the smart terminal, such as a hard disk or memory of the smart terminal. In other embodiments, the memory 20 may also be an external storage device of the smart terminal, such as a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), etc. equipped on the smart terminal. Furthermore, the memory 20 may also include both an internal storage unit of the smart terminal and an external storage device. The memory 20 is used to store application software and various types of data installed on the smart terminal, such as the program code of the installed smart terminal. The memory 20 may also be used to temporarily store data that has been output or is to be output. In one embodiment, a pedestrian re-identification program 40 is stored on the memory 20, and the pedestrian re-identification program 40 can be executed by the processor 10, thereby realizing the pedestrian re-identification method in the present application.
[0103] In some embodiments, the processor 10 may be a central processing unit (CPU), a microprocessor or other data processing chip, used to run the program code or process data stored in the memory 20, such as executing the pedestrian re-identification method.
[0104] In some embodiments, the display 30 may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, an OLED (Organic Light-Emitting Diode) touch device, etc. The display 30 is used to display information on the smart terminal and to display a visual user interface. The components 10-30 of the smart terminal communicate with each other via a system bus.
[0105] In one embodiment, when the processor 10 executes the pedestrian re-identification program 40 in the memory 20, the following steps are implemented:
[0106] Get a query image;
[0107] Inputting the query image into a trained feature encoder, and encoding the query image by the feature encoder to obtain initial features corresponding to the query image;
[0108] The initial feature is combined with each memory feature in a preset memory storage to obtain a query feature corresponding to the query image;
[0109] The comparative similarity between the query feature and a plurality of preset target features is calculated, and the target classification corresponding to the query image is determined according to the comparative similarity.
[0110] The present invention also provides a computer-readable storage medium, wherein the computer-readable storage medium stores a pedestrian re-identification program, and when the pedestrian re-identification program is executed by a processor, the steps of the pedestrian re-identification method as described above are implemented.
[0111] Of course, those skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be implemented by instructing related hardware (such as a processor, a controller, etc.) through a computer program, and the program can be stored in a computer-readable storage medium that can be read by a computer, and the program can include the processes of the above-mentioned method embodiments when executed. The computer-readable storage medium can be a memory, a disk, an optical disk, etc.
[0112] It should be understood that the application of the present invention is not limited to the above examples. For ordinary technicians in this field, improvements or changes can be made based on the above description. All these improvements and changes should fall within the scope of protection of the claims attached to the present invention.
Claims
1. A pedestrian re-identification method, characterized in that: The pedestrian re-identification method comprises: Get a query image; Inputting the query image into a trained feature encoder, and encoding the query image by the feature encoder to obtain initial features corresponding to the query image; The initial feature is combined with each memory feature in a preset memory storage to obtain a query feature corresponding to the query image; The step of fusing the initial feature with each memory feature in a preset memory storage to obtain a query feature corresponding to the query image specifically includes: Calculating the memory similarity value between the initial feature and each memory feature in the preset memory storage; According to the memory similarity values corresponding to the respective memory features, the memory features and the initial features are merged to obtain the query features corresponding to the query image; The step of fusing the memory features with the initial features according to the memory similarity values corresponding to the memory features to obtain the query features corresponding to the query image specifically includes: Classifying the memory features according to the memory similarity values corresponding to the respective memory features, and determining relevant features among the memory features that are relevant to the initial features; Concatenating the initial features, the relevant features, and the training labels corresponding to the relevant features to obtain a concatenated matrix corresponding to the initial features; Inputting the splicing matrix into a feature decoder in the feature fusion model, and adjusting the eigenvalues of the splicing matrix by the feature decoder to obtain a target matrix corresponding to the splicing matrix; and calculating the weight value corresponding to each of the related features according to the memory similarity value; According to the weight values, inner products are performed on the target matrix to obtain query features corresponding to the query image; Before inputting the query image into the trained feature encoder and encoding the query image by the feature encoder to obtain the initial features corresponding to the query image, the method further includes: Acquire a training image set, wherein the training image set includes a plurality of training subsets; For each training subset, an anchor training image and a sample image in the training subset are input into a preset initial encoder, and the anchor training image and the sample image are encoded by the initial encoder to obtain an anchor feature corresponding to the anchor training image and a sample feature corresponding to the sample image, wherein the sample image includes a positive training image and / or a negative training image; Calculating a training similarity value between the anchor feature and the sample feature, and determining a predicted label corresponding to the anchor training image based on the training similarity value; Based on the predicted label and the training label in the training subset, adjusting the parameters of the initial encoder until the initial encoder converges to obtain the feature encoder; The initial encoder is obtained by training a combination of a first encoder and a first decoder; After calculating the training similarity value between the anchor feature and the sample feature and determining the predicted label corresponding to the anchor training image based on the training similarity value, the method further includes: Calculating an evaluation value between the predicted label and the training label; Determining whether the anchor training image is a low recognition image according to the evaluation value and a preset evaluation threshold; If the anchor training image is the low recognition image, use the anchor training image as a memory feature, and write the memory feature and the training label corresponding to the memory feature into the memory storage; The comparative similarity between the query feature and a plurality of preset target features is calculated, and the target classification corresponding to the query image is determined according to the comparative similarity.
2. The pedestrian re-identification method according to claim 1, characterized in that: The anchor training image is encoded by the initial encoder to obtain an anchor feature corresponding to the anchor training image, specifically including: For each training image in the training image set, input the training image into a preset first encoder, and encode the training image by the first encoder to obtain an intermediate feature corresponding to the training image; The intermediate feature is input into a preset first decoder, and the intermediate feature is decoded by the first decoder to obtain a predicted label corresponding to the training image; Based on the predicted label and the label feature corresponding to the training image, adjusting parameters of the first encoder and the first decoder until the first encoder and the first decoder converge to obtain a trained second encoder and a second decoder, wherein the label feature is an embedding vector corresponding to the training label corresponding to the training image; Based on the second encoder, the anchor training image is encoded to obtain an anchor feature corresponding to the anchor training image.
3. The pedestrian re-identification method according to claim 1, characterized in that: After the initial encoder is parameter-adjusted based on the predicted label and the training label in the training subset until the initial encoder converges to obtain the feature encoder, the method further includes: Based on the feature encoder, the memory features in the memory storage are updated.
4. The pedestrian re-identification method according to claim 1, characterized in that: The network structure of the feature decoder is a residual network structure; the residual network structure includes several convolution modules and residual modules.
5. The pedestrian re-identification method according to claim 4, characterized in that: The convolutional module includes multiple attention layers.
6. An intelligent terminal, characterized in that: The intelligent terminal includes: a memory, a processor, and a pedestrian re-identification program stored in the memory and executable on the processor. When the pedestrian re-identification program is executed by the processor, the steps of the pedestrian re-identification method according to any one of claims 1 to 5 are implemented.
7. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a pedestrian re-identification program, and when the pedestrian re-identification program is executed by a processor, the steps of the pedestrian re-identification method according to any one of claims 1 to 5 are implemented.
