Face recognition model training method, device and equipment based on category adaptation
By calculating adaptive parameters during face recognition model training, the problems of difficult example recognition and long-tail distribution are solved, and the accuracy and effect of face recognition are improved.
Patent Information
- Application Number
- CN202211715603.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-12-28
- Publication Date
- 2025-09-12
- Estimated Expiration
- 2042-12-28
AI Technical Summary
Existing face recognition models have problems with poor recognition effect and low recognition accuracy in difficult example recognition and long-tail distribution problems.
By maintaining the historical feature queue, the first adaptive parameters and the second adaptive parameters are calculated to reflect the difficulty and long-tail distribution of the category. These parameters are used to calculate new adaptive parameters, and the loss function is updated to guide the training of the face recognition model.
It significantly improves the accuracy and recognition effect of face recognition and solves the problems of difficult example recognition and long-tail distribution.
Smart Images

Figure CN116012914B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a face recognition model training method, device and equipment based on category adaptation. Background Art
[0002] With the development of deep learning, face recognition accuracy has significantly improved. However, face recognition still faces two challenges: difficult example recognition and long-tail distribution. Face recognition tasks in real-world scenarios often encounter many difficult examples. These examples may be caused by factors such as lighting and occlusion, and existing face recognition algorithms often misidentify such data. Similarly, face recognition accuracy is also limited by the balance of categories. When the face categories in the training data have a long-tail distribution, it is difficult to train a face recognition model with sufficient accuracy. Due to these issues, face recognition models obtained using existing training methods suffer from poor recognition performance and low recognition accuracy. Summary of the Invention
[0003] In view of this, the embodiments of the present application provide a face recognition model training method, device and equipment based on category adaptation to solve the problems of poor recognition effect and low recognition accuracy of face recognition models in the prior art.
[0004] According to a first aspect of an embodiment of the present application, a method for training a face recognition model based on category adaptation is provided, comprising: inputting a face image in a data set into a feature extraction network to obtain a current sample feature corresponding to the face image, and inputting the current sample feature into a preset historical feature queue; after each round of iterative training is completed, calculating the adaptive parameters of each face image category in the historical feature queue to obtain a first adaptive parameter for characterizing the difficulty of the category; calculating the long-tail value corresponding to each face image category based on the number of samples corresponding to each face image category in the data set, mapping the long-tail value to an adaptive parameter, and obtaining a second adaptive parameter for characterizing the long-tail distribution of the category; calculating a new adaptive parameter based on the first adaptive parameter and the second adaptive parameter, calculating a logical value based on the new adaptive parameter, solving the loss value of the loss function, updating the loss function using the loss value, and using the updated loss function to guide the training of the face recognition model.
[0005] According to a second aspect of an embodiment of the present application, a face recognition model training device based on category adaptation is provided, comprising: an input module configured to input a face image in a data set into a feature extraction network, obtain current sample features corresponding to the face image, and input the current sample features into a preset historical feature queue; a calculation module configured to calculate the adaptive parameters of each face image category in the historical feature queue after each round of iterative training is completed, to obtain a first adaptive parameter for characterizing the difficulty of the category; a mapping module configured to calculate the long-tail value corresponding to each face image category based on the number of samples corresponding to each face image category in the data set, map the long-tail value into an adaptive parameter, and obtain a second adaptive parameter for characterizing the long-tail distribution of the category; an update module configured to calculate a new adaptive parameter based on the first adaptive parameter and the second adaptive parameter, calculate a logical value based on the new adaptive parameter, solve the loss value of the loss function, update the loss function using the loss value, and guide the training of the face recognition model using the updated loss function.
[0006] According to a third aspect of an embodiment of the present application, an electronic device is provided, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the steps of the above method are implemented when the processor executes the program.
[0007] According to a fourth aspect of the embodiments of the present application, a computer-readable storage medium is provided, which stores a computer program. When the computer program is executed by a processor, the steps of the above method are implemented.
[0008] At least one of the above technical solutions adopted in the embodiments of the present application can achieve the following beneficial effects:
[0009] By inputting the face images in the data set into the feature extraction network, the current sample features corresponding to the face images are obtained, and the current sample features are input into the preset historical feature queue; after each round of iterative training is completed, the adaptive parameters of each face image category in the historical feature queue are calculated to obtain a first adaptive parameter for characterizing the difficulty of the category; based on the number of samples corresponding to each face image category in the data set, the long-tail value corresponding to each face image category is calculated, and the long-tail value is mapped to an adaptive parameter to obtain a second adaptive parameter for characterizing the long-tail distribution of the category; based on the first adaptive parameter and the second adaptive parameter, a new adaptive parameter is calculated, a logical value is calculated according to the new adaptive parameter, and the loss value of the loss function is solved, the loss function is updated using the loss value, and the updated loss function is used to guide the training of the face recognition model. This application calculates the first adaptive parameter and the second adaptive parameter after each round of iterative training. Since the first adaptive parameter can reflect the difficulty of the category and the second adaptive parameter can reflect the long-tail distribution of the category, the loss value is calculated based on the first adaptive parameter and the second adaptive parameter, and the loss value is used to reversely update the network, so that the face recognition model finally trained can solve the difficult example recognition problem and the long-tail distribution problem in face recognition, and improve the face recognition accuracy and recognition effect. BRIEF DESCRIPTION OF THE DRAWINGS
[0010] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following briefly introduces the drawings required for use in the embodiments or descriptions of the prior art. 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 any creative work.
[0011] Figure 1 This is a schematic diagram of the training process of the face recognition model provided in the embodiment of the present application;
[0012] Figure 2 1 is a flow chart of a face recognition model training method based on category adaptation provided in an embodiment of the present application;
[0013] Figure 3 Schematic diagram of the structure of the face recognition model training device based on category adaptation provided in an embodiment of the present application;
[0014] Figure 4 It is a structural diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0015] In the following description, specific details such as specific system structures and techniques are provided for purposes of illustration rather than limitation to facilitate a thorough understanding of the embodiments of the present application. However, it will be apparent to those skilled in the art that the present application may 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 avoid obscuring the description of the present application with unnecessary detail.
[0016] As mentioned in the background, the development of deep learning has significantly improved facial recognition accuracy. However, facial recognition still faces two challenges: hard-to-recognize examples and the long-tail distribution problem. For example, when a dataset contains a large number of face image categories with few samples, facial recognition performance can be significantly poor.
[0017] Face recognition tasks in real-world scenarios often encounter many difficult examples. These examples may be caused by factors such as lighting and occlusion, and existing face recognition algorithms often misidentify these data. Similarly, face recognition accuracy is also limited by the balance of categories. When the face categories in the training data have a long-tail distribution, it is difficult to train a face recognition model with sufficient accuracy. Due to these problems, face recognition models obtained using existing training methods suffer from poor recognition performance and low recognition accuracy.
[0018] In view of this, the embodiment of the present application provides a face recognition model training method based on category adaptation to solve the problem of difficult example recognition and long-tail distribution in the field of face recognition. The present application will maintain a historical feature queue for storing historical sample features; after each round of iterative training is completed, the first adaptive parameter and the second adaptive parameter are automatically calculated, wherein the first adaptive parameter can reflect the difficulty of the face image category, and the second adaptive parameter can reflect the long-tail distribution of the face image category; then the first adaptive parameter and the second adaptive parameter are used to calculate the new adaptive parameter, and the logical value is calculated according to the new adaptive parameter, and the loss value of the loss function is solved, and the loss value is used to reversely update the network, so that the face recognition model finally trained can solve the problem of difficult example recognition and long-tail distribution in face recognition, and can significantly improve the face recognition accuracy and recognition effect.
[0019] The contents of the technical solution of this application are described in detail below with reference to the accompanying drawings and specific embodiments.
[0020] Figure 1 Schematic diagram of the training process of the face recognition model based on category adaptation provided in the embodiment of the present application. Figure 1 As shown, the training process of the face recognition model may specifically include:
[0021] First, the face images in the dataset are input into the feature extraction network Backbone, which is used to extract the facial features of the face images (i.e., the current sample features) and input the current sample features into the historical feature queue. Then, in the difficulty adaptation module, after each round of iterative training, the first adaptive parameter of each face image category (i.e., adaptive Margin1, referred to as Margin1) is obtained by calculating the variance of the historical sample features in each face image category queue. Next, in the long-tail adaptation module, the long-tail value corresponding to each face image category is calculated based on the number of samples contained in each face image category in the dataset, and then the long-tail value is mapped to the second adaptive parameter (i.e., adaptive Margin2, referred to as Margin2). Finally, in the head module (Head module) of the face recognition model, Margin1 and Margin2 are weighted to obtain a new adaptive parameter (i.e., new Margin), and the logical value Logit is calculated based on the new Margin. The loss value Loss is solved based on the logical value Logit, and the loss value Loss is used to reversely update the network. The updated loss function is used to guide the training of the entire face recognition model.
[0022] The following is based on Figure 1 The training process of the face recognition model based on category adaptation is shown, which describes in detail the implementation process of the face recognition model training method of the present application.
[0023] Figure 2 This is a flow chart of the face recognition model training method based on category adaptation provided in an embodiment of the present application. Figure 2 The face recognition model training method based on category adaptation can be executed by the server. Figure 2 As shown, the face recognition model training method based on category adaptation may specifically include:
[0024] S201, inputting a face image in a data set into a feature extraction network, obtaining a current sample feature corresponding to the face image, and inputting the current sample feature into a preset historical feature queue;
[0025] S202, after each round of iterative training is completed, calculating the adaptive parameter of each face image category in the historical feature queue to obtain a first adaptive parameter for representing the difficulty level of the category;
[0026] S203, calculating the long-tail value corresponding to each facial image category based on the number of samples corresponding to each facial image category in the data set, mapping the long-tail value to an adaptive parameter, and obtaining a second adaptive parameter for characterizing the long-tail distribution of the category;
[0027] S204, based on the first adaptive parameter and the second adaptive parameter, calculate a new adaptive parameter, calculate a logical value according to the new adaptive parameter, and solve the loss value of the loss function, use the loss value to update the loss function, and use the updated loss function to guide the training of the face recognition model.
[0028] Specifically, the data set of the embodiment of the present application stores facial image samples, and the facial recognition model of the embodiment of the present application can be a neural network model formed based on any facial recognition algorithm. The present application does not make any specific limitation on the facial recognition algorithm.
[0029] Furthermore, the feature extraction network Backbone of the present application adopts the ResNet50 network, that is, after the facial image in the dataset is input into the feature extraction network Backbone, the ResNet50 network is used to extract the facial features of the input facial image (that is, the current sample features), and then the current sample features are input into the preset historical feature queue.
[0030] In some embodiments, the length of the historical feature queue is the number of facial image categories in the data set, and the elements in the historical feature queue are historical sample features corresponding to each facial image category.
[0031] Specifically, this application will maintain a historical feature queue in the difficulty adaptation module. The historical feature queue is used to store historical sample features. The length of the queue is the number of face image categories in the data set. The elements in the queue are historical sample features stored for each category. For example, its length can be 10,000. During each training process, the current sample feature will be placed in its corresponding category queue.
[0032] In some embodiments, the current sample features are input into a preset historical feature queue, including: during each round of iterative training, the current sample features output by the feature extraction network are placed into the corresponding face image category queue in the historical feature queue; and the historical sample features stored in the face image category queue are updated using the current sample features to maintain the historical feature queue.
[0033] Specifically, during each round of iterative training, the historical feature queue is updated and maintained by placing the current sample features extracted by the ResNet50 network into the historical feature queue. When the current sample features are input into the historical feature queue, the current sample features are placed in the corresponding face image category queue according to the face image category stored in the historical feature queue.
[0034] In some embodiments, an adaptive parameter of each facial image category in a historical feature queue is calculated to obtain a first adaptive parameter for characterizing the difficulty of the category, including: calculating the variance of historical sample features in each facial image category queue in the historical feature queue, normalizing the variance, and multiplying the normalized variance with a preset value to obtain a first adaptive parameter corresponding to each facial image category; wherein the variance is used to represent the difficulty of the current facial image category, and the current facial image category corresponding to a variance greater than a threshold is regarded as a difficult category, and the current facial image category corresponding to a variance less than a threshold is regarded as an easy category.
[0035] Specifically, after each round of iterative training is completed, the adaptive Margin1 corresponding to each face image category is calculated from the historical feature queue. In actual application, after each round of iteration, the variance of all historical sample features in each face image category queue in the historical feature queue is calculated, and the variance is used to represent the difficulty of the current face image category queue, that is, a large variance indicates that the current category is a difficult category, and a small variance indicates that the current category is an easy category.
[0036] Furthermore, after calculating the variance of each face image category queue, it is necessary to assign different margins to different face image categories. The calculated variance is normalized to a value between 0 and 1, and then the normalized variance corresponding to each face image category is multiplied by a preset value (such as 0.3). The resulting value is the first adaptive parameter corresponding to each face image category (i.e., adaptive Margin1). Since this adaptive parameter can characterize the difficulty of the current face image category, it is also called the difficulty Margin.
[0037] In some embodiments, based on the number of samples corresponding to each facial image category in the data set, the long-tail value corresponding to each facial image category is calculated, including: based on the number of samples corresponding to each facial image category in the data set, determining the maximum number of samples and the minimum number of samples, using the maximum number of samples and the minimum number of samples to normalize the number of samples corresponding to each facial image category, and using the normalized value as the long-tail value corresponding to each facial image category.
[0038] Specifically, in order to solve the long-tail distribution problem of samples in the data set, the present application calculates the long-tail value of each face image category in the long-tail adaptive module based on the number of samples (i.e., the number of face images) contained in each face image category in the data set, and calculates the second adaptive parameter (i.e., adaptive Margin2) based on the long-tail value.
[0039] Furthermore, the number of samples contained in different facial image categories in the statistical data set is first counted, and then the maximum number of samples and the minimum number of samples are determined. The original number of samples (that is, the number of samples contained in each facial image category) is normalized using the maximum number of samples and the minimum number of samples, so that the long-tail value of each facial image category can be calculated; then the long-tail value of each facial image category is mapped to Margin, and the Margin is used as the long-tail Margin (adaptive Margin2). The long-tail adaptive module of this application can calculate different Margins for facial image categories with different long-tail distributions, thereby improving the recognition effect of the network.
[0040] In some embodiments, based on the first adaptive parameter and the second adaptive parameter, a new adaptive parameter is calculated, including: using the preset weights corresponding to the first adaptive parameter and the second adaptive parameter, weighted summing the first adaptive parameter and the second adaptive parameter to obtain the new adaptive parameter.
[0041] Specifically, after obtaining the adaptive Margin1 and the adaptive Margin2, the Margin1 output by the difficulty adaptive module and the Margin2 output by the long-tail adaptive module are weightedly summed according to the preset weights corresponding to Margin1 and Margin2, so as to calculate the new adaptive parameter (i.e., the new Margin).
[0042] In some embodiments, logical values are calculated based on new adaptive parameters, and the loss value of the loss function is solved, including: in the head module of the face recognition model, logical values are calculated using preset weights and new adaptive parameters, and the loss value of the loss function is solved using logical values.
[0043] Specifically, after calculating the new Margin, in the Head module (i.e., the head module) of the face recognition model, the preset weights and the new Margin are used to calculate the logical value Logit, and the loss value Loss is calculated based on the logical value Logit. The network is reversely updated using the loss value Loss, that is, the logical value Logit is used to perform Softmax, that is, the loss value Loss is used to update the original loss function, and the updated loss function is used to guide the training of the face recognition model until a trained face recognition model is obtained.
[0044] According to the technical solution provided in the embodiment of the present application, in order to solve the difficult recognition problem and long-tail distribution problem in the face recognition task, the present application proposes a face recognition algorithm based on category adaptive Margin. The present application uses a queue to store historical sample features, and then generates a category-based Margin by calculating the variance in the queue after each round of iterative training. The Margin value can reflect the difficulty of the category; the present application also calculates the long-tail value based on the number of samples in the face image category, and then maps it to Margin, and calculates the new Margin by weighted summing the Margin calculated in the difficulty Margin module and the Margin in the long-tail Margin module; finally, the new Margin is used to calculate the logical value Logit, and the loss value Loss is calculated based on the logical value Logit, and the loss value Loss is used to reversely update the network to achieve the purpose of guiding the training of the face recognition model. The face recognition model trained using the technical solution of the present application can not only solve the difficult example recognition problem and long-tail distribution problem in face recognition, but also significantly improve the face recognition accuracy and face recognition effect.
[0045] The following are device embodiments of the present application, which can be used to implement the method embodiments of the present application. For details not disclosed in the device embodiments of the present application, please refer to the method embodiments of the present application.
[0046] Figure 3 Schematic diagram of the structure of the face recognition model training device based on category adaptation provided by the embodiment of the present application. Figure 3 As shown, the face recognition model training device based on category adaptation includes:
[0047] Input module 301 is configured to input the face image in the data set into the feature extraction network, obtain the current sample features corresponding to the face image, and input the current sample features into a preset historical feature queue;
[0048] The calculation module 302 is configured to calculate the adaptive parameter of each face image category in the historical feature queue after each round of iterative training is completed, to obtain a first adaptive parameter for representing the difficulty level of the category;
[0049] A mapping module 303 is configured to calculate a long-tail value corresponding to each facial image category based on the number of samples corresponding to each facial image category in the data set, and map the long-tail value to an adaptive parameter to obtain a second adaptive parameter for characterizing the long-tail distribution of the category;
[0050] The update module 304 is configured to calculate a new adaptive parameter based on the first adaptive parameter and the second adaptive parameter, calculate a logical value according to the new adaptive parameter, solve the loss value of the loss function, update the loss function using the loss value, and use the updated loss function to guide the training of the face recognition model.
[0051] In some embodiments, the length of the historical feature queue is the number of facial image categories in the data set, and the elements in the historical feature queue are historical sample features corresponding to each facial image category.
[0052] In some embodiments, Figure 3 During each round of iterative training, the input module 301 puts the current sample features output by the feature extraction network into the corresponding face image category queue in the historical feature queue; and uses the current sample features to update the historical sample features stored in the face image category queue to maintain the historical feature queue.
[0053] In some embodiments, Figure 3 The calculation module 302 calculates the variance of the historical sample features in each face image category queue in the historical feature queue, normalizes the variance, and multiplies the normalized variance with a preset value to obtain a first adaptive parameter corresponding to each face image category; wherein the variance is used to indicate the difficulty of the current face image category, and the current face image category corresponding to the variance greater than the threshold is regarded as a difficult category, and the current face image category corresponding to the variance less than the threshold is regarded as an easy category.
[0054] In some embodiments, Figure 3 The mapping module 303 determines the maximum sample number and the minimum sample number based on the number of samples corresponding to each facial image category in the data set, uses the maximum sample number and the minimum sample number to normalize the number of samples corresponding to each facial image category, and uses the normalized value as the long-tail value corresponding to each facial image category.
[0055] In some embodiments, Figure 3 The updating module 304 uses the preset weights corresponding to the first adaptive parameter and the second adaptive parameter to perform weighted summation on the first adaptive parameter and the second adaptive parameter to obtain a new adaptive parameter.
[0056] In some embodiments, Figure 3 The updating module 304 calculates the logical value in the head module of the face recognition model using the preset weights and the new adaptive parameters, and uses the logical value to solve the loss value of the loss function.
[0057] It should be understood that the size of the serial numbers of the steps in the above 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 this application.
[0058] Figure 4 Schematic diagram of the structure of the electronic device 4 provided in the embodiment of the present application. Figure 4 As shown, the electronic device 4 of this embodiment includes: a processor 401, a memory 402, and a computer program 403 stored in the memory 402 and executable on the processor 401. When the processor 401 executes the computer program 403, the steps of the above-mentioned method embodiments are implemented. Alternatively, when the processor 401 executes the computer program 403, the functions of the modules / units in the above-mentioned device embodiments are implemented.
[0059] For example, computer program 403 may be divided into one or more modules / units, which are stored in memory 402 and executed by processor 401 to implement the present application. One or more modules / units may be a series of computer program instruction segments capable of performing specific functions, and the instruction segments are used to describe the execution process of computer program 403 in electronic device 4.
[0060] The electronic device 4 may be a desktop computer, a notebook, a PDA, a cloud server, or other electronic device. The electronic device 4 may include but is not limited to a processor 401 and a memory 402. Those skilled in the art will appreciate that Figure 4 It is only an example of the electronic device 4 and does not constitute a limitation of the electronic device 4. It may include more or fewer components than shown in the figure, or a combination of certain components, or different components. For example, the electronic device may also include input and output devices, network access devices, buses, etc.
[0061] The processor 401 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor or any conventional processor, etc.
[0062] Memory 402 can be an internal storage unit of electronic device 4, such as a hard drive or memory of electronic device 4. Memory 402 can also be an external storage device of electronic device 4, such as a plug-in hard drive, a Smart Media Card (SMC), a Secure Digital (SD) card, a flash memory card, etc. equipped on electronic device 4. Furthermore, memory 402 can include both an internal storage unit of electronic device 4 and an external storage device. Memory 402 is used to store computer programs and other programs and data required by the electronic device. Memory 402 can also be used to temporarily store data that has been output or is about to be output.
[0063] Those skilled in the art can clearly understand that, for the convenience and brevity 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 one 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 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 system can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here.
[0064] 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.
[0065] 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. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0066] In the embodiments provided in this application, 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 schematic. For example, the division of modules or units is merely a logical function division. In actual implementation, there may be other division methods. Multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed may be through some interfaces, indirect coupling or communication connection of the apparatus or unit, which may be electrical, mechanical or other forms.
[0067] 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.
[0068] In addition, the functional units in the various embodiments of the present application may be integrated into a single processing unit, or each unit may exist physically separately, or two or more units may be integrated into a single unit. The aforementioned integrated units may be implemented in the form of hardware or software functional units.
[0069] If the integrated module / 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 process in the above-mentioned embodiment method, and can also be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium, and when the computer program is executed by the processor, it can implement the steps of the above-mentioned various method embodiments. The computer program may include computer program code, which may be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may include: any entity or device capable of carrying computer program code, recording medium, USB flash drive, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electric carrier signal, telecommunication signal and software distribution medium. It should be noted that the content contained in the computer-readable medium can be appropriately increased or decreased according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, computer-readable media do not include electric carrier signals and telecommunication signals.
[0070] 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 various embodiments of the present application, and should all be included in the scope of protection of the present application.
Claims
1. A face recognition model training method based on category adaptation, characterized in that: include: Inputting the face image in the data set into the feature extraction network to obtain the current sample features corresponding to the face image, and inputting the current sample features into the preset historical feature queue; After each round of iterative training is completed, the adaptive parameter of each face image category in the historical feature queue is calculated to obtain a first adaptive parameter for characterizing the difficulty of the category; Calculating a long-tail value corresponding to each facial image category based on the number of samples corresponding to each facial image category in the data set, mapping the long-tail value to an adaptive parameter, and obtaining a second adaptive parameter for characterizing the long-tail distribution of the category; Based on the first adaptive parameter and the second adaptive parameter, a new adaptive parameter is calculated, a logical value is calculated according to the new adaptive parameter, and a loss value of the loss function is solved, the loss function is updated using the loss value, and the updated loss function is used to guide the training of the face recognition model.
2. The method according to claim 1, characterized in that The length of the historical feature queue is the number of facial image categories in the data set, and the elements in the historical feature queue are historical sample features corresponding to each facial image category.
3. The method according to claim 2, characterized in that Inputting the current sample feature into a preset historical feature queue includes: During each round of iterative training, the current sample features output by the feature extraction network are placed into the corresponding face image category queue in the historical feature queue; The historical sample features stored in the face image category queue are updated using the current sample features to maintain the historical feature queue.
4. The method according to claim 1, wherein The step of calculating the adaptive parameter of each facial image category in the historical feature queue to obtain a first adaptive parameter for characterizing the difficulty of the category includes: Calculating the variance of the historical sample features in each facial image category queue in the historical feature queue, normalizing the variance, and multiplying the normalized variance by a preset value to obtain a first adaptive parameter corresponding to each facial image category; The variance is used to represent the difficulty of the current face image category. The current face image category corresponding to the variance greater than the threshold is regarded as the difficult category, and the current face image category corresponding to the variance less than the threshold is regarded as the easy category.
5. The method according to claim 1, characterized in that Calculating the long-tail value corresponding to each face image category based on the number of samples corresponding to each face image category in the data set includes: Based on the number of samples corresponding to each facial image category in the data set, the maximum number of samples and the minimum number of samples are determined, and the number of samples corresponding to each facial image category is normalized using the maximum number of samples and the minimum number of samples, and the normalized value is used as the long-tail value corresponding to each facial image category.
6. The method according to claim 1, characterized in that The calculating a new adaptive parameter based on the first adaptive parameter and the second adaptive parameter includes: The first adaptive parameter and the second adaptive parameter are weightedly summed using the preset weights corresponding to the first adaptive parameter and the second adaptive parameter, to obtain the new adaptive parameter.
7. The method according to claim 1, characterized in that The calculating of the logic value according to the new adaptive parameter and solving the loss value of the loss function include: In the head module of the face recognition model, the logic value is calculated using the preset weights and the new adaptive parameters, and the loss value of the loss function is solved using the logic value.
8. A face recognition model training device based on category adaptation, characterized in that: include: An input module is configured to input a facial image in a data set into a feature extraction network, obtain a current sample feature corresponding to the facial image, and input the current sample feature into a preset historical feature queue; a calculation module configured to calculate the adaptive parameter of each face image category in the historical feature queue after each round of iterative training is completed, to obtain a first adaptive parameter for representing the difficulty level of the category; a mapping module configured to calculate a long-tail value corresponding to each facial image category based on the number of samples corresponding to each facial image category in the data set, and map the long-tail value to an adaptive parameter to obtain a second adaptive parameter for characterizing the long-tail distribution of the category; The update module is configured to calculate new adaptive parameters based on the first adaptive parameters and the second adaptive parameters, calculate logical values according to the new adaptive parameters, solve the loss value of the loss function, update the loss function using the loss value, and use the updated loss function to guide the training of the face recognition model.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the method according to any one of claims 1 to 7 when executing the program.
10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.
Citation Information
Patent Citations
Face recognition method and device, electronic equipment and readable storage medium
CN112329619A
Model training method and device, storage medium and electronic device
CN114511042A