Optimization training method and device, image processing method and device, equipment and medium
By updating and integrating the parameters of the face recognition and attribute classification model in multi-task learning, the problem of performance degradation of individual tasks in multi-task training is solved, and higher overall performance and adaptability are achieved.
Patent Information
- Application Number
- CN202411814859.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-09
- Publication Date
- 2025-04-11
- Estimated Expiration
- 2044-12-09
AI Technical Summary
The existing multi-task learning methods have limitations in parameter update and model integration, resulting in the performance of individual tasks in multi-task training models deteriorating and affecting the overall performance.
By obtaining the training set composed of training images, face recognition and attribute classification submodels in the preset model are used to perform face recognition and attribute classification, the parameters of each submodel are updated according to the target results, and global parameters are calculated in loop iteration to replace submodel parameters until the preset conditions are met.
It realizes the reduction in performance of individual tasks in multi-task training, improves the recognition accuracy of the overall model and the accuracy of attribute classification, and enhances the adaptability and generalization capabilities of the model.
Smart Images

Figure CN119810883A_ABST
Abstract
Description
Technical Field
[0001] The present application is applicable to the field of image processing technology, and in particular relates to an optimization training method, an image processing method, a device, a equipment and a medium. Background Art
[0002] With the rapid development of artificial intelligence technology, face recognition and face attribute classification (such as gender, age, race, emotion, etc.) have been widely used in many fields, including security monitoring, social media, personalized advertising, and smart home. Traditional face recognition methods usually rely on specially designed feature extractors and classifiers. Although these methods perform well on specific tasks, they often fail to fully utilize rich contextual information. In addition, attribute classification tasks are usually regarded as independent problems, lacking support for face recognition tasks, resulting in overall performance degradation.
[0003] Research shows that multi-task learning (MTL) can improve the performance of different tasks by sharing feature learning. By processing face recognition and attribute classification in parallel, the model can learn richer and more discriminative feature representations, thereby enhancing its adaptability to different tasks. However, existing multi-task learning methods have limitations in parameter updating and model integration, and fail to fully realize the synergy between tasks.
[0004] Traditional multi-task training methods usually simply add task heads to achieve training of different tasks, especially in scenarios dealing with face recognition and face attribute classification. Although this method can introduce additional features to the face recognition model to a certain extent, such as attribute classification (such as gender, age, race, etc.), in practical applications it often leads to a decrease in the classification accuracy of the model in recognition tasks. The reasons for this phenomenon can be attributed to the following aspects: task conflict, overfitting, and loss function weight setting.
[0005] Therefore, how to optimize the model architecture and training process to avoid the performance degradation of individual tasks in the multi-task training model affecting the performance of the overall model has become an urgent problem to be solved. Summary of the invention
[0006] In view of this, the embodiments of the present application provide an optimized training method, image processing method, device, equipment and medium to solve the problem of how to optimize the model architecture and training process to avoid the performance degradation of individual tasks in the multi-task training model affecting the overall performance of the model when it is used.
[0007] In a first aspect, an embodiment of the present application provides an optimization training method, comprising: Acquire a training set consisting of first images for training, wherein the training set also includes classification annotations corresponding to attribute classifications of each of the first images; In one iteration, face recognition is performed on each of the first images through the face recognition sub-model in the preset model to obtain a corresponding target recognition result, and attribute classification is performed on each of the first images through the attribute classification sub-model in the preset model to obtain a corresponding target classification result; According to the target recognition result corresponding to each of the first images, the parameters of the face recognition sub-model are updated; according to the target classification result corresponding to each of the first images and the corresponding classification label, the parameters of the attribute classification sub-model are updated; After looping N iterations, obtaining a first parameter of the face recognition sub-model and a second parameter of the attribute classification sub-model, and updating the current global parameter according to the first parameter and the second parameter to obtain an updated global parameter, where N is an integer greater than zero; Use the updated global parameters to replace the first parameters of the face recognition sub-model and the second parameters of the attribute classification sub-model, return to execute in one iteration, use the face recognition sub-model in the preset model to perform face recognition on each of the first images, and obtain the corresponding target recognition result, until the preset conditions are met, and obtain the trained face recognition sub-model and the trained attribute classification sub-model.
[0008] In a second aspect, an embodiment of the present application provides an image processing method, including: Get the image to be processed; When performing face recognition on the image to be processed, inputting the image to be processed into a trained face recognition sub-model obtained after executing the optimization training method described in the first aspect, and outputting a first processing result; or When performing attribute classification on the image to be processed, the image to be processed is input into a trained attribute classification sub-model obtained after executing the optimization training method described in the first aspect, and a second processing result is output.
[0009] In a third aspect, an optimization training device according to an embodiment of the present application includes: A first acquisition module, used to acquire a training set consisting of first images for training, wherein the training set also includes classification annotations corresponding to attribute classifications of each of the first images; An image processing module, configured to perform face recognition on each of the first images in one iteration through a face recognition sub-model in a preset model to obtain a corresponding target recognition result, and perform attribute classification on each of the first images through an attribute classification sub-model in the preset model to obtain a corresponding target classification result; A submodule parameter updating module, used to update the parameters of the face recognition submodel according to the target recognition result corresponding to each of the first images, and to update the parameters of the attribute classification submodel according to the target classification result and the corresponding classification label corresponding to each of the first images; A global parameter calculation module, used for obtaining the first parameter of the face recognition sub-model and the second parameter of the attribute classification sub-model after looping N iterations, and updating the current global parameter according to the first parameter and the second parameter to obtain the updated global parameter, where N is an integer greater than zero; A cyclic training module is used to use the updated global parameters to replace the first parameter of the face recognition sub-model and the second parameter of the attribute classification sub-model, and return to execute the face recognition sub-model in the preset model in one iteration to perform face recognition on each of the first images to obtain the corresponding target recognition result, until the preset conditions are met, and the trained face recognition sub-model and the trained attribute classification sub-model are obtained.
[0010] In a fourth aspect, an embodiment of the present application provides an image processing device, including: A second acquisition module, used for acquiring an image to be processed; A face recognition processing module is used to input the image to be processed into a trained face recognition sub-model obtained after executing the optimization training method described in the first aspect when performing face recognition on the image to be processed, and output a first processing result; or The attribute classification processing module is used to input the image to be processed into the trained attribute classification sub-model obtained after executing the optimization training method described in the first aspect when performing attribute classification on the image to be processed, and output a second processing result.
[0011] In a fifth aspect, an embodiment of the present application 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 optimization training method described in the first aspect or the image processing method described in the second aspect is implemented.
[0012] In a sixth aspect, an embodiment of the present application 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 optimization training method as described in the first aspect, or the image processing method as described in the second aspect is implemented.
[0013] Compared with the prior art, the embodiments of the present application have the following beneficial effects: the present application obtains a training set consisting of first images for training, the training set also includes classification annotations of attribute classifications corresponding to each of the first images, in one iteration, face recognition is performed on each of the first images through the face recognition sub-model in the preset model to obtain a corresponding target recognition result, attribute classification is performed on each of the first images through the attribute classification sub-model in the preset model to obtain a corresponding target classification result, parameters of the face recognition sub-model are updated according to the target recognition result corresponding to each of the first images, and the target classification result corresponding to each of the first images and the corresponding classification annotations are updated according to the target classification result corresponding to each of the first images. The parameters of the attribute classification submodel are updated. After N iterations of the loop, the first parameter of the face recognition submodel and the second parameter of the attribute classification submodel are obtained. According to the first parameter and the second parameter, the current global parameter is updated to obtain the updated global parameter, where N is an integer greater than zero. The first parameter of the face recognition submodel and the second parameter of the attribute classification submodel are replaced with the updated global parameter, and the execution is returned. In one iteration, the face recognition submodel in the preset model is used to perform face recognition on each of the first images to obtain the corresponding target recognition result, until the preset conditions are met, and the trained face recognition submodel and the trained attribute classification submodel are obtained.
[0014] Through the face recognition sub-model and attribute classification sub-model in the preset model, each first image is processed accordingly, and the corresponding model is trained according to the corresponding processing results in N iterations. A global parameter is calculated with the parameters of each sub-model after N iterations of training to replace the parameters of all sub-models. The trained face recognition sub-model and the trained attribute classification sub-model are obtained through cyclic training. The two sub-models process the same image at the same time during the iteration and are trained independently. Then, through the final global parameter update, the final model can retain both the performance of face recognition and the performance of attribute classification. The final model can learn the characteristics of other tasks to improve the overall performance. BRIEF DESCRIPTION OF THE DRAWINGS
[0015] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.
[0016] Figure 1 It is a schematic diagram of an application environment of an optimization training method or an image processing method provided in Example 1 of the present application; Figure 2 It is a flowchart of an optimization training method provided in Example 2 of the present application; Figure 3 It is a structural diagram of an optimization training model provided in Example 2 of the present application; Figure 4 It is a flowchart of an optimization training method provided in Example 3 of the present application; Figure 5 It is a flowchart of an image processing method provided in Embodiment 4 of the present application; Figure 6 It is a structural schematic diagram of an optimization training device provided in Example 5 of the present application; Figure 7 is a structural schematic diagram of an image processing device provided in Embodiment 6 of the present application; Figure 8 It is a structural diagram of a computer device provided in Example 7 of the present application. DETAILED DESCRIPTION
[0017] In the following description, specific details such as specific system structures, technologies, etc. are provided for the purpose of illustration rather than limitation, so as to provide a thorough understanding of the embodiments of the present application. However, it should be clear to those skilled in the art that the present application may also be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to prevent unnecessary details from obstructing the description of the present application.
[0018] It should be understood that when used in the present specification and the appended claims, the term "comprising" indicates the presence of described features, wholes, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, wholes, steps, operations, elements, components and / or combinations thereof.
[0019] It should also be understood that the term “and / or” used in the specification and appended claims refers to any and all possible combinations of one or more of the associated listed items, and includes these combinations.
[0020] As used in the specification and appended claims of this application, the term "if" can be interpreted as "when" or "uponce" 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" can be interpreted as meaning "uponce it is determined" or "in response to determining" or "uponce [described condition or event] is detected" or "in response to detecting [described condition or event]", depending on the context.
[0021] In addition, in the description of the present application 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.
[0022] References to "one embodiment" or "some embodiments" etc. described in the specification of this application mean that one or more embodiments of the present application include specific features, structures or characteristics described in conjunction with the embodiment. Therefore, the statements "in one embodiment", "in some embodiments", "in some other embodiments", "in some other embodiments", etc. that appear in different places in this specification do not necessarily refer to the same embodiment, but mean "one or more but not all embodiments", unless otherwise specifically emphasized in other ways. The terms "including", "comprising", "having" and their variations all mean "including but not limited to", unless otherwise specifically emphasized in other ways.
[0023] The embodiments of the present application can acquire and process relevant data based on artificial intelligence technology. Among them, artificial intelligence is the theory, method, technology and application system that uses digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results.
[0024] AI basic technologies generally include sensors, dedicated AI chips, cloud computing, distributed storage, big data processing technology, operation / interaction systems, mechatronics, etc. AI software technologies mainly include computer vision technology, robotics technology, biometrics technology, speech processing technology, natural language processing technology, and machine learning / deep learning.
[0025] It should be understood that the size of the serial numbers of the steps in the following embodiments does not 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 embodiments of the present application.
[0026] In order to illustrate the technical solution of the present application, a specific embodiment is provided below for illustration.
[0027] The optimization training method and image processing method provided in the first embodiment of the present application can be applied to Figure 1 In an application environment, the optimization training method and the image processing method can both be applied to a server, and the server is used to deploy models corresponding to the optimization training method and the image processing method. The model corresponding to the optimization training method is an untrained model, which is trained by obtaining image data from a client or a database, and the model corresponding to the image processing method is a model trained by the optimization training method, which is used to obtain image data from a client or a database for face recognition or attribute classification.
[0028] The client includes, but is not limited to, a PDA, a desktop computer, a laptop computer, an ultra-mobile personal computer (UMPC), a netbook, a server computer device, a personal digital assistant (PDA), and other computer devices. The server can be implemented with an independent server or a server cluster consisting of multiple servers.
[0029] See also Figure 2 , is a flow chart of an optimization training method provided in Example 2 of the present application, and the above-mentioned optimization training method is applied to Figure 1 The server in . Figure 2 As shown, the optimization training method may include the following steps: Step S201, obtaining a training set consisting of first training images.
[0030] The training set also includes classification annotations for attribute classifications corresponding to each first image. The first images include but are not limited to images containing faces, that is, there may be images without faces in the first images, and such images can be used as negative samples or invalid samples during training. The first images in the training set all have corresponding attribute classification results, that is, classification annotations, which are used for supervision during subsequent attribute classification training.
[0031] In one embodiment, when the first image is used for training face recognition, supervised training may also be used. In this case, face recognition annotations need to be set in the training set. Of course, this embodiment is mainly based on unsupervised training, so there is no limit on the annotations corresponding to face recognition results included in the training set.
[0032] Step S202, in one iteration, face recognition is performed on each first image through the face recognition sub-model in the preset model to obtain a corresponding target recognition result, and attribute classification is performed on each first image through the attribute classification sub-model in the preset model to obtain a corresponding target classification result.
[0033] Among them, a face recognition sub-model and an attribute classification sub-model are set in the preset model. The face recognition sub-model is used to recognize the face in the image, for example, to obtain the facial features after locating the face position in the image, and the attribute classification sub-model is used to classify the attributes of the image, for example, to define the image attributes including 0 and 1, where 0 indicates that the image does not contain a human body image, and 1 indicates that the image contains a human body image. The final classification result of the image is 1 or 0.
[0034] In this application, two identical deep learning network structures are used for face recognition and attribute classification tasks respectively. For example, the face recognition model and the attribute classification model use convolutional neural networks (CNN) respectively.
[0035] Step S203, according to the target recognition result corresponding to each first image, the parameters of the face recognition sub-model are updated, and according to the target classification result corresponding to each first image and the corresponding classification label, the parameters of the attribute classification sub-model are updated.
[0036] Among them, after obtaining the target recognition result, the parameters of the face recognition sub-model are updated and adjusted in reverse by calculating the loss to complete one iteration of the face recognition sub-model. Similarly, after obtaining the target classification result, all target classification results and the classification labels of the corresponding target classification results are calculated for loss, so as to update and adjust the parameters of the attribute classification sub-model and complete one iteration of the attribute classification sub-model.
[0037] like Figure 3 As shown, it is a structural diagram of an optimization training model provided in Example 2 of the present application, wherein the first image is respectively input into the modules corresponding to the face feature extraction and the attribute feature extraction for feature extraction, and then the results of the feature extraction are respectively given to the corresponding fully connected layers and the corresponding losses are output, and the parameters of the feature extraction part are adjusted in reverse according to the losses, thereby forming an iteration.
[0038] For example, for the face recognition model, Triplet Loss (TL) is used to optimize the similarity of feature representations, while for the attribute classification model, Cross-Entropy Loss (CEL) is used to optimize the classification accuracy. The two models can use different optimizers (such as Adam or SGD) to meet the needs of their respective tasks.
[0039] Optionally, updating the parameters of the face recognition sub-model according to the target recognition result corresponding to each first image includes: For any first image, based on the triplet loss and in combination with the target recognition result of the first image, determine a triplet loss value corresponding to the first image; Traverse all first images to obtain triplet loss values corresponding to all first images, sum the triplet loss values corresponding to all first images to obtain face recognition loss; According to the face recognition loss, the parameters of the face recognition sub-model are updated.
[0040] Among them, the use of triplet loss to perform training is an unsupervised training. When processing the image, anchor samples (Anchor): representing the samples to be classified, positive samples (Positive): samples similar to the anchor samples, and negative samples (Negative): samples that are dissimilar to the anchor samples can be obtained.
[0041] The triplet loss is as follows: L=max{d(a,p)-d(a,n)+ margin,0} Among them, d(a,p) represents the distance metric between the anchor sample and the positive sample, d(a,n) represents the distance metric between the anchor sample and the negative sample, and margin represents the margin parameter, which is used to control the distance difference between the positive and negative samples. Using this triplet loss, there is no need for supervised training, which reduces the difficulty of constructing training samples when training the model.
[0042] Optionally, updating the parameters of the attribute classification sub-model according to the target classification result and the corresponding classification label corresponding to each first image includes: For any first image, calculate the cross entropy loss between the target classification result corresponding to the first image and the corresponding classification label to obtain the cross entropy loss value of the first image; Traverse all first images, obtain the cross entropy loss values corresponding to all first images, sum the cross entropy loss values corresponding to all first images, and obtain the attribute classification loss; According to the attribute classification loss, the parameters of the attribute classification sub-model are updated.
[0043] Among them, the cross entropy loss value is calculated by combining the target classification result with the corresponding classification annotation, and then the cross entropy loss values of all images are summed up to determine the attribute classification loss, and the attribute classification loss is used to reversely update the parameters of the attribute classification sub-model. Using cross entropy loss for supervised training can achieve better training results.
[0044] Step S204, after looping N iterations, obtain the first parameter of the face recognition sub-model and the second parameter of the attribute classification sub-model, and update the current global parameter according to the first parameter and the second parameter to obtain the updated global parameter.
[0045] Wherein, N is an integer greater than zero.
[0046] In each training iteration, the parameters of the two sub-models are updated independently. After every N iterations, the parameters of the backbone networks of the two sub-models are merged to obtain the updated global parameters. After the global model is updated, the parameters of the two trained sub-models are replaced with the global model parameters.
[0047] Step S205, use the updated global parameters to replace the first parameter of the face recognition sub-model and the second parameter of the attribute classification sub-model, return to execute in one iteration, use the face recognition sub-model in the preset model to perform face recognition on each first image, and obtain the corresponding target recognition result, until the preset conditions are met, and obtain the trained face recognition sub-model and the trained attribute classification sub-model.
[0048] When the parameters of the global model are updated, the two base models will continue to be trained with the updated parameters. Finally, after cyclic iterative training, a trained face recognition sub-model and a trained attribute classification sub-model are obtained. The trained face recognition sub-model can realize face recognition of images, and the trained attribute classification sub-model can realize attribute classification of images.
[0049] Through this parameter replacement mechanism, a tighter coupling is achieved between the two tasks. In this process, the face recognition model not only focuses on identifying different face categories, but also learns features related to face attributes with the help of shared parameters, thereby improving the accuracy and robustness of classification. At the same time, the attribute classification model can also obtain richer feature representations from the face recognition model, making it more accurate in identifying and distinguishing different attributes. In this way, the model can promote and complement each other when performing face recognition and attribute classification, and ultimately achieve better overall performance.
[0050] This coupling mechanism effectively utilizes the advantages of multi-task learning, not only making the model perform better on each task, but also improving the overall generalization ability. As training continues, this strategy of parameter replacement and coupled learning will help the model gradually achieve higher recognition accuracy and attribute classification accuracy in the process of continuous optimization, thereby achieving a more comprehensive face recognition solution.
[0051] The embodiment of the present application processes each first image accordingly through the face recognition sub-model and the attribute classification sub-model in the preset model, and trains the corresponding models according to the corresponding processing results in N iterations. A global parameter is calculated with the parameters of each sub-model after N iterations of training to replace the parameters of all sub-models. The trained face recognition sub-model and the trained attribute classification sub-model are obtained through cyclic training. The two sub-models process the same image at the same time during the iteration and are trained independently. Then, through the final global parameter update, the final model can retain both the performance of face recognition and the performance of attribute classification. The final model can learn the characteristics of other tasks to improve the overall performance.
[0052] See also Figure 4 , is a flow chart of an optimization training method provided in Example 3 of the present application. Figure 3As shown, in the above step S204, the current global parameter is updated according to the first parameter and the second parameter to obtain the updated global parameter, which may include the following steps: Step S401: perform weighted averaging on the first parameter and the second parameter to obtain a weighted average parameter.
[0053] Step S402: performing weighted averaging on the weighted average parameter and the current global parameter to obtain an updated global parameter.
[0054] Among them, the adoption numbers in the backbone networks of the two sub-models are weighted and merged, and the merged parameters are updated through the exponential moving average (EMA) to update the global network parameters, as follows: In the formula, express and The weighted summation result, that is, the weighted average parameter, Represents the parameters of the face feature extraction backbone of the face recognition sub-model, It represents the parameter of the attribute feature extraction backbone of the attribute classification sub-model. α represents the weighting coefficient. You can use the empirical value 0.5 or and Make adaptive adjustments. Indicates updating global parameters. Represents the current global parameter (i.e., the updated global parameter after the last iteration), which is updated by EMA. β is the EMA weighted value. For example, β can be set to 0.9-0.999.
[0055] Optionally, performing weighted averaging on the first parameter and the second parameter to obtain a weighted average parameter includes: Obtaining a first loss value of the face recognition sub-model when the first parameter is obtained, and a second loss value of the attribute classification sub-model when the second parameter is obtained; Determine a first weight corresponding to the first parameter and a second weight corresponding to the second parameter according to the first loss value and the second loss value; Multiply the first weight by the first parameter to obtain a first multiplication result, and multiply the second weight by the second parameter to obtain a second multiplication result; The first multiplication result and the second multiplication result are averaged to obtain a weighted average parameter.
[0056] The integration of the two sub-model parameters can adopt a simple weighted average method. In this embodiment, each model is weighted according to its performance on the current task to improve the performance of the global model.
[0057] In the embodiments of the present application, by combining multi-task learning and the EMA strategy, the performance of the two tasks can be mutually promoted. Studies have shown that when the model performs face recognition, it can use the features learned by attribute classification to improve the recognition accuracy. In addition, the EMA strategy helps to reduce the training fluctuations of the model, making the model more robust when facing different tasks and environments. In particular, when there is noise or imbalance in the data set, the stability of the model will be further enhanced.
[0058] See also Figure 5 , is a flow chart of an image processing method provided in Embodiment 4 of the present application, and the image processing method is applied to Figure 1 The server in . Figure 5 As shown, the image processing method may include the following steps: Step S501, obtaining an image to be processed.
[0059] Step S502, when performing face recognition on the image to be processed, the image to be processed is input into the trained face recognition sub-model obtained after executing the above-mentioned optimization training method, and a first processing result is output.
[0060] Step S503, when performing attribute classification on the image to be processed, the image to be processed is input into the trained attribute classification sub-model obtained after executing the above-mentioned optimization training method, and a second processing result is output.
[0061] Among them, the image processing method is a model trained using the above-mentioned optimization training method. In actual use, since the above-mentioned preset model includes a face recognition sub-model and an attribute classification sub-model, the two sub-models are trained by mutual learning, but when in use, the two sub-models are used independently, that is, the image is processed for face recognition through the trained face recognition sub-model, and the image is processed for attribute classification through the trained attribute classification sub-model.
[0062] Specifically, the face recognition sub-model is deployed on the server side. When performing a face recognition task, face recognition processing is performed on the acquired image to be processed to obtain a first processing result, namely, the face recognition result. The attribute classification sub-model is deployed on the server side. When performing an attribute classification task, attribute classification processing is performed on the acquired image to be processed to obtain a second processing result, namely, the attribute classification result.
[0063] The embodiment of the present application processes each first image accordingly through the face recognition sub-model and the attribute classification sub-model in the preset model, and trains the corresponding models according to the corresponding processing results in N iterations. A global parameter is calculated with the parameters of each sub-model after N iterations of training to replace the parameters of all sub-models. The trained face recognition sub-model and the trained attribute classification sub-model are obtained through cyclic training. The two sub-models process the same image at the same time during the iteration and are trained independently. Then, through the final global parameter update, the final model can retain both the performance of face recognition and the performance of attribute classification. The final model can learn the characteristics of other tasks to improve the overall performance.
[0064] Corresponding to the optimization training method of the above embodiment, Figure 6 The structural block diagram of the optimization training device provided in the fifth embodiment of the present application is shown. The optimization training device can be used for the above Figure 1 For ease of description, only the parts related to the embodiment of the present application are shown.
[0065] See also Figure 6 , the optimization training device comprises: A first acquisition module 61 is used to acquire a training set consisting of first images for training, wherein the training set also includes classification labels corresponding to attribute classifications of each first image; The image processing module 62 is used to perform face recognition on each first image in one iteration by using the face recognition sub-model in the preset model to obtain a corresponding target recognition result, and perform attribute classification on each first image by using the attribute classification sub-model in the preset model to obtain a corresponding target classification result; The submodule parameter updating module 63 is used to update the parameters of the face recognition submodel according to the target recognition result corresponding to each first image, and to update the parameters of the attribute classification submodel according to the target classification result corresponding to each first image and the corresponding classification label; A global parameter calculation module 64 is used to obtain the first parameter of the face recognition sub-model and the second parameter of the attribute classification sub-model after looping N iterations, and update the current global parameter according to the first parameter and the second parameter to obtain an updated global parameter, where N is an integer greater than zero; The loop training module 65 is used to replace the first parameter of the face recognition sub-model and the second parameter of the attribute classification sub-model with the updated global parameters, and return to execute in one iteration, using the face recognition sub-model in the preset model to perform face recognition on each first image to obtain the corresponding target recognition result, until the preset conditions are met, and a trained face recognition sub-model and a trained attribute classification sub-model are obtained.
[0066] Optionally, the submodule parameter updating module 63 includes: A triplet loss calculation unit, for determining, for any first image, a triplet loss value corresponding to the first image based on the triplet loss and in combination with a target recognition result of the first image; A face recognition loss unit, used for traversing all first images, obtaining triplet loss values corresponding to all first images, and summing the triplet loss values corresponding to all first images to obtain face recognition loss; The face recognition parameter updating unit is used to update the parameters of the face recognition sub-model according to the face recognition loss.
[0067] Optionally, the submodule parameter updating module 63 includes: A cross entropy loss calculation unit, used to calculate, for any first image, a cross entropy loss between a target classification result corresponding to the first image and a corresponding classification label, to obtain a cross entropy loss value of the first image; An attribute classification loss unit, used to traverse all first images, obtain cross entropy loss values corresponding to all first images, and sum the cross entropy loss values corresponding to all first images to obtain attribute classification loss; The attribute classification parameter updating unit is used to update the parameters of the attribute classification sub-model according to the attribute classification loss.
[0068] Optionally, the global parameter calculation module 64 includes: A parameter weighted averaging unit, used to perform weighted averaging on the first parameter and the second parameter to obtain a weighted average parameter; The global parameter updating unit is used to perform weighted averaging on the weighted average parameter and the current global parameter to obtain an updated global parameter.
[0069] Optionally, a parameter weighted averaging unit includes: A loss acquisition subunit, used to acquire a first loss value of the face recognition submodel when the first parameter is obtained, and a second loss value of the attribute classification submodel when the second parameter is obtained; A weight calculation subunit, used to determine a first weight corresponding to the first parameter and a second weight corresponding to the second parameter according to the first loss value and the second loss value; A product operator unit, configured to multiply the first weight by the first parameter to obtain a first multiplication result, and to multiply the second weight by the second parameter to obtain a second multiplication result; The parameter weighted average subunit is used to average the first multiplication result and the second multiplication result to obtain a weighted average parameter.
[0070] It should be noted that the information interaction, execution process and other contents between the above-mentioned modules are based on the same concept as the method embodiment of the present application. Their specific functions and technical effects can be found in the method embodiment part and will not be repeated here.
[0071] Corresponding to the image processing method of the above embodiment, Figure 7 The structure block diagram of the image processing device provided in the sixth embodiment of the present application is shown. The image processing device can be used for the above Figure 1 For ease of description, only the parts related to the embodiment of the present application are shown.
[0072] See also Figure 7 , the image processing includes: A second acquisition module 71, used to acquire an image to be processed; The face recognition processing module 72 is used to input the image to be processed into the trained face recognition sub-model obtained after executing the above-mentioned optimization training method when performing face recognition on the image to be processed, and output a first processing result; or The attribute classification processing module 73 is used to input the image to be processed into the trained attribute classification sub-model obtained after executing the above-mentioned optimization training method when performing attribute classification on the image to be processed, and output a second processing result.
[0073] It should be noted that the information interaction, execution process and other contents between the above-mentioned modules are based on the same concept as the method embodiment of the present application. Their specific functions and technical effects can be found in the method embodiment part and will not be repeated here.
[0074] Figure 8 This is a schematic diagram of the structure of a computer device provided in Example 7 of this application. Figure 8 As shown, the computer device of this embodiment includes: at least one processor ( Figure 8 Only one is shown in the figure), a memory, and a computer program stored in the memory and executable on a processor, wherein at least one processor implements the steps in any of the above-mentioned optimization training methods or image processing method embodiments when executing the computer program.
[0075] The computer device may include, but is not limited to, a processor and a memory. Those skilled in the art will appreciate that Figure 8 This 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 those 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.
[0076] The processor may be a CPU, or other general-purpose processors, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor, etc.
[0077] The memory includes a readable storage medium, an internal memory, etc., wherein the internal memory may 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 may be a hard disk of a computer device, and in other embodiments, it may 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. Further, the memory may also include both an internal storage unit of the computer device and an external storage device. The memory is used to store an operating system, an application program, a boot loader (BootLoader), data, and other programs, such as the program code of a computer program, etc. The memory may also be used to temporarily store data that has been output or is to be output.
[0078] The technicians in the relevant field 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 practical applications, the above-mentioned function allocation can be completed by different functional units and modules as needed, that is, the internal structure of the device is 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 separately, 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 software functional units. 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 this application. The specific working process of the units and modules in the above-mentioned device can refer to the corresponding process in the above-mentioned 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 application 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, and the computer program can be stored in a computer-readable storage medium. When the computer program is executed by the processor, the steps of the above-mentioned method embodiment can be implemented. 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 at least include: 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.
[0079] The present application implements all or part of the processes in the above-mentioned embodiment method, 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 embodiment when executing the computer program product.
[0080] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0081] Those of ordinary skill 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. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0082] In the embodiments provided in the present application, it should be understood that the disclosed devices / computer equipment and methods can be implemented in other ways. For example, the device / computer equipment embodiments described above are only schematic, for example, the division of modules or units is only a logical function division, and there may be other division methods in actual implementation, 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.
[0083] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0084] The above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application 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 embodiments of the present application, and should all be included in the protection scope of the present application.
Claims
1. An optimization training method, characterized in that: include: Acquire a training set consisting of first images for training, wherein the training set also includes classification annotations corresponding to attribute classifications of each of the first images; In one iteration, face recognition is performed on each of the first images through the face recognition sub-model in the preset model to obtain a corresponding target recognition result, and attribute classification is performed on each of the first images through the attribute classification sub-model in the preset model to obtain a corresponding target classification result; According to the target recognition result corresponding to each of the first images, the parameters of the face recognition sub-model are updated; according to the target classification result corresponding to each of the first images and the corresponding classification label, the parameters of the attribute classification sub-model are updated; After looping N iterations, obtaining a first parameter of the face recognition sub-model and a second parameter of the attribute classification sub-model, and updating the current global parameter according to the first parameter and the second parameter to obtain an updated global parameter, where N is an integer greater than zero; Use the updated global parameters to replace the first parameters of the face recognition sub-model and the second parameters of the attribute classification sub-model, return to execute in one iteration, use the face recognition sub-model in the preset model to perform face recognition on each of the first images, and obtain the corresponding target recognition result, until the preset conditions are met, to obtain the trained face recognition sub-model and the trained attribute classification sub-model.
2. The optimization training method according to claim 1, characterized in that: The updating of the parameters of the face recognition sub-model according to the target recognition result corresponding to each of the first images includes: For any first image, based on the triplet loss and in combination with the target recognition result of the first image, determine a triplet loss value corresponding to the first image; Traverse all first images to obtain triplet loss values corresponding to all first images, sum the triplet loss values corresponding to all first images to obtain face recognition loss; According to the face recognition loss, the parameters of the face recognition sub-model are updated.
3. The optimization training method according to claim 1, characterized in that: The updating of the parameters of the attribute classification sub-model according to the target classification result and the corresponding classification label corresponding to each of the first images includes: For any first image, calculate the cross entropy loss between the target classification result corresponding to the first image and the corresponding classification label to obtain the cross entropy loss value of the first image; Traverse all first images, obtain the cross entropy loss values corresponding to all first images, sum the cross entropy loss values corresponding to all first images, and obtain the attribute classification loss; According to the attribute classification loss, the parameters of the attribute classification sub-model are updated.
4. The optimization training method according to claim 1, characterized in that: The updating of the current global parameter according to the first parameter and the second parameter to obtain the updated global parameter includes: Taking a weighted average of the first parameter and the second parameter to obtain a weighted average parameter; The weighted average parameter and the current global parameter are weightedly averaged to obtain an updated global parameter.
5. The optimization training method according to claim 4, characterized in that: The step of performing weighted averaging on the first parameter and the second parameter to obtain a weighted average parameter includes: Obtaining a first loss value of the face recognition sub-model when the first parameter is obtained, and a second loss value of the attribute classification sub-model when the second parameter is obtained; Determine a first weight corresponding to the first parameter and a second weight corresponding to the second parameter according to the first loss value and the second loss value; Multiplying the first weight by the first parameter to obtain a first multiplication result, and multiplying the second weight by the second parameter to obtain a second multiplication result; The first multiplication result and the second multiplication result are averaged to obtain a weighted average parameter.
6. An image processing method, characterized in that: include: Get the image to be processed; When performing face recognition on the image to be processed, inputting the image to be processed into a trained face recognition sub-model obtained after executing the optimization training method according to any one of claims 1 to 5, and outputting a first processing result; or When performing attribute classification on the image to be processed, the image to be processed is input into a trained attribute classification sub-model obtained after executing the optimization training method as described in any one of claims 1 to 5, and a second processing result is output.
7. An optimization training device, characterized in that: include: A first acquisition module, used to acquire a training set consisting of first images for training, wherein the training set also includes classification annotations corresponding to attribute classifications of each of the first images; An image processing module, configured to perform face recognition on each of the first images in one iteration through a face recognition sub-model in a preset model to obtain a corresponding target recognition result, and perform attribute classification on each of the first images through an attribute classification sub-model in the preset model to obtain a corresponding target classification result; A submodule parameter updating module, used to update the parameters of the face recognition submodel according to the target recognition result corresponding to each of the first images, and to update the parameters of the attribute classification submodel according to the target classification result and the corresponding classification label corresponding to each of the first images; A global parameter calculation module, used for obtaining the first parameter of the face recognition sub-model and the second parameter of the attribute classification sub-model after looping N iterations, and updating the current global parameter according to the first parameter and the second parameter to obtain the updated global parameter, where N is an integer greater than zero; A cyclic training module is used to use the updated global parameters to replace the first parameter of the face recognition sub-model and the second parameter of the attribute classification sub-model, and return to execute the face recognition sub-model in the preset model in one iteration to perform face recognition on each of the first images to obtain the corresponding target recognition result, until the preset conditions are met, and the trained face recognition sub-model and the trained attribute classification sub-model are obtained.
8. An image processing device, characterized in that: include: A second acquisition module, used for acquiring an image to be processed; A face recognition processing module, used for inputting the image to be processed into a trained face recognition sub-model obtained after executing the optimization training method according to any one of claims 1 to 5 when performing face recognition on the image to be processed, and outputting a first processing result; or The attribute classification processing module is used to input the image to be processed into a trained attribute classification sub-model obtained after executing the optimization training method as described in any one of claims 1 to 5 when performing attribute classification on the image to be processed, and output a second processing result.
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 optimization training method as described in any one of claims 1 to 5 or the image processing method as described in claim 6 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 optimization training method according to any one of claims 1 to 5 or the image processing method according to claim 6 is implemented.
Citation Information
Patent Citations
Face recognition and attribute classification method based on multi-task convolutional neural network
CN111814706A
Face recognition model training method and device
CN115631522A
Fine-grained image classification model training method based on category-level soft target supervision
CN116563602A
Living body detection method based on life clues and vertical field large model normal form
CN117576791A