Person re-identification network model generation method, device, computer equipment and medium
By combining labeled and unlabeled data and using pseudo-label and loss value iterative training methods, the problem of high labeling cost and low recognition accuracy in pedestrian re-identification model training is solved, and efficient pedestrian re-identification in complex scenes is achieved. .
Patent Information
- Application Number
- CN202311600346.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-11-27
- Publication Date
- 2024-09-17
- Estimated Expiration
- 2043-11-27
AI Technical Summary
Existing pedestrian re-identification model training methods require a large amount of labeled data, the cost of manual labeling is high, and the model trained by unsupervised methods has low recognition accuracy and is difficult to apply to complex scenes.
By obtaining labeled and unlabeled image data sets, use the image enhancer to enhance the unlabeled images, calculate the loss value based on the prediction results, assign pseudo labels, and combine supervised and unsupervised losses for iterative training to reduce the need for annotation data. , improve model robustness.
It effectively reduces the labeling cost, improves the model recognition accuracy, and can effectively perform pedestrian re-identification in scenarios with less labeled data.
Smart Images

Figure CN117612206B
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of pedestrian re-identification, and in particular to a method, device, computer equipment and storage medium for generating a pedestrian re-identification network model. Background Art
[0002] Person re-identification, also known as pedestrian re-identification, is a technology that uses computer vision technology to determine whether a specific pedestrian exists in an image or video sequence. It is widely considered to be a sub-problem of image retrieval, that is, given a monitored pedestrian image, the pedestrian image is retrieved across devices.
[0003] The existing training methods for person re-identification models mainly use supervised methods, that is, the model is trained and tested on a labeled data set, but this task requires a large amount of labeled data to form a labeled data set (referred to as the data set). As the data set grows, it becomes time-consuming and laborious to manually mark and generate labeled data, and the cost is too high, making it difficult to apply to complex and changeable actual scenarios. The unsupervised method is used to train completely based on unlabeled data, which is too blind and leads to a very low recognition accuracy of the trained model. Summary of the invention
[0004] Based on this, it is necessary to provide a method, device, computer equipment and storage medium for generating a pedestrian re-identification network model to solve at least one problem existing in the above-mentioned prior art.
[0005] In a first aspect, an embodiment of the present application provides a method for generating a person re-identification network model, comprising:
[0006] Obtain a sample image dataset, where the sample image dataset includes labeled images and unlabeled images;
[0007] Selecting a first preset number of labeled images and inputting them into a preset prediction network of an initial person re-identification network for prediction processing to obtain a first prediction result, and calculating a first loss value based on the first prediction result;
[0008] Selecting a second preset number of unlabeled images, and inputting them into different image enhancers for image enhancement processing, and inputting the enhanced images into the preset prediction network for prediction processing, to obtain a second prediction result and a third prediction result;
[0009] Performing feature extraction on the second preset number of unlabeled images to obtain a first feature vector, assigning a pseudo label to the target unlabeled image based on the first feature vector and the second prediction result, and calculating a second loss value based on the pseudo label and the third prediction result;
[0010] Based on the first loss value and the second loss value, a total loss value is calculated, and iterative training is performed based on the total loss value until the loss value meets a preset convergence condition, thereby obtaining a trained pedestrian re-identification network model.
[0011] In one embodiment, the selecting of a second preset number of unlabeled images and inputting them into different image enhancers for image enhancement processing respectively includes:
[0012] Inputting the second preset number of unlabeled images into a first image enhancer, and performing enhancement processing on the unlabeled images by a first enhancement method to obtain a first enhanced image;
[0013] The second preset number of unlabeled images are input into a second image enhancer, and the unlabeled images are enhanced by a second enhancement method to obtain second enhanced images.
[0014] In one embodiment, the first enhancement mode is different from the second enhancement mode, and both the first enhancement mode and the second enhancement mode may include one of flipping, translation, random scaling, and increasing brightness, or any combination thereof.
[0015] In one embodiment, the step of inputting the enhanced images into the preset prediction network for prediction processing to obtain the second prediction result and the third prediction result includes:
[0016] Inputting the first enhanced image and the second enhanced image into a feature extraction network for feature extraction respectively, so as to obtain a second feature vector and a third feature vector;
[0017] The second eigenvector and the third eigenvector are respectively input into a classification network for classification prediction to obtain a first probability distribution and a second probability distribution.
[0018] In one embodiment, selecting a first preset number of labeled images and inputting them into a preset prediction network of an initial person re-identification network for prediction processing to obtain a first prediction result includes:
[0019] Inputting the first preset number of labeled images into a preset feature extraction network for feature extraction to obtain a fourth feature vector;
[0020] The fourth feature vector is input into a classification network for classification prediction to obtain the first prediction result.
[0021] In one embodiment, assigning a pseudo label to the unlabeled image based on the first feature vector and the second prediction result includes:
[0022] Based on the second prediction result, a preset number of picture samples are selected according to the rule that the probability values of each category are from high to low, and the average value of the first feature vectors corresponding to the picture samples is used as the center of each category;
[0023] The distance value from the first feature vector to the center of each class is calculated, and the image sample with the smallest distance value is assigned a pseudo label.
[0024] In one embodiment, after obtaining the trained person re-identification network model, the following steps are included:
[0025] Obtain all pedestrian images and pedestrian images to be identified in a preset pedestrian image database, and input them into the pedestrian re-identification network model respectively to obtain image features of all pedestrian images and image features of the pedestrian to be identified;
[0026] Calculating similarity between the image features of the pedestrian to be identified and the image features of all pedestrians to obtain similarity values;
[0027] The pedestrian image with the largest similarity value is taken as the pedestrian re-identification result.
[0028] In a second aspect, a pedestrian re-identification network model generation device is provided, comprising:
[0029] A sample image acquisition unit, used to acquire an image sample data set, wherein the image sample data set includes labeled images and unlabeled images;
[0030] A first loss value calculation unit, configured to select a first preset number of labeled images and input them into a preset prediction network of an initial person re-identification network for prediction processing to obtain a first prediction result, and calculate a first loss value based on the first prediction result;
[0031] A prediction unit is used to select a second preset number of unlabeled pictures, and input them into different picture enhancers for picture enhancement processing, and input the enhanced pictures into the preset prediction network for prediction processing to obtain a second prediction result and a third prediction result;
[0032] A second loss value calculation unit is used to perform feature extraction on the second preset number of unlabeled images to obtain a first feature vector, assign a pseudo label to the target unlabeled image based on the first feature vector and the second prediction result, and calculate a second loss value based on the pseudo label and the third prediction result;
[0033] A pedestrian re-identification network model generation unit is used to calculate a total loss value based on the first loss value and the second loss value, and perform iterative training based on the total loss value until the loss value meets a preset convergence condition, thereby obtaining a trained pedestrian re-identification network model.
[0034] In a third aspect, a computer device is provided, including a memory and a processor, wherein the memory stores a computer program, and when the computer program is executed by the processor, the processor executes the method for generating a pedestrian re-identification network model as described above.
[0035] In a fourth aspect, a computer-readable storage medium is provided, storing a computer program, characterized in that when the computer program is executed by a processor, the processor executes the pedestrian re-identification network model generation method as described above.
[0036] The above-mentioned pedestrian re-identification network model generation method, device, computer equipment and storage medium, the method implementation includes: obtaining a picture sample data set, the picture sample data set includes labeled pictures and unlabeled pictures; selecting a first preset number of labeled pictures, and inputting them into the preset prediction network of the initial pedestrian re-identification network for prediction processing to obtain a first prediction result, and calculating a first loss value based on the first prediction result; selecting a second preset number of unlabeled pictures, and inputting them into different picture enhancers for picture enhancement processing, and inputting the enhanced pictures into the preset prediction network for prediction processing to obtain a second prediction result and a third prediction result; performing feature extraction on the second preset number of unlabeled pictures to obtain a first feature vector, and assigning a pseudo label to the target unlabeled picture based on the first feature vector and the second prediction result, and calculating a second loss value based on the pseudo label and the third prediction result; calculating a total loss value based on the first loss value and the second loss value, and iteratively training based on the total loss value until the loss value meets the preset convergence condition, thereby obtaining a trained pedestrian re-identification network model. In an embodiment of the present application, by using labeled images and unlabeled images to train the initial pedestrian re-identification network, the required annotation data can be greatly reduced, the cost required for annotation can be well controlled, and the pedestrian re-identification problem in scenarios with less labeled data can be solved. Secondly, by setting a pseudo-label method, the model can be better helped to learn the hidden information in the unlabeled data, improve the model robustness, and improve the model recognition accuracy. BRIEF DESCRIPTION OF THE DRAWINGS
[0037] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings required for use in the description of the embodiments of the present invention will be briefly introduced below. Obviously, the accompanying drawings in the following description are only some embodiments of the present invention. For ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without paying creative labor.
[0038] Figure 1 is a diagram of the initial person re-identification network architecture in one embodiment of the present invention;
[0039] Figure 2 It is a flow chart of a method for generating a pedestrian re-identification network model in one embodiment of the present invention;
[0040] Figure 3 is a schematic diagram of an implementation environment of a pseudo-label acquisition method in one embodiment of the present invention;
[0041] Figure 4 It is a structural schematic diagram of a device for generating a network model for pedestrian re-identification according to an embodiment of the present invention;
[0042] Figure 5 is a schematic diagram of a computer device in one embodiment of the present invention. DETAILED DESCRIPTION
[0043] 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 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.
[0044] See also Figure 1 In an embodiment of the present application, an initial person re-identification network architecture may be pre-constructed, and the initial person re-identification network architecture may include a preset prediction network, an image enhancer, and the preset prediction network may include a feature extraction network and a classification network. The image enhancer may include a first image enhancer (image enhancer one) and a second image enhancer (image enhancer two). After obtaining a sample image data set, a preset number of unlabeled images may be selected and input into the first image enhancer and the second image enhancer for image enhancement, and then the enhanced images may be input into the preset prediction network for classification prediction to obtain a prediction result, and based on the prediction result and the features extracted from the unlabeled image, a label is assigned to the target unlabeled image, and then a loss value is further calculated. The labeled image may be predicted and classified through the preset prediction network, and a loss value is calculated based on the classification result, and a total loss value is calculated based on the loss value of the unlabeled image and the loss value of the labeled image, and the initial person re-identification network architecture is trained based on the total loss value.
[0045] In one embodiment, if Figure 2 As shown, a method for generating a person re-identification network model is provided, comprising the following steps:
[0046] In step S110, a picture sample data set is obtained, where the picture sample data set includes labeled pictures and unlabeled pictures;
[0047] In the embodiment of the present application, the image sample data may include a large amount of image data, and some of the images in the image data may be labeled by manual annotation, thereby obtaining the labeled images. Using the labeled images and the unlabeled images to train the initial person re-identification network model can avoid complete reliance on labels, reduce the cost of manual annotation, and improve the accuracy of the unlabeled image training method.
[0048] In step S120, a first preset number of labeled images are selected and input into a preset prediction network of an initial person re-identification network for prediction processing to obtain a first prediction result, and a first loss value is calculated based on the first prediction result;
[0049] In an embodiment of the present application, the first preset number of labeled pictures may be m pictures, where m may be a positive integer greater than 0, for example, 5 pictures, and may be specifically set according to actual conditions.
[0050] In an embodiment of the present application, the preset prediction network may include a feature extraction network and a classification network. The feature extraction network may use any deep neural network suitable for image feature extraction, such as CNN, ResNet, Transformer, etc. The input is a labeled image, and a feature vector can be output. The classification network can be a shallow fully connected neural network, which outputs a probability distribution by inputting a feature vector, which can be used to represent the probability that the labeled image belongs to each class, and the dimension is the same as the number of different people in the pedestrian re-identification problem.
[0051] In an embodiment of the present application, the selecting of a first preset number of labeled images and inputting them into a preset prediction network of an initial person re-identification network for prediction processing to obtain a first prediction result includes:
[0052] Inputting the first preset number of labeled images into a preset feature extraction network for feature extraction to obtain a fourth feature vector;
[0053] The fourth feature vector is input into a classification network for classification prediction to obtain the first prediction result.
[0054] Specifically, the preset prediction network may include a feature extraction network and a classification network. After m labeled images are selected, they can be input into the feature extraction network for feature extraction to obtain the fourth feature vector, and then the fourth feature vector is input into the classification network for classification prediction, and the first prediction result can be obtained so as to perform supervised loss calculation based on the first prediction result.
[0055] Furthermore, the selected m labeled images are input into the feature extraction network and the classification network to obtain the first prediction result, that is, the probability distribution of each labeled image, which can be expressed as p i Represents the probability distribution of the classification network output corresponding to each picture, with y i Indicates the artificial labels corresponding to each labeled image. A preset loss function can be used, such as a cross entropy function, which can be represented by H. The first loss value, i.e., the supervised loss, is calculated by the following formula:
[0056]
[0057] In step S130, a second preset number of unlabeled images are selected and respectively input into different image enhancers for image enhancement processing, and the enhanced images are respectively input into the preset prediction network for prediction processing to obtain a second prediction result and a third prediction result;
[0058] In an embodiment of the present application, the second preset number of unlabeled images may be M images, where M may be a positive integer greater than 0, for example, 5 images, and may be specifically set according to actual conditions.
[0059] In an embodiment of the present application, the image enhancer may include multiple ones. After M unlabeled images are selected, they can be respectively input into different image enhancers for enhancement processing, and then the images enhanced by different image enhancers are respectively input into preset prediction networks, first feature extraction is performed through the feature extraction network, and then the extracted features are respectively input into the classification network to obtain the second prediction result and the third prediction result, that is, the probability distribution of each unlabeled image.
[0060] In an embodiment of the present application, the step of selecting a second preset number of unlabeled images and inputting them into different image enhancers for image enhancement processing includes:
[0061] Inputting the second preset number of unlabeled images into a first image enhancer, and performing enhancement processing on the unlabeled images by a first enhancement method to obtain a first enhanced image;
[0062] The second preset number of unlabeled images are input into a second image enhancer, and the unlabeled images are enhanced by a second enhancement method to obtain second enhanced images.
[0063] Specifically, two image enhancers can be set up, and the unlabeled image can be input into the first image enhancer and the second image enhancer respectively, and the unlabeled image can be enhanced in different ways respectively, and classification prediction can be performed based on the enhanced image, which can improve image clarity and expand the difference between the features of different objects in the image, thereby improving the recognition accuracy of the model.
[0064] The first enhancement method and the second enhancement method may both include one of flipping, translation, increasing brightness, random scaling, or any combination thereof. The first enhancement method is different from the second enhancement method so as to further expand the difference between features of different objects in the image and improve the accuracy of subsequent pseudo-label setting.
[0065] In an embodiment of the present application, the enhanced images are respectively input into the preset prediction network for prediction processing to obtain the second prediction result and the third prediction result, including:
[0066] Inputting the first enhanced image and the second enhanced image into a feature extraction network for feature extraction respectively, so as to obtain a second feature vector and a third feature vector;
[0067] The second eigenvector and the third eigenvector are respectively input into a classification network for classification prediction to obtain a first probability distribution and a second probability distribution.
[0068] Specifically, the preset prediction network may include a feature extraction network and a classification network. After obtaining the first enhanced picture and the second enhanced picture, the first enhanced picture and the second enhanced picture can be respectively input into the feature extraction network for feature extraction to obtain the second feature vector and the third feature vector, and then the second feature vector and the third feature vector are respectively input into the classification network for classification prediction to obtain the second prediction result and the third prediction result, that is, the first probability distribution and the second probability distribution.
[0069] In step S140, feature extraction is performed on the second preset number of unlabeled images to obtain a first feature vector, and a pseudo label is assigned to the target unlabeled image based on the first feature vector and the second prediction result, and a second loss value is calculated based on the pseudo label and the third prediction result;
[0070] In the embodiment of the present application, the feature extraction network can be used to extract features from the second preset number of unlabeled images, thereby obtaining a first feature vector for each unlabeled image, and then based on the first feature vector and the second prediction result predicted by the classification network, a pseudo label is assigned to the target unlabeled image, and the second loss value is calculated based on the pseudo label and the third prediction result. For example, g i Represents the second prediction result corresponding to each unlabeled image, with z i Represents the pseudo-label corresponding to each unlabeled image. Similarly, the loss function can adopt the cross entropy function, represented by H, and the second loss value, that is, the unsupervised loss, is calculated by the following formula:
[0071]
[0072] In an embodiment of the present application, assigning a pseudo label to the unlabeled image based on the first feature vector and the second prediction result includes:
[0073] Based on the second prediction result, a preset number of picture samples are selected according to the rule that the probability values of each category are from high to low, and the average value of the first feature vectors corresponding to the picture samples is used as the center of each category;
[0074] The distance value from the first feature vector to the center of each class is calculated, and the image sample with the smallest distance value is assigned a pseudo label.
[0075] Specifically, based on the second prediction result, k sample images with the highest probability values for each category can be selected in order from high to low, for example, 3, and then the average value of the feature vectors corresponding to the k sample images is used as the center of each category, and the distance between the feature vectors corresponding to the M unlabeled images and the center of each class is calculated. Based on the distance value, it is determined which class center the sample image with the closest distance to can be assigned a pseudo-label of that class.
[0076] Assume that M is 10, k is 2, and the total number of categories is 3. Use S01, S02, ..., S10 to represent 10 samples. Assume that in a certain step of training, the first probability distribution corresponding to these 10 sample images is shown in Table 1 below. It can be seen from Table 1 that the sample images with the top two probability values of category one are S02 and S03. The average value of the first eigenvectors corresponding to samples S02 and S03 can be used as the center of category one. Similarly, the average value of the first eigenvectors corresponding to samples S06 and S10 is used as the center of category two; the average value of the first eigenvectors corresponding to samples S02 and S04 is used as the center of category three. Use C1, C2, and C3 to represent the centers of the three categories respectively. Assume that the distribution of the class center and each sample image in the first feature space is as follows Figure 3 As shown, Figure 3 It can be seen that sample images S02, S03, and S07 are closest to C1, so these three samples are given pseudo labels of category 1; similarly, sample images S05, S06, S09, and S10 are closest to C2, so these four sample images are given pseudo labels of category 2; sample images S01, S04, and S08 are closest to C3, so these three sample images are given pseudo labels of category 3. In this way, pseudo labels of all sample images can be obtained.
[0077] Table 1: The first probability distribution table corresponding to sample images S01-S10:
[0078] sample Class-Probability Class 2 Probability Category three probability S01 0.33 0.35 0.32 S02 0.36 0.20 0.44 S03 0.40 0.34 0.26 S04 0.32 0.24 0.44 S05 0.26 0.33 0.41 S06 0.27 0.49 0.24 S07 0.33 0.26 0.41 S08 0.24 0.33 0.43 S09 0.31 0.31 0.38 S10 0.28 0.43 0.29
[0079] In step S150, a total loss value is calculated based on the first loss value and the second loss value, and iterative training is performed based on the total loss value until the loss value meets a preset convergence condition, thereby obtaining a trained person re-identification network model.
[0080] In the embodiment of the present application, after calculating the first loss value and the second loss value, the total loss value L can be calculated by the following formula:
[0081] L=L1+γL2
[0082] Among them, γ is a hyperparameter, which ranges from 0 to 1 and is used to control the ratio of supervised loss to unsupervised loss.
[0083] Based on the total loss value, the initial pedestrian re-identification network is iteratively trained until the preset convergence conditions are met, such as when the number of training steps reaches a preset step threshold, or when the total loss value reaches a preset threshold, such as 80%, the training is completed and the trained pedestrian re-identification network model can be obtained.
[0084] In one embodiment of the present application, after obtaining the trained person re-identification network model, the method includes:
[0085] Obtain all pedestrian images and pedestrian images to be identified in a preset pedestrian image database, and input them into the pedestrian re-identification network model respectively to obtain image features of all pedestrian images and image features of the pedestrian to be identified;
[0086] Calculating similarity between the image features of the pedestrian to be identified and the image features of all pedestrians to obtain similarity values;
[0087] The pedestrian image with the largest similarity value is taken as the pedestrian re-identification result.
[0088] Specifically, the trained pedestrian re-identification network model includes a trained feature extraction network, and does not require a classification network and an image enhancer. When performing pedestrian re-identification, a pre-constructed pedestrian image database gallery can be obtained. For example, pedestrian images can be collected by monitoring equipment, attendance equipment, etc., and saved to form a preset pedestrian image database. The database may include multiple pedestrian images. At the same time, the pedestrian image to be identified can be collected in real time by an image acquisition device, such as a camera, as a query image. Then, the pre-trained feature extraction network can be used to extract features of all pedestrian images in the pedestrian image database to obtain gallery image features, and feature extraction can be performed on the query image to obtain query features. Then, the similarity between the query feature and each gallery image feature can be calculated respectively. For example, the Euclidean distance algorithm can be used for calculation, and the pedestrian image with the highest similarity is selected as the pedestrian recognition result, thereby realizing pedestrian re-identification.
[0089] Furthermore, when collecting video data, each frame of the video data can be split to obtain each frame of the picture, and the picture with the highest clarity and no obstruction of the facial features and body features of the pedestrians can be selected for recognition.
[0090] In an embodiment of the present application, a method for generating a pedestrian re-identification network model is provided, including: obtaining a picture sample data set, the picture sample data set including labeled pictures and unlabeled pictures; selecting a first preset number of labeled pictures, and inputting them into a preset prediction network of an initial pedestrian re-identification network for prediction processing to obtain a first prediction result, and calculating a first loss value based on the first prediction result; selecting a second preset number of unlabeled pictures, and inputting them into different picture enhancers for picture enhancement processing, and inputting the enhanced pictures into the preset prediction network for prediction processing to obtain a second prediction result and a third prediction result; performing feature extraction on the second preset number of unlabeled pictures to obtain a first feature vector, and assigning a pseudo label to a target unlabeled picture based on the first feature vector and the second prediction result, and calculating a second loss value based on the pseudo label and the third prediction result; calculating a total loss value based on the first loss value and the second loss value, and performing iterative training based on the total loss value until the loss value meets a preset convergence condition, thereby obtaining a trained pedestrian re-identification network model. In an embodiment of the present application, by using labeled images and unlabeled images to train the initial pedestrian re-identification network, the required annotation data can be greatly reduced, the cost required for annotation can be well controlled, and the pedestrian re-identification problem in scenarios with less labeled data can be solved. Secondly, by setting a pseudo-label method, the model can be better helped to learn the hidden information in the unlabeled data, improve the model robustness, and improve the model recognition accuracy.
[0091] It should be understood that the order of execution of the steps in the above embodiment does not necessarily mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiment of the present invention.
[0092] In one embodiment, a pedestrian re-identification network model generation device is provided, and the pedestrian re-identification network model generation device corresponds to the pedestrian re-identification network model generation method in the above embodiment. Figure 4 As shown, the pedestrian re-identification network model generation device includes a sample image acquisition unit 10, a first loss value calculation unit 20, a prediction unit 30, and a second loss value calculation unit 40. The functional modules are described in detail as follows:
[0093] A sample image acquisition unit 10 is used to acquire a sample image data set, where the sample image data set includes labeled images and unlabeled images;
[0094] A first loss value calculation unit 20 is used to select a first preset number of labeled images and input them into a preset prediction network of the initial person re-identification network for prediction processing to obtain a first prediction result, and calculate a first loss value based on the first prediction result;
[0095] The prediction unit 30 is used to select a second preset number of unlabeled pictures, and input them into different picture enhancers for picture enhancement processing, and input the enhanced pictures into the preset prediction network for prediction processing to obtain a second prediction result and a third prediction result;
[0096] A second loss value calculation unit 40 is used to perform feature extraction on the second preset number of unlabeled images to obtain a first feature vector, assign a pseudo label to the target unlabeled image based on the first feature vector and the second prediction result, and calculate a second loss value based on the pseudo label and the third prediction result;
[0097] The pedestrian re-identification network model generation unit 50 is used to calculate the total loss value based on the first loss value and the second loss value, and perform iterative training based on the total loss value until the loss value meets the preset convergence condition, thereby obtaining the trained pedestrian re-identification network model.
[0098] In an embodiment of the present application, the prediction unit 30 is further configured to:
[0099] Inputting the second preset number of unlabeled images into a first image enhancer, and performing enhancement processing on the unlabeled images by a first enhancement method to obtain a first enhanced image;
[0100] The second preset number of unlabeled images are input into a second image enhancer, and the unlabeled images are enhanced by a second enhancement method to obtain second enhanced images.
[0101] In an embodiment of the present application, the first enhancement method is different from the second enhancement method, and both the first enhancement method and the second enhancement method may include one of flipping, translation, and increasing brightness, or any combination thereof.
[0102] In an embodiment of the present application, the prediction unit 30 is further configured to:
[0103] Inputting the first enhanced image and the second enhanced image into a feature extraction network for feature extraction respectively, so as to obtain a second feature vector and a third feature vector;
[0104] The second eigenvector and the third eigenvector are respectively input into a classification network for classification prediction to obtain a first probability distribution and a second probability distribution.
[0105] In one embodiment of the present application, the first loss value calculation unit 20 is further used to:
[0106] Inputting the first preset number of labeled images into a preset feature extraction network for feature extraction to obtain a fourth feature vector;
[0107] The fourth feature vector is input into a classification network for classification prediction to obtain the first prediction result.
[0108] In one embodiment of the present application, the second loss value calculation unit 40 is further used to:
[0109] Based on the second prediction result, a preset number of picture samples are selected according to the rule that the probability values of each category are from high to low, and the average value of the first feature vectors corresponding to the picture samples is used as the center of each category;
[0110] The distance value from the first feature vector to the center of each class is calculated, and the image sample with the smallest distance value is assigned a pseudo label.
[0111] In one embodiment of the present application, the device further includes a pedestrian re-identification unit, which is used to:
[0112] Obtain all pedestrian images and pedestrian images to be identified in a preset pedestrian image database, and input them into the pedestrian re-identification network model respectively to obtain image features of all pedestrian images and image features of the pedestrian to be identified;
[0113] Calculating similarity between the image features of the pedestrian to be identified and the image features of all pedestrians to obtain similarity values;
[0114] The pedestrian image with the largest similarity value is taken as the pedestrian re-identification result.
[0115] In an embodiment of the present application, by using labeled images and unlabeled images to train the initial pedestrian re-identification network, the required annotation data can be greatly reduced, the cost required for annotation can be well controlled, and the pedestrian re-identification problem in scenarios with less labeled data can be solved. Secondly, by setting a pseudo-label method, the model can be better helped to learn the hidden information in the unlabeled data, improve the model robustness, and improve the model recognition accuracy.
[0116] For the specific limitations of the pedestrian re-identification network model generation device, please refer to the limitations of the pedestrian re-identification network model generation method above, which will not be repeated here. The various modules in the above-mentioned pedestrian re-identification network model generation device can be implemented in whole or in part by software, hardware and their combination. The above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory of the computer device in the form of software, so that the processor can call and execute the operations corresponding to the above modules.
[0117] In one embodiment, a computer device is provided. The computer device may be a terminal device, and its internal structure diagram may be as follows: Figure 5 As shown. The computer device includes a processor, a memory, and a network interface connected via a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a readable storage medium. The readable storage medium stores computer-readable instructions. The network interface of the computer device is used to communicate with an external terminal via a network connection. When the computer-readable instructions are executed by the processor, a method for generating a pedestrian re-identification network model is implemented. The readable storage medium provided in this embodiment includes a non-volatile readable storage medium and a volatile readable storage medium.
[0118] In an embodiment of the present application, a computer device is provided, including a memory, a processor, and computer-readable instructions stored in the memory and executable on the processor. When the processor executes the computer-readable instructions, the steps of the method for generating a pedestrian re-identification network model as described above are implemented.
[0119] In an embodiment of the application, a readable storage medium is provided, wherein the readable storage medium stores computer-readable instructions, and when the computer-readable instructions are executed by a processor, the steps of the method for generating a pedestrian re-identification network model as described above are implemented.
[0120] Those of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be implemented by instructing related hardware through computer-readable instructions, and the computer-readable instructions can be stored in a non-volatile readable storage medium or a volatile readable storage medium. When the computer-readable instructions are executed, they may include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application may include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.
[0121] Those skilled in the art can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example. In actual applications, the above-mentioned functions can be distributed and completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above.
[0122] The embodiments described above are only used to illustrate the technical solutions of the present invention, rather than to limit the same. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. Such modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention, and should all be included in the protection scope of the present invention.
Claims
1. A method for generating a person re-identification network model, characterized in that: The method comprises: Obtain a sample image dataset, where the sample image dataset includes labeled images and unlabeled images; Selecting a first preset number of labeled images and inputting them into a preset prediction network of an initial person re-identification network for prediction processing to obtain a first prediction result, and calculating a first loss value based on the first prediction result; Selecting a second preset number of unlabeled images, and inputting them into different image enhancers for image enhancement processing, and inputting the enhanced images into the preset prediction network for prediction processing, to obtain a second prediction result and a third prediction result; Performing feature extraction on the second preset number of unlabeled images to obtain a first feature vector, assigning a pseudo label to the target unlabeled image based on the first feature vector and the second prediction result, and calculating a second loss value based on the pseudo label and the third prediction result; Based on the first loss value and the second loss value, a total loss value is calculated, and iterative training is performed based on the total loss value until the loss value meets a preset convergence condition, thereby obtaining a trained person re-identification network model; The selecting of a second preset number of unlabeled images and inputting them into different image enhancers for image enhancement processing respectively includes: Inputting the second preset number of unlabeled images into a first image enhancer, and performing enhancement processing on the unlabeled images by a first enhancement method to obtain a first enhanced image; Inputting the second preset number of unlabeled images into a second image enhancer, and performing enhancement processing on the unlabeled images by a second enhancement method to obtain second enhanced images; The step of inputting the enhanced images into the preset prediction network for prediction processing to obtain the second prediction result and the third prediction result includes: Inputting the first enhanced image and the second enhanced image into a feature extraction network for feature extraction respectively, so as to obtain a second feature vector and a third feature vector; Inputting the second feature vector and the third feature vector into a classification network for classification prediction to obtain a second prediction result and a third prediction result; The first enhancement mode is different from the second enhancement mode, and both the first enhancement mode and the second enhancement mode may include one of flipping, translation, random scaling, and increasing brightness, or any combination thereof; The assigning a pseudo label to the unlabeled image based on the first feature vector and the second prediction result includes: Based on the second prediction result, according to the rule that the probability values of each category are from high to low, a preset number of picture samples are selected, and the average value of the first feature vectors corresponding to the picture samples is used as the center of each category; The distance value from the first feature vector to the center of each class is calculated, and the image sample with the smallest distance value is assigned a pseudo label.
2. The method for generating a person re-identification network model according to claim 1, wherein: The selecting a first preset number of labeled images and inputting them into a preset prediction network of the initial person re-identification network for prediction processing to obtain a first prediction result includes: Inputting the first preset number of labeled images into a feature extraction network for feature extraction to obtain a fourth feature vector; The fourth feature vector is input into a classification network for classification prediction to obtain the first prediction result.
3. The method for generating a person re-identification network model according to claim 1, wherein: After obtaining the trained person re-identification network model, the following steps are included: Obtain all pedestrian images and pedestrian images to be identified in a preset pedestrian image database, and input them into the pedestrian re-identification network model respectively to obtain image features of all pedestrian images and image features of the pedestrian to be identified; Calculating similarity between the image features of the pedestrian to be identified and the image features of all pedestrians to obtain similarity values; The pedestrian image with the largest similarity value is taken as the pedestrian re-identification result.
4. A pedestrian re-identification network model generation device, characterized in that: The device comprises: A sample image acquisition unit, used to acquire an image sample data set, wherein the image sample data set includes labeled images and unlabeled images; A first loss value calculation unit, configured to select a first preset number of labeled images and input them into a preset prediction network of an initial person re-identification network for prediction processing to obtain a first prediction result, and calculate a first loss value based on the first prediction result; A prediction unit is used to select a second preset number of unlabeled pictures, and input them into different picture enhancers for picture enhancement processing, and input the enhanced pictures into the preset prediction network for prediction processing to obtain a second prediction result and a third prediction result; A second loss value calculation unit is used to perform feature extraction on the second preset number of unlabeled images to obtain a first feature vector, assign a pseudo label to the target unlabeled image based on the first feature vector and the second prediction result, and calculate a second loss value based on the pseudo label and the third prediction result; A person re-identification network model generating unit, configured to calculate a total loss value based on the first loss value and the second loss value, and perform iterative training based on the total loss value until the loss value meets a preset convergence condition, thereby obtaining a trained person re-identification network model; Wherein, the prediction unit is further used for: Inputting the second preset number of unlabeled images into a first image enhancer, and performing enhancement processing on the unlabeled images by a first enhancement method to obtain a first enhanced image; Inputting the second preset number of unlabeled images into a second image enhancer, and performing enhancement processing on the unlabeled images by a second enhancement method to obtain second enhanced images; Wherein, the prediction unit is further used for: Inputting the first enhanced image and the second enhanced image into a feature extraction network for feature extraction respectively, so as to obtain a second feature vector and a third feature vector; Inputting the second feature vector and the third feature vector into a classification network for classification prediction to obtain a second prediction result and a third prediction result; The first enhancement mode is different from the second enhancement mode, and both the first enhancement mode and the second enhancement mode may include one of flipping, translation, random scaling, and increasing brightness, or any combination thereof; The second loss value calculation unit is further used for: Based on the second prediction result, according to the rule that the probability values of each category are from high to low, a preset number of picture samples are selected, and the average value of the first feature vectors corresponding to the picture samples is used as the center of each category; The distance value from the first feature vector to the center of each class is calculated, and the image sample with the smallest distance value is assigned a pseudo label.
5. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the computer program is executed by the processor, the processor executes the method for generating a pedestrian re-identification network model as described in any one of claims 1 to 3.
6. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the processor executes the method for generating a pedestrian re-identification network model as described in any one of claims 1 to 3.
