Pseudo-label construction method, device, equipment and medium for model training
By constructing pseudo labels in the human weight recognition model and utilizing clustering and similarity threshold processing of unlabeled images, the problem of low recognition accuracy caused by lack of training data is solved, and efficient training and accurate recognition of the model are achieved in migration scenarios.
Patent Information
- Application Number
- CN202211683975.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-12-27
- Publication Date
- 2025-10-03
- Estimated Expiration
- 2042-12-27
AI Technical Summary
The human weight recognition model has a low recognition accuracy in migration scenarios due to a lack of training data. Especially when unlabeled data is difficult to use, existing technologies cannot effectively improve the recognition accuracy of the model.
The unlabeled images are input into the pre-trained model for feature extraction, the graph data is constructed and clustered using the similarity threshold, pseudo labels are assigned according to the number of cluster sets, the initial re-identification model is retrained, and semi-supervised training is performed using labeled and unlabeled images to update the model.
It provides sufficient training data, improves the recognition accuracy of the human weight recognition model in migration scenarios, reduces the annotation cost, and improves the adaptability and recognition ability of the model.
Smart Images

Figure CN116206174B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of artificial intelligence technology, and in particular to a pseudo-label construction method, device, equipment and medium for model training. Background Art
[0002] With the development of artificial intelligence technology, human body weight recognition technology has been applied to various scenarios, such as smart retail scenarios, smart security scenarios, and smart transportation scenarios, because of its ability to track, match, and authenticate target people across time and space.
[0003] However, with the rapid expansion of application scenarios, when the human weight recognition model is migrated and used in different scenarios, the model may not be able to adapt to the migration scenario. The massive unlabeled data in the migration scenario is difficult to use as training data after migration due to reasons such as labeling costs, resulting in poor model recognition accuracy. Therefore, how to effectively use unlabeled data to improve the accuracy of the human weight recognition model has become an urgent problem to be solved. Summary of the Invention
[0004] In view of this, embodiments of the present invention provide a pseudo-label construction method, apparatus, device and medium for model training to solve the problem of low accuracy of human weight recognition model caused by lack of training data after model migration.
[0005] In a first aspect, an embodiment of the present invention provides a pseudo-label construction method for model training, the pseudo-label construction method comprising:
[0006] Input the obtained N unlabeled images into the pre-trained initial re-identification model for feature extraction, and obtain N image features corresponding to the unlabeled images, where N is an integer greater than zero;
[0007] Obtain at least one preset similarity threshold, and for any similarity threshold, treat the unlabeled image as a node, calculate the similarity of image features of any two nodes, and connect two nodes whose similarity is greater than the similarity threshold to form graph data corresponding to the similarity threshold;
[0008] Perform clustering on each graph data to obtain at least one cluster set corresponding to the graph data. For any pair of nodes, determine the number of sets that belong to the same cluster set. Traverse all node pairs to obtain the number of sets corresponding to the node pairs.
[0009] When the number of sets is greater than a preset threshold, the two nodes in the node pair corresponding to the number of sets are divided into the same final clustering set, and a preset pseudo-label is assigned to the unlabeled image corresponding to each node according to the final clustering set to which it belongs. The N unlabeled images and their pseudo-labels are used to retrain the initial re-identification model to obtain an updated re-identification model.
[0010] In a second aspect, an embodiment of the present invention provides a pseudo-label construction device for model training, the pseudo-label construction device comprising:
[0011] A feature extraction module is used to input the acquired N unlabeled images into the pre-trained initial re-identification model for feature extraction, thereby obtaining N image features corresponding to the unlabeled images, where N is an integer greater than zero;
[0012] a graph data construction module configured to obtain at least one preset similarity threshold, and for any similarity threshold, treat the unlabeled image as a node, calculate the similarity of image features between any two nodes, and connect two nodes whose similarity is greater than the similarity threshold to form graph data corresponding to the similarity threshold;
[0013] A clustering processing module is used to perform clustering processing on each graph data to obtain at least one cluster set corresponding to the graph data. For any node pair consisting of two nodes, the number of sets of the node pairs belonging to the same cluster set is determined, and all node pairs are traversed to obtain the number of sets of corresponding node pairs.
[0014] The pseudo-label construction module is used to divide the two nodes in the node pair corresponding to the set number into the same final cluster set when the set number is greater than a preset threshold, and assign a preset pseudo-label to the unlabeled image corresponding to each node according to the final cluster set to which it belongs. The N unlabeled images and their pseudo-labels are used to retrain the initial re-identification model to obtain an updated re-identification model.
[0015] In a third aspect, an embodiment of the present invention provides a computer device, comprising a processor, a memory, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the pseudo-label construction method as described in the first aspect is implemented.
[0016] In a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the pseudo-label construction method as described in the first aspect is implemented.
[0017] Compared with the prior art, the embodiments of the present invention have the following beneficial effects:
[0018] The N unlabeled images obtained are input into the pre-trained initial re-identification model for feature extraction to obtain N image features corresponding to the unlabeled images, and at least one preset similarity threshold is obtained. For any similarity threshold, the unlabeled image is used as a node, and the similarity of the image features of any two nodes is calculated. The two nodes with similarity greater than the similarity threshold are connected to form graph data corresponding to the similarity threshold. Each graph data is clustered to obtain at least one cluster set of the corresponding graph data. For any node pair consisting of two nodes, the number of sets of node pairs belonging to the same cluster set is determined, and all node pairs are traversed to obtain the corresponding node data. The number of point pairs is calculated. When the number of sets is greater than a preset threshold, the two nodes in the node pairs of the corresponding number of sets are divided into the same final clustering set. A preset pseudo-label is assigned to the unlabeled image corresponding to each node according to the final clustering set to which it belongs. N unlabeled images and their pseudo-labels are used to retrain the initial re-identification model to obtain an updated re-identification model. Multiple graph data constructed according to different similarity thresholds of the unlabeled images are clustered separately. A pseudo-label is assigned to each unlabeled image based on the statistical information of multiple clustering results, providing sufficient training data for the retraining of the initial re-identification model, thereby improving the accuracy of the human body re-identification model. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0020] Figure 1 1 is a schematic diagram of an application environment of a pseudo-label construction method for model training provided in the first embodiment of the present invention;
[0021] Figure 2 1 is a flow chart of a pseudo-label construction method for model training provided in the first embodiment of the present invention;
[0022] Figure 3 1 is a flow chart of a pseudo-label construction method for model training provided in the second embodiment of the present invention;
[0023] Figure 4 Schematic diagram of a pseudo-label construction device for model training provided in the third embodiment of the present invention;
[0024] Figure 5 This is a structural diagram of a computer device provided in Example 4 of the present invention. DETAILED DESCRIPTION
[0025] In the following description, specific details such as particular system structures and techniques are provided for purposes of illustration, not limitation, to facilitate a thorough understanding of the embodiments of the present invention. However, it will be apparent to those skilled in the art that the present invention may be practiced in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted so as not to obscure the description of the present invention with unnecessary detail.
[0026] It should be understood that when used in the present specification and the appended claims, the term "comprising" indicates the presence of described features, integers, steps, operations, elements and / or components, but does not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or groups thereof.
[0027] It will also be understood that the term "and / or" used in the present description and appended claims refers to and includes any and all possible combinations of one or more of the associated listed items.
[0028] As used in the present specification and the appended claims, the term "if" may be interpreted as "when" or "upon" or "in response to determining" or "in response to detecting," depending on the context. Similarly, the phrase "if it is determined" or "if [described condition or event] is detected" may be interpreted as meaning "upon determination" or "in response to determining" or "upon detection of [described condition or event]" or "in response to detecting [described condition or event]," depending on the context.
[0029] In addition, in the description of the present specification and the appended claims, the terms "first", "second", "third", etc. are only used to distinguish the descriptions and cannot be understood as indicating or implying relative importance.
[0030] References to "one embodiment" or "some embodiments" in the present specification mean that a particular feature, structure, or characteristic described in conjunction with that embodiment is included in one or more embodiments of the present invention. Thus, phrases such as "in one embodiment," "in some embodiments," "in other embodiments," and "in yet other embodiments" appearing in various places in this specification do not necessarily refer to the same embodiment, but rather mean "one or more, but not all, embodiments," unless otherwise specifically emphasized. The terms "including," "comprising," "having," and variations thereof mean "including but not limited to," unless otherwise specifically emphasized.
[0031] Embodiments of the present invention can acquire and process relevant data based on artificial intelligence technology. Artificial Intelligence (AI) refers to the theories, methods, technologies, and application systems that use digital computers or machines controlled by digital computers to simulate, extend, and expand human intelligence, perceive the environment, acquire knowledge, and use that knowledge to achieve optimal results.
[0032] Fundamental AI technologies generally include sensors, dedicated AI chips, cloud computing, distributed storage, big data processing, operating / interaction systems, and mechatronics. AI software technologies primarily encompass computer vision, robotics, biometrics, speech processing, natural language processing, and machine learning / deep learning.
[0033] It should be understood that the order of execution of the steps in the following embodiments does not necessarily mean the order in which they are executed. The order in which each process is executed should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present invention.
[0034] In order to illustrate the technical solution of the present invention, specific embodiments are provided below.
[0035] The pseudo label construction method for model training provided in the first embodiment of the present invention can be applied in the following situations: Figure 1 In an application environment, a client communicates with a server. The client includes but is not limited to PDAs, desktop computers, laptops, ultra-mobile personal computers (UMPCs), netbooks, cloud terminal devices, personal digital assistants (PDAs), and other computer devices. The server can be a standalone server or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content delivery networks (CDNs), and big data and artificial intelligence platforms.
[0036] The client can be deployed in the migrated human weight recognition scenario, which can be a criminal investigation scenario, smart retail scenario, smart security scenario or smart traffic scenario, etc. Several image acquisition devices are deployed in the human weight recognition scenario, which can include but are not limited to cameras, video cameras, recorders, handheld photography equipment, etc.
[0037] See also Figure 2, is a flow chart of a pseudo-label construction method for model training provided by the first embodiment of the present invention. The pseudo-label construction method can be applied to Figure 1 The client in the client, the computer device corresponding to the client connects to the corresponding server to obtain the unlabeled image collected by the image acquisition device from the server. The computer device corresponding to the client is deployed with a pre-trained initial re-identification model. The pre-trained initial re-identification model can be directly transferred from other people's weight recognition scenarios. Figure 2 As shown, the pseudo-label construction method may include the following steps:
[0038] In step S201 , the obtained N unlabeled images are respectively input into a pre-trained initial re-identification model for feature extraction to obtain N image features corresponding to the unlabeled images.
[0039] Wherein, N is an integer greater than zero, an unlabeled image may refer to a human image without label information, a pre-trained initial re-ID model may be directly transferred from other human body recognition scenarios, and image features may represent feature information of the unlabeled image.
[0040] Specifically, the person weight recognition scenario deployed by the client is taken as the current scenario, and the person weight recognition scenario of the training data set used by the pre-trained initial re-identification model during pre-training is taken as the historical scenario. The pre-trained initial re-identification model is directly migrated from the historical scenario to the current scene. Since there are certain differences in the personnel characteristics between the historical scene and the current scene, the pre-trained initial re-identification model will have a low recognition accuracy in the current scenario.
[0041] In the historical scene, the self-supervised training method can be used to pre-train the human weight recognition model. After randomly initializing the parameters in the human weight recognition model, the MOCO self-supervised method is used to pre-train the human weight recognition model for the first time using the unlabeled images in the historical scene. At this time, the historical scene can be multiple different historical scenes. The human weight recognition model pre-trained for the first time is used to extract the initial features of the labeled images in the historical scene, and a composite pooling operation is performed on the initial features. Composite pooling can refer to performing multiple pooling processes on the initial features and then weighting them. The pooling process can include maximum pooling, mean pooling, etc. The features after the composite pooling process are input into the fully connected layer to obtain the classification result. The cross entropy loss is calculated using the classification result and the label of the labeled image, and the triplet loss is calculated between the features after the composite pooling process. Based on the cross entropy loss and the triplet loss, the human weight recognition model pre-trained for the first time is supervised training to obtain the final pre-trained initial re-identification model.
[0042] The pre-trained initial re-identification model may include a pre-trained feature extraction layer and a pre-trained fully connected layer. The pre-trained feature extraction layer may be used to extract features from the input image. The pre-trained fully connected layer may map the extracted image features to obtain a re-identification result. The re-identification result may be a person's identity. Generally, since there may be persons who do not exist in the training data in the human weight recognition scenario, the fully connected layer used to identify the person's identity information may only be used in the training process. The pre-trained initial re-identification model may only use the pre-trained feature extraction layer in actual use, that is, the pre-trained feature extraction layer may be used to extract features from the actual collected image. After obtaining the image features, the image features may be compared with the image features of the stored known images to achieve the human weight recognition task.
[0043] It should be noted that the original image directly captured by the image acquisition device may not contain the human body area. Therefore, human body detection and positioning are required for the original image to filter out the image containing the human body area. The implementer can use the target detection model for human body detection. The target detection model can use the Yolo model, RCNN model, SSD model, etc. The output of the target detection model is the bounding box of the human body area. According to the bounding box of the human body area, the original image can be cropped to isolate irrelevant background noise, and the cropped image is used as the unlabeled image.
[0044] The above-mentioned step of inputting the acquired N unlabeled images into the pre-trained initial re-identification model for feature extraction to obtain N image features corresponding to the unlabeled images, extracting the image features according to the initial re-identification model, facilitates the subsequent clustering of the unlabeled images according to the image features, thereby constructing pseudo labels for the unlabeled images to retrain the initial re-identification model, and improving the accuracy of the human body re-identification model after scene migration.
[0045] Step S202: Obtain at least one preset similarity threshold. For any similarity threshold, take the unlabeled image as a node, calculate the similarity of the image features of any two nodes, and connect the two nodes whose similarity is greater than the similarity threshold to form graph data corresponding to the similarity threshold.
[0046] Among them, nodes and edges can constitute graph data, the similarity threshold can be used to measure whether the image features of two unlabeled images are similar enough, the nodes can be connected by edges, and the graph data can contain information on the similarity between N unlabeled images.
[0047] Specifically, the similarity between image features can be calculated using distance metrics such as cosine distance and Euclidean distance. In this embodiment, cosine distance is used to calculate the similarity between image features. The value range of cosine similarity is [0, 1]. The preset similarity threshold should satisfy the value range of similarity. In this embodiment, the similarity threshold can be set to three similarity thresholds of 0.6, 0.7, and 0.8. Obviously, when the similarity threshold takes different values, the connection relationship between the nodes will also change. For example, the similarity between the image features of two unlabeled images is 0.65. When the similarity threshold is 0.6, there is a connecting edge between the nodes corresponding to the two unlabeled images. When the similarity threshold is 0.7, there is no connecting edge between the nodes corresponding to the two unlabeled images.
[0048] The above-mentioned step of obtaining at least one preset similarity threshold, taking the unlabeled image as a node for any similarity threshold, calculating the similarity of the image features of any two nodes, connecting the two nodes whose similarity is greater than the similarity threshold, and forming graph data corresponding to the similarity threshold, constructs multiple graph data through different similarity thresholds to avoid the pseudo-label obtained by only one clustering being inaccurate, obtains multiple clustering results by adjusting the similarity threshold multiple times, and finally obtains reliable pseudo-labels.
[0049] Step S203: perform clustering processing on each graph data to obtain at least one cluster set corresponding to the graph data. For any node pair consisting of two nodes, determine the number of sets of node pairs belonging to the same cluster set, traverse all node pairs, and obtain the number of sets of corresponding node pairs.
[0050] Clustering may refer to clustering nodes in graph data. A single graph data may obtain at least one cluster set after clustering processing, and a node pair includes two nodes.
[0051] Specifically, in this embodiment, there are N unlabeled images, and there are N nodes in total. N nodes can be combined in pairs to form Node pairs.
[0052] Optionally, clustering is performed on each graph data to obtain at least one cluster set of the corresponding graph data, including:
[0053] For any graph data, perform random walk processing on the graph data to obtain a random walk sequence;
[0054] Perform hierarchical coding on the random walk sequence, and calculate the optimization target based on the hierarchical coding result and the preset objective function;
[0055] By adjusting the hierarchical coding, the optimization target is optimized until the optimization target converges, and the hierarchical coding adjustment result corresponding to the convergence of the optimization target is determined to be at least one cluster set of the corresponding graph data;
[0056] Traverse each graph data to obtain at least one cluster set corresponding to the graph data.
[0057] Among them, the random walk sequence can refer to a sequence composed of all nodes visited when performing random walk processing on graph data, the hierarchical coding results can include category coding results and intra-class coding results, the category coding results can include category marks and termination marks, the objective function can refer to the calculation function of the average coding length, and the optimization target can refer to the average coding length of the current hierarchical coding result.
[0058] Specifically, a preset transition probability is assigned between each pair of nodes with edges in the graph data. In this embodiment, the transition probability of one node transferring to another node is determined according to the number of nodes connected to the node. For example, if node A is connected to Q nodes respectively, the transition probability of node A transferring to node B connected to it is 1 / Q. It should be noted that the transition probability of node B transferring to node A is also determined according to the number of nodes connected to node B, and is not necessarily the same as 1 / Q.
[0059] Take a random node as the starting node, sample according to the transition probability, determine the next node to move to, repeat the movement process until the number of moves meets the preset number or the number of nodes visited by the random walk meets the preset number, stop the random walk, directly construct Huffman coding for all the nodes visited by the random walk, and obtain the random walk sequence.
[0060] The random walk sequence is hierarchically encoded. After hierarchical encoding, the random walk sequence contains category tags, termination tags and intra-class encoding results. For example, the category tag can be 01, 02, etc., the termination tag can be 0, and the category encoding results can be 001, 002, etc. Then, in the hierarchical encoding, the encoding of a hierarchical category can be expressed as
[01] ,
[001] ,
[002] , [0]. According to the category tag 01, it can be determined that this part belongs to the first hierarchical category. The intra-class code of the first node in the hierarchical category is 001, and the intra-class code of the second node is 002. According to the termination tag, it can be determined that the encoding of the hierarchical category has ended.
[0061] After obtaining the hierarchical coding, the normalized probabilities of the category mark, termination mark, and intra-class coding results can be obtained through global normalization. The first average coding length is calculated based on the category mark, and the second average coding length of each hierarchical category is calculated based on the intra-class coding results. The first average coding length and all second average coding lengths are added together to obtain the average coding length, which is also the optimization target.
[0062] With the purpose of minimizing the optimization target, the hierarchical coding is adjusted until the optimization target converges to the minimum value. According to the hierarchical categories in the hierarchical coding adjustment results corresponding to the convergence of the optimization target, the clustering sets of the corresponding graph data are determined.
[0063] In this embodiment, graph data is clustered through hierarchical coding without setting hyperparameters. Clustering tasks with an indefinite number of cluster sets can be completed when only the graph data information is known, thereby being adaptable to various graph data structures and improving the generalization of clustering processing.
[0064] Optionally, for any two node pairs, determining the number of sets in which the node pairs belong to the same cluster set includes:
[0065] For any node pair, initialize the number of sets to zero;
[0066] Traverse each cluster set. If both nodes in a node pair belong to the cluster set, increase the set number by one to get the set number of the node pair.
[0067] The number of sets may refer to the number of cluster sets that simultaneously include both nodes in the node pair.
[0068] Specifically, if the two nodes in a node pair belong to the same cluster set, it means that when the graph data is clustered this time, the two nodes in the node pair belong to the same class. Obviously, in the clustering results of a single graph data, the cluster set to which the two nodes in the node pair belong has been determined. Therefore, by counting all cluster sets of all graph data, the number of node pairs can be obtained.
[0069] In this embodiment, the number of sets of each node pair is counted by traversal, so as to determine whether the two nodes in the node pair are ultimately of the same category based on the clustering of the two nodes in the node pair under different graph data.
[0070] The above steps of clustering each graph data separately to obtain at least one cluster set of the corresponding graph data, determining the number of sets of node pairs belonging to the same cluster set for any two nodes, traversing all node pairs to obtain the number of sets of corresponding node pairs, can count the clustering of nodes under different graph data, avoid the inaccuracy of pseudo-labels obtained by clustering nodes only once, and obtain more reliable pseudo-labels.
[0071] Step S204 , when the number of clusters is greater than a preset threshold, the two nodes in the node pair corresponding to the number of clusters are divided into the same final cluster set, and a preset pseudo label is assigned to the unlabeled image corresponding to each node according to the final cluster set to which it belongs.
[0072] The preset threshold can be used to measure whether two nodes in a node pair are sufficiently similar. The final cluster set can refer to the set ultimately used for pseudo-label assignment, and the pseudo-labels are represented by serial numbers, one-hot encoding, etc. N unlabeled images and their pseudo-labels are used to retrain the initial re-identification model to obtain an updated re-identification model.
[0073] Specifically, when the number of sets corresponding to a node pair is greater than a preset threshold, it indicates that the two nodes in the node pair are similar enough. Therefore, when the cluster sets are finally divided, the two nodes in the node pair are divided into the same final cluster set. In this embodiment, the preset threshold is set to 4, and the implementer can adjust the preset threshold according to actual conditions.
[0074] In one embodiment, the preset threshold value may be dynamically determined according to the number of graph data. For example, assuming there are P graph data in total, the preset threshold value α may be expressed as α=P*β, and γ may be 0.5.
[0075] Optionally, assigning a preset pseudo label to the unlabeled image corresponding to each node according to the final cluster set to which it belongs includes:
[0076] Count the number of all final cluster sets, and assign corresponding pseudo labels to each final cluster set based on the number;
[0077] For the unlabeled image corresponding to any node, the final cluster set to which the unlabeled image belongs is determined, and the pseudo label corresponding to the final cluster set to which the unlabeled image belongs is used as the pseudo label of the unlabeled image.
[0078] Here, the number may refer to the total number of the final cluster sets.
[0079] Specifically, if two nodes in a node pair are determined to belong to the same final clustering set, at this time, the node pairs formed by the two nodes are judged. If there is a node pair belonging to the same final clustering set, the other node in the node pair is added to the final clustering set. By default, when the number of graph data is large enough, there is no conflict in the final clustering sets to which the nodes belong.
[0080] After all final cluster sets are obtained, the final cluster sets can be screened according to a preset node number threshold to remove outliers. The preset node number threshold can be 2, that is, only the final cluster sets with more than two nodes are retained.
[0081] Assume that the number of all final cluster sets is W, then the pseudo-labels can be 1, 2, ..., W, that is, the pseudo-labels are represented by serial numbers, and the corresponding pseudo-labels are assigned to the corresponding final cluster sets. All nodes in a final cluster set also use the pseudo-labels corresponding to the final cluster set as the pseudo-labels of the corresponding nodes' unlabeled images.
[0082] In this embodiment, a corresponding pseudo label is assigned to each unlabeled image in each final cluster set based on the quantity to provide training data for model retraining. At this time, the model only needs to learn the final cluster set to which the unlabeled image belongs, without learning its true label, thereby saving a lot of labeling costs and improving the accuracy of the model after scene migration.
[0083] Optionally, the pseudo-label construction method further includes:
[0084] Get M labeled images and their true labels, where M is an integer greater than zero;
[0085] The initial re-identification model is retrained using labeled images and their true labels, and N unlabeled images and their pseudo labels to obtain an updated re-identification model.
[0086] The labeled image may refer to a human body image that has been manually labeled, the true label may refer to the result of manual labeling, and the true label may be represented by an identity identifier.
[0087] Specifically, the process of retraining the initial re-identification model is a semi-supervised process, which combines labeled images and unlabeled images as training samples to perform semi-supervised training on the initial re-identification model.
[0088] In this embodiment, while ensuring a sufficient number of training samples, labeled images are used to provide a training reference for model training, thereby ensuring the retraining effect of the initial re-identification model and improving the recognition accuracy of the retrained human weight recognition model in the migration scenario.
[0089] Optionally, the initial re-identification model is retrained using labeled images and their true labels, and N unlabeled images and their pseudo labels, to obtain an updated re-identification model including:
[0090] Input the M labeled images into the initial re-identification model respectively to obtain M first recognition results corresponding to the labeled images, and calculate the first recognition loss based on the M first recognition results corresponding to the labeled images, the true labels of the M corresponding labeled images, and a preset first recognition loss function;
[0091] Inputting N unlabeled images into the initial re-identification model respectively to obtain second recognition results of N corresponding unlabeled images, and calculating the second recognition loss according to the second recognition results of the N corresponding unlabeled images, the pseudo labels of the N corresponding unlabeled images, and a preset second recognition loss function;
[0092] Based on the first recognition loss and the second recognition loss, the initial re-identification model is retrained to obtain an updated re-identification model.
[0093] Among them, the first recognition result can refer to the identity classification result, the second recognition result can refer to the classification result of the final clustering set, the preset first recognition loss function can adopt a classification loss function, such as a cross entropy loss function, and the preset second recognition loss function can also adopt a classification loss function.
[0094] The first recognition loss can be used to supervise the learning of the real labels of the labeled images by the human weight recognition model, and the second recognition loss can be used to supervise the learning of the pseudo labels of the unlabeled images by the human weight recognition model.
[0095] Specifically, during the actual training process, each labeled image can also determine its pseudo label through the above-mentioned pseudo label construction process, thereby avoiding the model's inability to recognize labeled images and unlabeled images. At this time, the model calculates the second recognition loss for all images based on the pseudo labels, and then calculates the first recognition loss based on the images with real labels among all images.
[0096] In this embodiment, the initial re-identification model is trained in a semi-supervised manner, which provides sufficient training samples for the training process, so that the initial re-identification model can adapt to the current scenario after training, thereby improving the accuracy of the trained person re-identification model.
[0097] Optionally, calculating the second recognition loss according to the second recognition results of the N corresponding unlabeled images, the pseudo labels of the N corresponding unlabeled images, and a preset second recognition loss function includes:
[0098] For any unlabeled image, multiply the pseudo label corresponding to the unlabeled image by a preset first coefficient to obtain a multiplication result;
[0099] Count the number of labels of all pseudo labels, compare the number of labels with the preset second coefficient, add the obtained ratio and the multiplication result to obtain the smoothed label;
[0100] Calculating a second identification sub-loss according to the second recognition result corresponding to the unlabeled image, the smoothed label corresponding to the unlabeled image, and the second recognition loss function;
[0101] Traverse all unlabeled images, obtain the second identifier loss corresponding to each unlabeled image, and use the sum of all second identifier losses as the second recognition loss.
[0102] Among them, the preset first coefficient can be used to represent the weight of the pseudo-label to which the unlabeled image belongs, the multiplication result can refer to the weighted result of the pseudo-label to which the unlabeled image belongs, and the weighted result can represent the probability of the pseudo-label to which the unlabeled image belongs. The preset second coefficient can be used to characterize the total smoothed probability of all pseudo-labels, the number of labels can refer to the number of all pseudo-labels, the ratio can be used to characterize the smoothed probability of any pseudo-label among all pseudo-labels, and the smoothed label can refer to the probability of the pseudo-label to which the unlabeled image belongs after smoothing.
[0103] Specifically, under normal circumstances, the label probability distribution vector used for learning in the classification task is one-hot encoding, for example, [0,1,0], which means that the second category is the label category with a probability of 1, and the first and third categories are other categories with a probability of 0. In this embodiment, assuming that the number of labels of all pseudo labels is K, the smoothed probability of each pseudo label can be expressed as:
[0104]
[0105] Among them, y k It can represent the initial probability of the kth pseudo label, 1-γ can refer to the first coefficient, γ can refer to the second coefficient, y′ k It can represent the smoothed probability of the k-th pseudo label.
[0106] Then for the pseudo label of the unlabeled image, the smoothing probability is For the pseudo labels that the unlabeled image does not belong to, the smoothed probability is Obviously, the sum of the smoothed probabilities of all pseudo labels is 1, which conforms to the constraints of the probability distribution.
[0107] In this embodiment, the pseudo labels are probability smoothed to reduce the noise impact brought by the pseudo labels during the training process of the initial re-identification model, so that the re-identification model can learn more accurate classification information, thereby improving the recognition accuracy of the updated re-identification model.
[0108] The above step of dividing the two nodes in the node pair corresponding to the set number into the same final cluster set when the set number is greater than the preset threshold, and assigning a preset pseudo label to the unlabeled image corresponding to each node according to the final cluster set to which it belongs,
[0109] In this embodiment, multiple graph data constructed according to different similarity thresholds for unlabeled images are clustered separately, and a pseudo label is assigned to each unlabeled image based on the statistical information of the multiple clustering results, providing sufficient training data for retraining the initial re-identification model, thereby improving the accuracy of the human re-identification model.
[0110] See also Figure 3, is a flow chart of a pseudo-label construction method for model training provided in the second embodiment of the present invention. In this pseudo-label construction method, the final cluster set can be determined directly by traversing each node and comparing the statistical results of the corresponding set number with a preset threshold, or by constructing an association matrix and performing batch screening to determine the final cluster set.
[0111] When the final cluster set is determined directly by traversing each node pair and comparing the statistical result of the corresponding set number with the preset threshold, please refer to the first embodiment and no further details will be given here.
[0112] When the final cluster set is determined by constructing a cluster association matrix and performing batch screening, after obtaining the number of sets of corresponding node pairs, the following steps are also included:
[0113] Step S301: constructing a cluster association matrix of a preset size, and initializing the element value of each element in the cluster association matrix to zero;
[0114] Step S302: Determine the element corresponding to each node pair in the clustering association matrix based on the two nodes in the node pair, and update the element value of the corresponding element with the set number of each node pair to obtain the clustering association matrix between N nodes;
[0115] Step S303 : Using a preset element threshold, filter the elements in the cluster association matrix between the N nodes, and determine a final cluster set based on the filtered elements.
[0116] The size of the cluster association matrix can be set to N*N, which is determined by the number of unlabeled images N. The preset element threshold can be used to measure whether the two nodes in a node pair are similar enough.
[0117] Specifically, based on the two nodes in the node pair, determine the corresponding element of each node pair in the cluster association matrix. For example, the unlabeled images corresponding to the two nodes in the node pair are identified as n1 and n2 respectively, then the corresponding element in the cluster association matrix is (n1, n2). The element value of the element at the (n1, n2) position in the cluster association matrix is updated with the set number of the node pair. The preset element threshold can be set to 4, and the implementer can adjust the element threshold according to actual conditions.
[0118] In this embodiment, the statistical results of the information storage node pairs of the cluster association matrix are used to save information storage space, and at the same time, threshold comparisons can be performed in batches, thereby improving the convenience and efficiency of the pseudo-label construction process.
[0119] Corresponding to the pseudo-label construction method for model training in the above embodiment, Figure 4The following is a block diagram of a pseudo-label construction device for model training, provided in a third embodiment of the present invention. The pseudo-label construction device is applied to a client. The computer device corresponding to the client is connected to a corresponding server to obtain unlabeled images captured by an image acquisition device from the server. The computer device corresponding to the client is equipped with a pre-trained initial re-identification model. This pre-trained initial re-identification model can be directly transferred from other human re-identification scenarios. For ease of explanation, only the portion relevant to the embodiment of the present invention is shown.
[0120] See also Figure 4 , the pseudo-label construction device includes:
[0121] A feature extraction module 41 is configured to input the obtained N unlabeled images into a pre-trained initial re-identification model for feature extraction, thereby obtaining N image features corresponding to the unlabeled images, where N is an integer greater than zero.
[0122] A graph data construction module 42 is configured to obtain at least one preset similarity threshold, and for any similarity threshold, treat an unlabeled image as a node, calculate the similarity of image features between any two nodes, and connect two nodes whose similarity is greater than the similarity threshold to form graph data corresponding to the similarity threshold;
[0123] The cluster processing module 43 is used to perform cluster processing on each graph data to obtain at least one cluster set corresponding to the graph data. For any node pair consisting of two nodes, the number of sets of node pairs belonging to the same cluster set is determined, and all node pairs are traversed to obtain the number of sets of corresponding node pairs.
[0124] The pseudo-label construction module 44 is used to divide the two nodes in the node pair of the corresponding set number into the same final cluster set when the set number is greater than a preset threshold, and assign a preset pseudo-label to the unlabeled image corresponding to each node according to the final cluster set to which it belongs. The N unlabeled images and their pseudo-labels are used to retrain the initial re-identification model to obtain an updated re-identification model.
[0125] Optionally, the clustering processing module 43 includes:
[0126] The random walk submodule is used to perform random walk processing on any graph data to obtain a random walk sequence;
[0127] The hierarchical coding submodule is used to perform hierarchical coding on the random walk sequence and calculate the optimization target based on the hierarchical coding result and the preset objective function;
[0128] A coding adjustment submodule is configured to optimize the optimization target by adjusting the hierarchical coding until the optimization target converges, and determine that the hierarchical coding adjustment result corresponding to the convergence of the optimization target is at least one cluster set of the corresponding graph data;
[0129] The graph data traversal submodule is used to traverse each graph data and obtain at least one cluster set corresponding to the graph data.
[0130] Optionally, the clustering processing module 43 includes:
[0131] The initialization submodule is used to initialize the number of sets to zero for any node pair;
[0132] The set number statistics submodule is used to traverse each cluster set. If both nodes in a node pair belong to the cluster set, the set number is increased by one to obtain the set number of the node pair.
[0133] Optionally, the pseudo-label construction module 44 includes:
[0134] The pseudo-label assignment submodule is used to count the number of all final cluster sets and assign corresponding pseudo-labels to each final cluster set based on the number;
[0135] The pseudo-label determination submodule is used to determine the final cluster set to which the unlabeled image belongs for the unlabeled image corresponding to any node, and use the pseudo-label corresponding to the final cluster set to which the unlabeled image belongs as the pseudo-label of the unlabeled image.
[0136] Optionally, the pseudo-label construction device further includes:
[0137] An image acquisition module is used to obtain M labeled images and their true labels, where M is an integer greater than zero;
[0138] The model training module is used to retrain the initial re-identification model using labeled images and their true labels, and N unlabeled images and their pseudo labels to obtain an updated re-identification model.
[0139] Optionally, the above model training module includes:
[0140] A first loss calculation submodule is configured to input the M labeled images into the initial re-identification model respectively to obtain the first recognition results of the M corresponding labeled images, and calculate the first recognition loss based on the first recognition results of the M corresponding labeled images, the true labels of the M corresponding labeled images, and a preset first recognition loss function;
[0141] A second loss calculation submodule is configured to input the N unlabeled images into the initial re-identification model respectively to obtain second recognition results of the N corresponding unlabeled images, and calculate a second recognition loss based on the second recognition results of the N corresponding unlabeled images, the pseudo labels of the N corresponding unlabeled images, and a preset second recognition loss function;
[0142] The model training submodule is used to retrain the initial re-identification model based on the first recognition loss and the second recognition loss to obtain an updated re-identification model.
[0143] Optionally, the second loss calculation submodule includes:
[0144] a coefficient multiplication unit, configured to multiply, for any unlabeled image, a pseudo label corresponding to the unlabeled image and a preset first coefficient to obtain a multiplication result;
[0145] A label smoothing unit is used to count the number of labels of all pseudo labels, compare the number of labels with a preset second coefficient, and add the obtained ratio and the multiplication result to obtain a smoothed label;
[0146] a sub-loss calculation unit, configured to calculate a second recognition sub-loss based on a second recognition result corresponding to the unlabeled image, a smoothed label corresponding to the unlabeled image, and a second recognition loss function;
[0147] The sub-loss addition unit is used to traverse all unlabeled images, obtain the second recognition sub-loss corresponding to each unlabeled image, and use the sum of all second recognition sub-losses as the second recognition loss.
[0148] It should be noted that the information interaction, execution process, etc. between the above-mentioned modules, sub-modules, and units are based on the same concept as the embodiment of the method of the present invention. Their specific functions and technical effects can be found in the method embodiment part and will not be repeated here.
[0149] Figure 5 This is a schematic diagram of the structure of a computer device provided in the fourth embodiment of the present invention. Figure 5 As shown, the computer device of this embodiment includes: at least one processor ( Figure 5 Only one is shown), a memory, and a computer program stored in the memory and executable on at least one processor, wherein when the processor executes the computer program, the steps of any of the above-mentioned pseudo-label construction method embodiments are implemented.
[0150] The computer device may include, but is not limited to, a processor and a memory. It will be understood by those skilled in the art that Figure 5The above is merely an example of a computer device and does not constitute a limitation on the computer device. The computer device may include more or fewer components than shown in the figure, or a combination of certain components, or different components. For example, it may also include a network interface, a display screen, and an input device.
[0151] The processor may be a CPU, or other general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic device, a discrete gate or transistor logic device, or a discrete hardware component. A general-purpose processor may be a microprocessor, or any conventional processor.
[0152] The memory includes a readable storage medium, an internal memory, etc., wherein the internal memory can be the memory of a computer device, and the internal memory provides an environment for the operation of the operating system and computer-readable instructions in the readable storage medium. The readable storage medium can be the hard disk of the computer device, and in other embodiments, it can also be an external storage device of the computer device, for example, 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 computer device. Furthermore, the memory can also include both the internal storage unit of the computer device and the external storage device. The memory is used to store the operating system, application programs, boot loaders (BootLoader), data, and other programs, such as the program code of the computer program. The memory can also be used to temporarily store data that has been output or is about to be output.
[0153] 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 for illustration. 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. The functional units and modules in the embodiment can be integrated into a processing unit, or each unit can exist physically alone, or two or more units can be integrated into one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of a software functional unit. In addition, the specific names of the functional units and modules are only for the convenience of distinguishing each other and are not used to limit the scope of protection of the present invention. The specific working process of the units and modules in the above-mentioned device can refer to the corresponding process in the aforementioned method embodiment, which will not be repeated here. If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present invention implements all or part of the processes in the above-mentioned embodiment method, which can be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium. When the computer program is executed by the processor, it can implement the steps of the above-mentioned method embodiment. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may include at least: any entity or device capable of carrying computer program code, recording medium, computer memory, read-only memory (ROM), random access memory (RAM), electric carrier signal, telecommunication signal and software distribution medium. For example, a USB flash drive, a mobile hard disk, a magnetic disk or an optical disk. In some jurisdictions, according to legislation and patent practice, computer-readable media cannot be electric carrier signals and telecommunication signals.
[0154] The present invention may implement all or part of the processes in the above-mentioned method embodiments, and may also be completed through a computer program product. When the computer program product runs on a computer device, the computer device can implement the steps in the above-mentioned method embodiments when executing the computer program product.
[0155] In the above embodiments, the description of each embodiment has its own focus. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant description of other embodiments.
[0156] Those skilled in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of the present invention.
[0157] In the embodiments provided by the present invention, it should be understood that the disclosed apparatus / computer equipment and methods can be implemented in other ways. For example, the apparatus / computer equipment embodiments described above are merely illustrative. For example, the division of modules or units is merely a logical function division. In actual implementation, there may be other division methods, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0158] Units described as separate components may or may not be physically separate, and components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of these units may be selected to achieve the purpose of this embodiment according to actual needs.
[0159] The above embodiments 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 they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. These modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the various embodiments of the present invention, and should all be included in the scope of protection of the present invention.
Claims
1. A pseudo-label construction method for model training, characterized in that: The pseudo-label construction method comprises: Input the obtained N unlabeled images into the pre-trained initial re-identification model for feature extraction, and obtain N image features corresponding to the unlabeled images, where N is an integer greater than zero; Obtain at least one preset similarity threshold, and for any similarity threshold, treat the unlabeled image as a node, calculate the similarity of image features of any two nodes, and connect two nodes whose similarity is greater than the similarity threshold to form graph data corresponding to the similarity threshold; Perform clustering on each graph data to obtain at least one cluster set corresponding to the graph data. For any pair of nodes, determine the number of sets that belong to the same cluster set. Traverse all node pairs to obtain the number of sets corresponding to the node pairs. When the number of sets is greater than a preset threshold, the two nodes in the node pair corresponding to the number of sets are divided into the same final clustering set, and a preset pseudo-label is assigned to the unlabeled image corresponding to each node according to the final clustering set to which it belongs. The N unlabeled images and their pseudo-labels are used to retrain the initial re-identification model to obtain an updated re-identification model.
2. The pseudo-label construction method according to claim 1, characterized in that: The clustering process is performed on each graph data to obtain at least one cluster set of the corresponding graph data, including: For any graph data, performing random walk processing on the graph data to obtain a random walk sequence; Performing hierarchical coding on the random walk sequence, and calculating an optimization target based on the hierarchical coding result and a preset target function; Optimizing the optimization target by adjusting the hierarchical coding until the optimization target converges, and determining that the hierarchical coding adjustment result corresponding to the convergence of the optimization target is at least one cluster set corresponding to the graph data; Traverse each graph data to obtain at least one cluster set corresponding to the graph data.
3. The pseudo-label construction method according to claim 1, characterized in that: For any two node pairs, determining the number of sets of nodes that belong to the same cluster set includes: For any node pair, initialize the set number to zero; Each cluster set is traversed, and if both nodes in the node pair belong to the cluster set, the set number is increased by one to obtain the set number of the node pair.
4. The pseudo-label construction method according to claim 1, characterized in that: The step of assigning a preset pseudo label to the unlabeled image corresponding to each node according to the final cluster set to which the image belongs includes: Counting the number of all final cluster sets, and assigning a corresponding pseudo label to each final cluster set based on the number; For an unlabeled image corresponding to any node, a final cluster set to which the unlabeled image belongs is determined, and a pseudo label corresponding to the final cluster set to which the unlabeled image belongs is used as a pseudo label of the unlabeled image.
5. The pseudo-label construction method according to any one of claims 1 to 4, characterized in that: The pseudo-label construction further includes: Get M labeled images and their true labels, where M is an integer greater than zero; The initial re-identification model is retrained using the labeled images and their true labels, and the N unlabeled images and their pseudo labels to obtain the updated re-identification model.
6. The pseudo-label construction method according to claim 5, characterized in that: The step of retraining the initial re-identification model using the labeled image and its true label, and the N unlabeled images and their pseudo labels to obtain the updated re-identification model comprises: Inputting the M labeled images into the initial re-identification model respectively to obtain M first recognition results corresponding to the labeled images, and calculating a first recognition loss based on the M first recognition results corresponding to the labeled images, the true labels of the M corresponding labeled images, and a preset first recognition loss function; Inputting the N unlabeled images into the initial re-identification model respectively to obtain second recognition results of N corresponding unlabeled images, and calculating a second recognition loss based on the second recognition results of the N corresponding unlabeled images, the pseudo labels of the N corresponding unlabeled images, and a preset second recognition loss function; The initial re-recognition model is retrained based on the first recognition loss and the second recognition loss to obtain the updated re-recognition model.
7. The pseudo-label construction method according to claim 6, characterized in that: The calculating the second recognition loss according to the second recognition results of the N corresponding unlabeled images, the pseudo labels of the N corresponding unlabeled images, and a preset second recognition loss function includes: For any unlabeled image, multiplying the pseudo label corresponding to the unlabeled image by a preset first coefficient to obtain a multiplication result; Counting the number of labels of all pseudo labels, comparing the number of labels with a preset second coefficient, and adding the obtained ratio to the multiplication result to obtain a smoothed label; Calculating a second identification sub-loss according to a second recognition result corresponding to the unlabeled image, a smoothed label corresponding to the unlabeled image, and the second recognition loss function; Traverse all unlabeled images to obtain the second recognition sub-loss corresponding to each unlabeled image, and take the sum of all second recognition sub-losses as the second recognition loss.
8. A pseudo-label construction device for model training, characterized in that: The pseudo-label construction device comprises: A feature extraction module is used to input the acquired N unlabeled images into the pre-trained initial re-identification model for feature extraction, thereby obtaining N image features corresponding to the unlabeled images, where N is an integer greater than zero; a graph data construction module configured to obtain at least one preset similarity threshold, and for any similarity threshold, treat the unlabeled image as a node, calculate the similarity of image features between any two nodes, and connect two nodes whose similarity is greater than the similarity threshold to form graph data corresponding to the similarity threshold; A clustering processing module is used to perform clustering processing on each graph data to obtain at least one cluster set corresponding to the graph data. For any node pair consisting of two nodes, the number of sets of the node pairs belonging to the same cluster set is determined, and all node pairs are traversed to obtain the number of sets of corresponding node pairs. The pseudo-label construction module is used to divide the two nodes in the node pair corresponding to the set number into the same final cluster set when the set number is greater than a preset threshold, and assign a preset pseudo-label to the unlabeled image corresponding to each node according to the final cluster set to which it belongs. The N unlabeled images and their pseudo-labels are used to retrain the initial re-identification model to obtain an updated re-identification model.
9. A computer device, characterized in that: The computer device includes a processor, a memory, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the pseudo-label construction method according to any one of claims 1 to 7 is implemented.
10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the pseudo-label construction method according to any one of claims 1 to 7 is implemented.
Citation Information
Patent Citations
Object clustering model obtaining method and object clustering method and device
CN114358111A
Pedestrian re-identification method and device based on semi-supervised learning, and storage medium
CN115457652A