Methods, apparatus, equipment and storage media for training deep learning models for face recognition
By employing a dual-branch basic unit and multi-stage feature aggregation method, combined with a dynamic margin loss function, the problem of insufficient feature extraction and class imbalance in existing face recognition models is solved, thereby improving the accuracy and effectiveness of face recognition.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- BEIJING LONGZHI DIGITAL TECH CO LTD
- Filing Date
- 2022-12-30
- Publication Date
- 2026-05-26
AI Technical Summary
Existing face recognition models are unable to extract rich basic features from face images, their feature representation ignores detailed features, and they suffer from class imbalance, resulting in low recognition accuracy.
Feature maps are extracted and concatenated using dual-branch basic units, combined with a backbone network for multi-stage feature aggregation, and trained using a dynamic margin loss function weighted by the number of samples.
It improves the accuracy and recognition performance of the face recognition model, solves the class imbalance problem, and extracts richer feature representations.
Smart Images

Figure CN115953820B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and in particular to a method, apparatus, device and storage medium for training a deep learning model for face recognition. Background Technology
[0002] In the training of face recognition models, it is necessary to consider the impact of basic units on model training, as well as how to obtain more discriminative feature representations. In addition, the class imbalance problem of training data must also be considered, which brings difficulties to the design of face recognition models.
[0003] Traditional face recognition models typically consist of only one convolutional layer, which easily overlooks crucial information from the original image. Furthermore, traditional face recognition model training often only uses the output features of the last convolutional layer as the feature representation, ignoring the detailed features of previous layers. Additionally, face recognition training sets often suffer from significant class imbalance. These issues prevent existing face recognition models from extracting rich, fundamental features from face images, resulting in neglected detailed features and low accuracy and poor face recognition performance due to class imbalance in the training set. Summary of the Invention
[0004] In view of this, embodiments of this application provide a method, apparatus, device, and storage medium for training a deep learning model for face recognition, in order to solve the problems of existing technologies that cannot extract rich basic features of face images, feature representation ignores detailed features, and face recognition models have low accuracy and poor face recognition performance.
[0005] A first aspect of this application provides a method for training a deep learning model for face recognition, comprising: inputting a face sample image into a predetermined dual-branch basic unit; extracting a first feature map and a second feature map using the first branch and the second branch of the dual-branch basic unit, respectively; concatenating the first feature map and the second feature map to obtain a transformed feature map; inputting the transformed feature map into a backbone network; processing the feature map output by a preset target stage in the backbone network to obtain a feature vector corresponding to each target stage; aggregating the feature vectors to obtain a target feature vector; determining the angle between the target feature vector and the class center of each face category; determining an additive margin parameter based on the number of samples corresponding to the face category and the maximum number of samples in the largest class; inputting the angle and the additive margin parameter into a preset loss function to calculate a loss value; and using the loss value to back-update the parameters of the deep learning model for face recognition, so as to train the deep learning model for face recognition.
[0006] A second aspect of this application provides a face recognition deep learning model training apparatus, comprising: an extraction module configured to input a face sample image into a predetermined dual-branch basic unit, extract a first feature map and a second feature map using a first branch and a second branch in the dual-branch basic unit respectively, and concatenate the first feature map and the second feature map to obtain a transformed feature map; an aggregation module configured to input the transformed feature map into a backbone network, process the feature map output by a preset target stage in the backbone network to obtain a feature vector corresponding to each target stage, and aggregate the feature vectors to obtain a target feature vector; a loss module configured to determine the angle between the target feature vector and the class center of each face category, and determine an additive margin parameter based on the number of samples of the face sample image corresponding to the face category and the maximum number of samples of the largest category, and input the angle and the additive margin parameter into a preset loss function to calculate a loss value; and a training module configured to use the loss value to back-update the parameters of the face recognition deep learning model in order to train the face recognition deep learning model.
[0007] A third aspect of this application provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the steps of the above-described method.
[0008] A fourth aspect of this application provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the steps of the above-described method.
[0009] The above-described technical solutions adopted in the embodiments of this application can achieve the following beneficial effects:
[0010] By inputting face sample images into a predetermined dual-branch basic unit, the first and second feature maps are extracted using the first and second branches of the dual-branch basic unit, respectively. The first and second feature maps are then concatenated to obtain a transformed feature map. The transformed feature map is input into a backbone network, and the feature maps output by the preset target stages in the backbone network are processed to obtain feature vectors corresponding to each target stage. The feature vectors are then aggregated to obtain the target feature vector. The angle between the target feature vector and the class center of each face category is determined, and the additive margin parameter is determined based on the number of samples corresponding to the face category and the maximum number of samples in the largest class. The angle and the additive margin parameter are input into a preset loss function to calculate the loss value. The parameters of the face recognition deep learning model are then updated using the loss value to train the face recognition deep learning model. The dual-branch basic unit of this application can extract richer basic features of face images, aggregate the feature vectors output from the multi-target stage, so that the final feature expression has both high-dimensional global information and low-dimensional detailed information. Finally, the loss function is calculated based on the number of samples to solve the problem of class imbalance in the training set, thereby improving the accuracy and face recognition effect of the face recognition model. Attached Figure Description
[0011] To more clearly illustrate the technical solutions in the embodiments of this application, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0012] Figure 1 This is a flowchart illustrating the face recognition deep learning model training method provided in an embodiment of this application;
[0013] Figure 2 This is a schematic diagram of the process of extracting feature maps using dual-branch basic units in an embodiment of this application;
[0014] Figure 3 This is a flowchart illustrating the multi-stage feature aggregation process using a backbone network in an embodiment of this application.
[0015] Figure 4 This is a schematic diagram of the structure of the face recognition deep learning model training device provided in the embodiments of this application;
[0016] Figure 5 This is a schematic diagram of the structure of the electronic device provided in the embodiments of this application. Detailed Implementation
[0017] In the following description, specific details such as particular system architectures and techniques are set forth for illustrative purposes and not for limitation, in order to provide a thorough understanding of the embodiments of this application. However, those skilled in the art will understand that this application may also be implemented in other embodiments without these specific details. In other instances, detailed descriptions of well-known systems, apparatuses, circuits, and methods have been omitted so as not to obscure the description of this application with unnecessary detail.
[0018] As described in the background section, current face recognition model training tasks require consideration of the impact of the basic unit (the first convolutional layer) on model training, as well as how to obtain more discriminative feature representations. Additionally, the class imbalance problem of training data must be considered, which brings difficulties to the design of face recognition models.
[0019] Traditional face recognition models typically consist of only one convolutional layer, which easily overlooks crucial information from the original image. Furthermore, traditional face recognition model training often only uses the output features of the last convolutional layer as the feature representation, ignoring the detailed features of previous layers. Additionally, face recognition training sets often suffer from significant class imbalance. These issues prevent existing face recognition models from extracting rich, fundamental features from face images, resulting in neglected detailed features and low accuracy and poor face recognition performance due to class imbalance in the training set.
[0020] In view of this, to solve the above problems, this application provides a face recognition deep learning model training method based on dual-branch basic units and multi-stage feature aggregation. This application first utilizes dual-branch basic units to extract richer basic features from face images; then, it uses a multi-stage feature aggregation method to aggregate the feature vectors output from multiple target stages, so that the final feature representation contains both high-dimensional global information and low-dimensional detailed information; finally, it uses a dynamic margin loss function weighted by the number of samples to solve the long-tail problem of the number of samples in the training set (i.e., the problem of class imbalance). The technical solution of this application will be described in detail below with reference to the accompanying drawings and specific embodiments.
[0021] Figure 1 This is a flowchart illustrating the face recognition deep learning model training method provided in this application embodiment. Figure 1 The training method for deep learning models for face recognition can be executed by a server. For example... Figure 1 As shown, the training method for this face recognition deep learning model can specifically include:
[0022] S101, input the face sample image into the predetermined dual-branch basic unit, extract the first feature map and the second feature map using the first branch and the second branch in the dual-branch basic unit respectively, and concatenate the first feature map and the second feature map to obtain the transformed feature map.
[0023] S102, input the transformed feature map into the backbone network, process the feature map output by the preset target stage in the backbone network to obtain the feature vector corresponding to each target stage, and aggregate the feature vectors to obtain the target feature vector.
[0024] S103, determine the angle between the target feature vector and the class center of each face category, and determine the additive margin parameter based on the number of samples of the face sample image corresponding to the face category and the number of samples of the largest category. Input the angle and the additive margin parameter into the preset loss function to calculate the loss value.
[0025] S104 uses the loss value to update the parameters of the face recognition deep learning model in reverse, so as to train the face recognition deep learning model.
[0026] Specifically, the face sample images in this application are face images in a face recognition dataset. That is, the input of the face recognition deep learning model of this applicant is a face recognition dataset, which contains multiple face images and the ID information (i.e., face category) corresponding to each face image. In practical applications, the image data in the face recognition dataset is usually more than 1 million images, and the number of IDs is usually more than 100,000.
[0027] It should be noted that the face recognition deep learning model in the embodiments of this application can also be referred to as a face recognition model. This application does not limit the model structure of the face recognition deep learning model. Any face recognition deep learning model with any model structure is applicable to this application. For example, deep learning models such as ViT can be used.
[0028] Furthermore, the deep learning model for face recognition trained using this application can recognize input face images, and the deep learning model for face recognition can output a feature vector of length 512 corresponding to the face image. This feature vector can be used for subsequent face comparison and other tasks.
[0029] The training of the applicant's face recognition deep learning model includes the following three parts: feature extraction of dual-branch basic units, multi-stage feature aggregation, and dynamic margin loss weighted by the number of samples. The above three stages of the technical solution of this application will be described in detail below with reference to specific embodiments.
[0030] In some embodiments, extracting a first feature map using the first branch in a dual-branch basic unit includes: inputting a face sample image into a first convolutional layer for convolution processing, and performing batch normalization and activation function processing on the convolutionally processed feature map to obtain a first output feature map; inputting the first output feature map into a second convolutional layer for convolution processing, and performing batch normalization and activation function processing on the convolutionally processed feature map to obtain a second output feature map, and using the second output feature map as the first feature map.
[0031] Specifically, the input to the dual-branch basic unit of this application can be a face image. The dual-branch basic unit uses two branches to extract feature maps, and finally concatenates the feature maps to obtain the transformed feature map of the basic unit. The working process and principle of the dual-branch basic unit will be described in detail below with reference to the accompanying drawings and specific embodiments. Figure 2 This is a schematic diagram illustrating the process of extracting feature maps using dual-branch basic units in an embodiment of this application. For example... Figure 2 As shown, the feature map extraction of this dual-branch basic unit can specifically include:
[0032] The dual-branch basic unit includes a first branch and a second branch. In the first branch, to utilize more facial detail information and improve the model's generalization ability, the input face sample image size is set to 3x224x224. The face sample image first undergoes convolution processing through a first convolutional layer. The first convolutional layer uses a kernel size of 3 and a stride of 2, which can reduce the spatial size of the image. The feature map processed by the first convolutional layer is then processed by batch normalization (BatchNorm) and PReLU activation function to obtain the first output feature map.
[0033] Furthermore, the first output feature map is input into the second convolutional layer for convolution processing. The second convolutional layer uses a kernel size of 3 and a stride of 1, which can further perform feature transformation. Then, the feature map processed by the second convolutional layer is processed by batch normalization (BatchNorm) and PReLU activation function. The number of channels of the convolution output is set to 32, and finally the first feature map with an output feature map size of 32x112x112 is obtained.
[0034] In some embodiments, the extraction of the second feature map using the second branch in the dual-branch basic unit includes: recombining the height and width of the face sample image according to the even-numbered columns and the odd-numbered columns respectively; stitching the recombined images along the channel dimension; inputting the stitched images into the third convolutional layer for convolution processing; and performing batch normalization and activation function processing on the convolution-processed feature map to obtain the second feature map.
[0035] Specifically, in the second branch, the original input image (i.e., the face sample image) is first rearranged pixel by pixel, that is, the even-numbered columns and odd-numbered columns in the height and width dimensions are combined to form 4 images with a width and height downsampled by 2 times respectively. Then, the 4 images are stitched together in the channel dimension to form a single image. The resolution of this image is reduced by 2 times, but the number of channels is increased by 4 times, that is, the size of the stitched image is 12x112x112.
[0036] Furthermore, the stitched 12x112x112 image is input into the third convolutional layer for convolution processing. The third convolutional layer uses a kernel size of 3 and a stride of 1 to perform feature transformation on the image, and uses batch normalization (BatchNorm) and PReLU activation functions for processing. The number of channels in the convolution output is 32, and finally a second feature map with an output feature map size of 32x112x112 is obtained.
[0037] Furthermore, the first feature map output from the first branch is concatenated with the second feature map output from the second branch to obtain a transformed feature map. In practical applications, the first feature map and the second feature map are concatenated along the channel dimension to obtain a transformed feature map with a size of 64x112x112.
[0038] In some embodiments, the feature maps output by a preset target stage in the backbone network are processed to obtain feature vectors corresponding to each target stage, including: sequentially performing a first stage, a second stage, a third stage, and a fourth stage processing in the backbone network, wherein the second stage, the third stage, and the fourth stage are taken as target stages; and sequentially processing the feature maps output by the second stage, the third stage, and the fourth stage using a global average pooling layer, a fully connected layer, a batch normalization layer, and an activation function layer to obtain feature vectors corresponding to the second stage, the third stage, and the fourth stage, respectively.
[0039] Specifically, the backbone network of this application can adopt the IResNet50 network structure. The backbone network includes four processing stages: Stage 1, Stage 2, Stage 3, and Stage 4. The feature vectors output from multiple target stages are aggregated in the backbone network to obtain the final feature representation. The working process and principle of the backbone network will be described in detail below with reference to the accompanying drawings and specific embodiments. Figure 3 This is a schematic diagram illustrating the process of multi-stage feature aggregation using a backbone network, as described in an embodiment of this application. Figure 3 As shown, the multi-stage feature aggregation of this backbone network can specifically include:
[0040] The transformed feature map output by the dual-branch basic unit is used as the input to the backbone network, and Stages 2, 3, and 4 of the backbone network are used as target stages. The three target stages correspond to... Figure 3In C2, C3, and C4, the feature maps output from each target stage are processed using GP+FC+BN+PreLU to obtain the corresponding feature vectors. Here, GP represents the global average pooling layer, FC represents the fully connected layer (the input and output dimensions remain unchanged), BN represents the batch normalization layer (BatchNorm), and PReLU represents the activation function layer (PReLU can be used for activation). After the above processing, the dimensions of the feature vectors output from the three stages, Stage 2, Stage 3, and Stage 4, are (1, 512), (1, 256), and (1, 128), respectively.
[0041] In some embodiments, the feature vectors are aggregated to obtain the target feature vector, including: aggregating the feature vectors corresponding to the second stage, the third stage and the fourth stage respectively, inputting the aggregated feature vector into the fully connected layer, and using batch normalization to normalize the feature vector output by the fully connected layer to obtain the target feature vector.
[0042] Specifically, the feature vectors output from the three target stages are aggregated, that is, the three feature vectors are concatenated to obtain a feature vector of length 896. Then, this feature vector is input into a fully connected layer, which outputs a feature vector of dimension 512. Finally, batch normalization is used to normalize the feature vector of dimension 512 output by the fully connected layer, thereby obtaining the target feature vector and realizing the multi-stage feature aggregation operation.
[0043] Furthermore, face recognition training sets often suffer from class imbalance, meaning that the number of samples in different classes varies greatly, with some classes having hundreds of samples and others having less than ten. Class imbalance seriously affects the training of face recognition models. To address this issue, this application proposes a sample-weighted dynamic margin loss based on CosFace.
[0044] In some embodiments, the additive margin parameter is determined based on the number of samples corresponding to the face sample image of the face category and the number of samples of the largest category, including calculating the additive margin parameter using the following formula:
[0045]
[0046] Where m represents the additive margin parameter, and m0 represents the upper bound of the margin. Indicates the yth i Number of samples in each category, n max This represents the maximum number of samples in the largest category.
[0047] According to the formula above, the sample size... Fewer categories correspond to larger margins and greater losses, allowing for more thorough training; number of samples The more categories there are, the smaller the margin, and the smaller the loss, which can avoid overfitting.
[0048] In some embodiments, the included angle and additive interval parameters are input into a preset loss function to calculate the loss value, including calculating the loss value using the following loss function:
[0049]
[0050] Where, x i Let θ represent the target feature vector of the i-th face sample. j Let x represent the target feature vector of the i-th face sample. i With the class center W of the j-th category j The included angle, x represents i With the corresponding class center The angle between the two sides, m represents the additive margin parameter, s represents the feature scaling parameter, and N represents the number of all categories.
[0051] Specifically, θ j x is the feature vector of the i-th face sample. i ∈R 512x1 With the class center W of class j j ∈R 512x1 The angle between x and x. i The corresponding class tag is y i , x represents i With the corresponding class center The angle between the two sides. m is the additive margin parameter, s = 64 is the feature scaling parameter, and N is the total number of classes. Because in x i and W j There is an L2 regularization step above. m0 = 0.45 represents the upper bound of the margin, and Δm = 0.1 represents the range of margin differences. Indicates the yth i The number of samples in class n max This represents the number of samples in the largest class.
[0052] Finally, after calculating the loss value using the above loss function formula, the parameters of the face recognition deep learning model are updated in reverse using the loss value, thereby achieving the training of the face recognition deep learning model.
[0053] According to the technical solution provided in the embodiments of this application, the dual-branch basic unit of this application can extract richer basic features of face images; this application implements a feature representation strategy based on a backbone network to achieve multi-stage feature aggregation, so that the final feature representation has both high-dimensional global information and low-dimensional detailed information; this application uses a dynamic margin loss function weighted by the number of samples to solve the problem of class imbalance in the number of samples in the training set. This application improves the accuracy and face recognition effect of the face recognition model.
[0054] The following are embodiments of the apparatus described in this application, which can be used to execute the embodiments of the method described in this application. For details not disclosed in the apparatus embodiments of this application, please refer to the embodiments of the method described in this application.
[0055] Figure 4 This is a schematic diagram of the structure of the face recognition deep learning model training device provided in an embodiment of this application. Figure 4 As shown, the face recognition deep learning model training device includes:
[0056] The extraction module 401 is configured to input a face sample image into a predetermined dual-branch basic unit, extract a first feature map and a second feature map using the first branch and the second branch in the dual-branch basic unit respectively, and concatenate the first feature map and the second feature map to obtain a transformed feature map.
[0057] The aggregation module 402 is configured to input the transformed feature map into the backbone network, process the feature map output by the preset target stage in the backbone network to obtain the feature vector corresponding to each target stage, and aggregate the feature vectors to obtain the target feature vector.
[0058] The loss module 403 is configured to determine the angle between the target feature vector and the class center of each face category, and to determine the additive margin parameter based on the number of samples of the face sample image corresponding to the face category and the number of samples of the largest category. The angle and the additive margin parameter are input into the preset loss function to calculate the loss value.
[0059] Training module 404 is configured to back-update the parameters of the face recognition deep learning model using the loss value in order to train the face recognition deep learning model.
[0060] In some embodiments, Figure 4 The extraction module 401 inputs the face sample image into the first convolutional layer for convolution processing, and performs batch normalization and activation function processing on the feature map after convolution processing to obtain the first output feature map; inputs the first output feature map into the second convolutional layer for convolution processing, and performs batch normalization and activation function processing on the feature map after convolution processing to obtain the second output feature map, and uses the second output feature map as the first feature map.
[0061] In some embodiments, Figure 4 The extraction module 401 recombines the height and width of the face sample image according to the even-numbered columns and the odd-numbered columns respectively, and stitches the recombined images along the channel dimension; the stitched image is input into the third convolutional layer for convolution processing, and the feature map after convolution processing is batch normalized and activated by the activation function to obtain the second feature map.
[0062] In some embodiments, Figure 4 The aggregation module 402 sequentially performs the first, second, third and fourth stages of processing in the backbone network, with the second, third and fourth stages as the target stages. The feature maps output from the second, third and fourth stages are processed sequentially using a global average pooling layer, a fully connected layer, a batch normalization layer and an activation function layer to obtain the feature vectors corresponding to the second, third and fourth stages, respectively.
[0063] In some embodiments, Figure 4 The aggregation module 402 aggregates the feature vectors corresponding to the second, third and fourth stages respectively, and inputs the aggregated feature vectors into the fully connected layer. Batch normalization is used to normalize the feature vectors output by the fully connected layer to obtain the target feature vector.
[0064] In some embodiments, Figure 4 The loss module 403 determines the additive margin parameter based on the number of samples corresponding to the face sample image of each face category and the number of samples of the largest category, including calculating the additive margin parameter using the following formula:
[0065]
[0066] Where m represents the additive margin parameter, m0 represents the upper bound of the margin, and n yi Indicates the yth i Number of samples in each category, n max This represents the maximum number of samples in the largest category.
[0067] In some embodiments, Figure 4 The loss module 403 inputs the included angle and additive interval parameters into a preset loss function to calculate the loss value, including using the following loss functions to calculate the loss value:
[0068]
[0069] Where, x i Let θ represent the target feature vector of the i-th face sample. j Let x represent the target feature vector of the i-th face sample. i With the class center W of the j-th category j The included angle, x represents i With the corresponding class center The angle between the two sides, m represents the additive margin parameter, s represents the feature scaling parameter, and N represents the number of all categories.
[0070] It should be understood that the sequence number of each step in the above embodiments does not imply 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.
[0071] Figure 5 This is a schematic diagram of the structure of the electronic device 5 provided in an embodiment of this application. Figure 5 As shown, the electronic device 5 of this embodiment includes: a processor 501, a memory 502, and a computer program 503 stored in the memory 502 and executable on the processor 501. When the processor 501 executes the computer program 503, it implements the steps in the various method embodiments described above. Alternatively, when the processor 501 executes the computer program 503, it implements the functions of each module / unit in the various device embodiments described above.
[0072] For example, computer program 503 may be divided into one or more modules / units, which are stored in memory 502 and executed by processor 501 to complete this application. The one or more modules / units may be a series of computer program instruction segments capable of performing a specific function, which describe the execution process of computer program 503 in electronic device 5.
[0073] Electronic device 5 can be a desktop computer, laptop, handheld computer, cloud server, or other electronic device. Electronic device 5 may include, but is not limited to, processor 501 and memory 502. Those skilled in the art will understand that... Figure 5 This is merely an example of electronic device 5 and does not constitute a limitation on electronic device 5. It may include more or fewer components than shown, or combine certain components, or different components. For example, electronic device may also include input / output devices, network access devices, buses, etc.
[0074] Processor 501 can be a Central Processing Unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor can be a microprocessor or any conventional processor.
[0075] The memory 502 can be an internal storage unit of the electronic device 5, such as a hard disk or RAM. The memory 502 can also be an external storage device of the electronic device 5, such as a plug-in hard disk, Smart Media Card (SMC), Secure Digital (SD) card, or Flash Card. Furthermore, the memory 502 can include both internal and external storage units of the electronic device 5. The memory 502 is used to store computer programs and other programs and data required by the electronic device. The memory 502 can also be used to temporarily store data that has been output or will be output.
[0076] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the above-described division of functional units and modules is merely an example. In practical applications, the above functions can be assigned to 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 embodiments can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit. Furthermore, the specific names of the functional units and modules are only for easy differentiation and are not intended to limit the scope of protection of this application. The specific working process of the units and modules in the above system can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here.
[0077] In the above embodiments, the descriptions of each embodiment have different focuses. For parts that are not described in detail or recorded in a certain embodiment, please refer to the relevant descriptions of other embodiments.
[0078] Those skilled in the art will recognize that the units and algorithm steps of the various examples 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 implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art 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.
[0079] In the embodiments provided in this application, it should be understood that the disclosed apparatus / computer devices and methods can be implemented in other ways. For example, the apparatus / computer device embodiments described above are merely illustrative. For instance, the division of modules or units is only a logical functional division, and 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. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces, and the indirect coupling or communication connection between apparatuses or units may be electrical, mechanical, or other forms.
[0080] The units described as separate components may or may not be physically separate. The 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 the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0081] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0082] If an integrated module / unit is implemented as 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, all or part of the processes in the methods of the above embodiments can also be implemented by a computer program instructing related hardware. The computer program can be stored in a computer-readable storage medium, and when executed by a processor, it can implement the steps of the various method embodiments described above. The computer program may include computer program code, which can be in the form of source code, object code, executable files, or certain intermediate forms. The computer-readable medium may include: any entity or device capable of carrying computer program code, recording media, USB flash drives, portable hard drives, magnetic disks, optical disks, computer memory, read-only memory (ROM), random access memory (RAM), electrical carrier signals, telecommunication signals, and software distribution media, etc. It should be noted that the content included in the computer-readable medium may be appropriately added to or subtracted according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, the computer-readable medium does not include electrical carrier signals and telecommunication signals.
[0083] The above embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this application, and should all be included within the protection scope of this application.
Claims
1. A method for training a deep learning model for face recognition, characterized in that, include: A face sample image is input into a predetermined dual-branch basic unit. The first feature map and the second feature map are extracted using the first branch and the second branch in the dual-branch basic unit, respectively. The first feature map and the second feature map are then concatenated to obtain a transformed feature map. The transformed feature map is input into the backbone network, and the feature map output by the preset target stage in the backbone network is processed to obtain the feature vector corresponding to each target stage. The feature vectors are then aggregated to obtain the target feature vector. Determine the angle between the target feature vector and the class center of each face category, and determine the additive margin parameter based on the number of samples of the face sample image corresponding to the face category and the maximum number of samples of the largest category. Input the angle and the additive margin parameter into a preset loss function to calculate the loss value. The parameters of the face recognition deep learning model are updated in reverse using the loss value in order to train the face recognition deep learning model. The step of determining the additive margin parameter based on the number of samples corresponding to the face sample image of each face category and the number of samples of the largest category includes calculating the additive margin parameter using the following formula: in, Indicates the additive interval parameter. Indicates the upper bound of the difference. Indicates the first Number of samples in each category This represents the maximum number of samples in the largest category.
2. The method according to claim 1, characterized in that, Extracting the first feature map using the first branch in the dual-branch basic unit includes: The face sample image is input into the first convolutional layer for convolution processing, and the feature map after convolution processing is batch normalized and activated by an activation function to obtain the first output feature map. The first output feature map is input into the second convolutional layer for convolution processing. The convolutional feature map is then subjected to batch normalization and activation function processing to obtain the second output feature map, which is then used as the first feature map.
3. The method according to claim 1, characterized in that, Extracting the second feature map using the second branch in the dual-branch basic unit includes: The height and width of the face sample image are recombined according to the even-numbered columns and the odd-numbered columns respectively, and the recombined images are stitched together along the channel dimension. The stitched image is input into the third convolutional layer for convolution processing, and the convolutional feature map is batch normalized and activated to obtain the second feature map.
4. The method according to claim 1, characterized in that, The process of processing the feature maps output by the preset target stages in the backbone network to obtain the feature vectors corresponding to each target stage includes: The first, second, third, and fourth stages of processing are executed sequentially in the backbone network, wherein the second, third, and fourth stages are designated as target stages. The feature maps output from the second, third, and fourth stages are processed sequentially using a global average pooling layer, a fully connected layer, a batch normalization layer, and an activation function layer to obtain the feature vectors corresponding to the second, third, and fourth stages, respectively.
5. The method according to claim 4, characterized in that, The step of aggregating the feature vectors to obtain the target feature vector includes: The feature vectors corresponding to the second, third, and fourth stages are aggregated, and the aggregated feature vectors are input into a fully connected layer. Batch normalization is then used to normalize the feature vectors output by the fully connected layer to obtain the target feature vector.
6. The method according to claim 1, characterized in that, The step of inputting the included angle and the additive interval parameter into a preset loss function to calculate the loss value includes using the following loss function to calculate the loss value: in, Indicates the first The target feature vector of an individual face sample. Indicates the first Target feature vector of individual face samples With the Category center The included angle, express With the corresponding class center The included angle, Indicates the additive interval parameter. Indicates the feature scaling parameter. This represents the total number of categories.
7. A face recognition deep learning model training device, characterized in that, include: The extraction module is configured to input a face sample image into a predetermined dual-branch basic unit, extract a first feature map and a second feature map using the first branch and the second branch in the dual-branch basic unit respectively, and concatenate the first feature map and the second feature map to obtain a transformed feature map. The aggregation module is configured to input the transformed feature map into the backbone network, process the feature map output by the preset target stage in the backbone network to obtain the feature vector corresponding to each target stage, and aggregate the feature vectors to obtain the target feature vector. The loss module is configured to determine the angle between the target feature vector and the class center of each face category, and to determine the additive margin parameter based on the number of samples of the face sample image corresponding to the face category and the maximum number of samples of the largest category. The angle and the additive margin parameter are input into a preset loss function to calculate the loss value. The training module is configured to use the loss value to back-update the parameters of the face recognition deep learning model in order to train the face recognition deep learning model. The loss module is used to determine the additive margin parameter based on the number of samples corresponding to the face category and the maximum number of samples in the face sample image, including calculating the additive margin parameter using the following formula: in, Indicates the additive interval parameter. Indicates the upper bound of the difference. Indicates the first Number of samples in each category This represents the maximum number of samples in the largest category.
8. An electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the method as described in any one of claims 1 to 6.
9. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by a processor, it implements the method as described in any one of claims 1 to 6.