Face recognition model compression method, device, medium and computer program product
By extracting the category category of the face recognition model, it is expressed and characterized by the category of the face recognition model, optimizing the student model to obtain the face recognition compression model, solve the problem of poor face recognition model compression effect in existing technologies, and achieve more efficient and accurate model compression compression. Essence
Patent Information
- Application Number
- CN202110617959.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-06-03
- Publication Date
- 2025-01-28
- Estimated Expiration
- 2041-06-03
AI Technical Summary
In the prior art, the face recognition model has poor compression effect. When the pruning ratio is high, the model accuracy will be affected. When the pruning ratio is low, the model will still be complex and inconvenient for deployment.
By obtaining the trainer's face sample and sample category tags, the characteristic of the teacher model and the student model of the face recognition of the person's face recognition, and extracted the category center in the teacher model to generate the loss of the target model, optimize the student model to obtain the face recognition compression model Essence
It improves the compression effect of the face recognition model, improves the learning efficiency and accuracy of the lightweight model, and overcomes the problem of accuracy and complexity when the proportion of pruning is higher or lower.
Smart Images

Figure CN113361384B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of artificial intelligence technology in financial technology (Fintech), and in particular to a face recognition model compression method, device, medium and computer program product. Background Art
[0002] With the continuous development of financial technology, especially Internet technology finance, more and more technologies (such as distributed, artificial intelligence, etc.) are applied in the financial field, but the financial industry also puts forward higher requirements on technology, such as higher requirements on the distribution of corresponding to-do items in the financial industry.
[0003] With the continuous development of computer technology, the application of artificial intelligence has become more and more extensive. In recent years, face recognition technology has become more and more mature, and the requirements for recognition accuracy have become higher and higher, but at the same time, the face recognition model has also become more and more complex. As the complexity of the face recognition model increases, the hardware requirements and memory requirements for deploying the face recognition model are also increasing, which leads to higher difficulty in deploying the face recognition model. At present, the trained face recognition model is usually pruned to compress the face recognition model. When the pruning ratio is high, it will affect the accuracy of the compressed face recognition model after pruning. When the pruning ratio is low, the compressed face recognition model is still relatively complex and not convenient for model deployment. Therefore, the current model compression method has a poor effect on compressing the face recognition model. Summary of the invention
[0004] The main purpose of this application is to provide a face recognition model compression method, device, medium and computer program product, aiming to solve the technical problem of poor face recognition model compression effect in the prior art.
[0005] To achieve the above-mentioned purpose, the present application provides a face recognition model compression method, which is applied to a face recognition model compression device, and the face recognition model compression method includes:
[0006] Obtain training face samples and sample category labels corresponding to the training face samples, and based on the face recognition teacher model and the face recognition student model to be trained, respectively perform feature extraction on the training face samples to obtain a first training face feature representation and a second training face feature representation;
[0007] Extracting the central representation of each face category in the face recognition teacher model, and generating a target model loss corresponding to the face recognition student model to be trained based on the central representation of each face category, the sample category label, the first training face feature representation and the second training face feature representation;
[0008] Based on the target model loss, the face recognition student model to be trained is optimized to obtain a face recognition compression model corresponding to the face recognition teacher model.
[0009] To achieve the above-mentioned purpose, the present application provides a face recognition method, which is applied to a face recognition device, and the face recognition method includes:
[0010] Obtain a face image to be recognized, and extract features of the face image to be recognized based on a face recognition compression model optimized by the central representation of each face category of the face recognition teacher model, to obtain a feature representation of the target face;
[0011] By calculating the similarity between the target facial feature representation and the facial feature representations corresponding to each pre-recorded face, a facial recognition result corresponding to the face image to be recognized is generated.
[0012] The present application also provides a face recognition model compression device, which is a virtual device and is applied to a face recognition model compression device. The face recognition model compression device includes:
[0013] A feature extraction module is used to obtain training face samples and sample category labels corresponding to the training face samples, and based on the face recognition teacher model and the face recognition student model to be trained, respectively extract features from the training face samples to obtain a first training face feature representation and a second training face feature representation;
[0014] A loss calculation module, used to extract the central representation of each face category in the face recognition teacher model, and generate a target model loss corresponding to the face recognition student model to be trained based on the central representation of each face category, the sample category label, the first training face feature representation and the second training face feature representation;
[0015] The model optimization module is used to optimize the face recognition student model to be trained based on the target model loss, and obtain the face recognition compression model corresponding to the face recognition teacher model.
[0016] The present application also provides a face recognition device, wherein the face recognition model is a virtual device, and the face recognition device is applied to a face recognition device, and the face recognition device comprises:
[0017] A feature extraction module is used to obtain a face image to be identified, and based on a face recognition compression model optimized by the central representation of each face category of the face recognition teacher model, extract features from the face image to be identified to obtain a feature representation of the target face;
[0018] The generation module is used to generate a face recognition result corresponding to the face image to be recognized by calculating the similarity between the target face feature representation and the face feature representation corresponding to each pre-recorded face.
[0019] The present application also provides a face recognition model compression device, which is a physical device. The face recognition model compression device includes: a memory, a processor, and a program of the face recognition model compression method stored in the memory and executable on the processor. When the program of the face recognition model compression method is executed by the processor, the steps of the face recognition model compression method as described above can be implemented.
[0020] The present application also provides a face recognition device, which is a physical device. The face recognition device includes: a memory, a processor, and a program of the face recognition method stored in the memory and executable on the processor. When the program of the face recognition method is executed by the processor, the steps of the face recognition method as described above can be implemented.
[0021] The present application also provides a medium, which is a readable storage medium, on which is stored a program for implementing a face recognition model compression method, and when the program of the face recognition model compression method is executed by a processor, the steps of the face recognition model compression method as described above are implemented.
[0022] The present application also provides a medium, which is a readable storage medium. The readable storage medium stores a program for implementing a face recognition method. When the program of the face recognition method is executed by a processor, the steps of the face recognition method as described above are implemented.
[0023] The present application also provides a computer program product, including a computer program, which implements the steps of the above-mentioned face recognition model compression method when executed by a processor.
[0024] The present application also provides a computer program product, including a computer program, which implements the steps of the above-mentioned face recognition method when executed by a processor.
[0025] The present application provides a face recognition model compression method, device, medium and computer program product. Compared with the technical means adopted in the prior art to compress the face recognition model by pruning the trained face recognition model, the present application first obtains the training face samples and the sample category labels corresponding to the training face samples, and based on the face recognition teacher model and the face recognition student model to be trained, respectively extracts features of the training face samples to obtain the first training face feature representation and the second training face feature representation, and then extracts the center representation of each face category in the face recognition teacher model, and generates the target model loss based on the center representation of each face category, the sample category label, the first training face feature representation and the second training face feature representation, thereby achieving the purpose of directly sharing the category center representation of the face recognition teacher model with the face recognition student model to be trained. However, since the face recognition teacher model is a complex type The model is then based on the loss generated by the category center representation of the face recognition teacher model, and the face recognition student model to be trained is directly optimized, so that the face recognition student model to be trained directly learns the feature distribution of the face recognition teacher model based on the category center representation of the face recognition teacher model. Under the premise that the face recognition learning model to be trained is a lightweight model, the learning efficiency and accuracy of the knowledge of the face recognition teacher model learned by the face recognition student model to be trained are improved, and then the face recognition compression model corresponding to the face recognition teacher model is obtained, and the accuracy of the face recognition compression model as a lightweight model is improved. Therefore, when the pruning ratio is high, the accuracy of the compressed face recognition model after pruning is affected, and when the pruning ratio is low, the compressed face recognition model is still relatively complex, which is not convenient for model deployment, resulting in poor compression effect of the face recognition model. The technical defect is improved, and the compression effect of the face recognition model is improved. BRIEF DESCRIPTION OF THE DRAWINGS
[0026] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0027] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0028] Figure 1 This is a flow chart of an embodiment of the face recognition model compression method of the present application;
[0029] Figure 2A schematic diagram of the process of iteratively training a face recognition student model to be trained in the face recognition model compression method of the present application;
[0030] Figure 3 This is a flow chart of an embodiment of the face recognition method of the present application;
[0031] Figure 4 A schematic diagram of the device structure of the hardware operating environment involved in the face recognition model compression method in the embodiment of the present application;
[0032] Figure 5 Schematic diagram of the device structure of the hardware operating environment involved in the face recognition method in the embodiment of the present application.
[0033] The purpose, features and advantages of this application will be further described in conjunction with the embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION
[0034] It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0035] The present application embodiment provides a face recognition model compression method. In the first embodiment of the face recognition model compression method of the present application, refer to Figure 1 The face recognition model compression method is applied to a face recognition model compression device, and the face recognition model compression method includes:
[0036] Step S10, obtaining training face samples and sample category labels corresponding to the training face samples, and performing feature extraction on the training face samples based on the face recognition teacher model and the face recognition student model to be trained, respectively, to obtain a first training face feature representation and a second training face feature representation;
[0037] In this embodiment, it should be noted that the training face sample is sample data representing a face image, such as a pixel matrix representing a face image, etc. The sample category label is an identifier of the sample category to which the training face sample belongs. The face recognition teacher model is a trained face recognition model with a complex network structure, wherein the face recognition model with a complex network structure has a high model accuracy and a high demand for hardware resources. The complex network structure includes network structures such as Resnet101, Inception-v4 and densenet. The face recognition student model to be trained is an untrained face recognition model with a lightweight network structure, wherein the lightweight network structure The face recognition model with a lightweight network structure has a lower demand for hardware resources, and the accuracy of the face recognition model with a lightweight network structure is lower than that of the face recognition model with a complex network structure. The lightweight network structure includes network structures such as mobilefacenet, vargfacenet and shufflenet. The first training face feature representation is a vector of a preset dimension generated by the face recognition teacher model and representing the face features of the training face samples. The second training face feature representation is a vector of a preset dimension generated by the face recognition student model to be trained and representing the face features of the training face samples. The preset dimension can be set to 512 dimensions, 1024 dimensions, etc.
[0038] Acquire training face samples and sample category labels corresponding to the training face samples, and based on a face recognition teacher model and a face recognition student model to be trained, respectively perform feature extraction on the training face samples to obtain a first training face feature representation and a second training face feature representation. Specifically, acquire training face samples and sample category labels corresponding to the training face samples, wherein the training face samples are face image pixel matrices representing face images, and then based on the face recognition teacher model, perform feature extraction on the face image pixel matrix to map the face image pixel matrix to a vector of a preset dimension to obtain a first training face feature representation, and based on the face recognition student model to be trained, perform feature extraction on the face image pixel matrix to map the face image pixel matrix to a vector of a preset dimension to obtain a second training face feature representation.
[0039] Step S20, extracting the central representation of each face category in the face recognition teacher model, and generating a target model loss corresponding to the face recognition student model to be trained based on the central representation of each face category, the sample category label, the first training face feature representation and the second training face feature representation;
[0040] In this embodiment, it should be noted that the face category center is represented as the model parameter of the classification layer in the face recognition teacher model, which is used to represent the face category center. For example, assuming that the model parameter of the classification layer in the face recognition teacher model is a matrix (A, B, C), then vector A is the face category center representation of face category a, vector B is the face category center representation of face category b, and vector C is the face category center representation of face category c.
[0041] The central representation of each face category is extracted from the face recognition teacher model, and the target model loss corresponding to the face recognition student model to be trained is generated according to the central representation of each face category, the sample category label, the first training face feature representation and the second training face feature representation. Specifically, the model parameters of the classification layer in the face recognition teacher model are extracted as the central representation of each face category, and then according to the central representation of each face category, the sample category label, the first training face feature representation and the second training face feature representation, the face recognition loss, the category distribution similarity loss and the feature representation similarity loss are generated, wherein the face recognition loss is a model loss used to guide the face recognition student model to be trained to improve the model recognition ability, so that the inter-class similarity of the feature representation output by the face recognition learning model to be trained is less than the first preset similarity threshold, and the intra-class similarity Greater than a second preset similarity threshold, wherein the inter-class similarity is the similarity between feature representations that do not belong to the same face category, the intra-class similarity is the similarity between feature representations that belong to the same face category, the first preset similarity threshold is not greater than the second preset similarity threshold, the category distribution similarity loss is a model loss used to guide the face recognition student model to be trained to learn the feature representation output by the face recognition teacher model and the similarity distribution of the center representation of each face category, wherein the category distribution similarity loss includes KL divergence loss, etc., and the feature representation similarity loss is a model loss used to guide the face recognition student model to be trained to learn the feature representation output by the face recognition teacher model, so that for the same face image, the similarity between the feature representation output by the face recognition student model to be trained and the feature representation output by the face recognition teacher model is greater than the third preset similarity threshold.
[0042] The step of generating the target model loss corresponding to the face recognition student model to be trained according to the center representation of each face category, the sample category label, the first training face feature representation and the second training face feature representation comprises:
[0043] Step S21, generating the face recognition loss based on the first similarity between the second training face feature representation and each of the face category center representations and the sample category label;
[0044] In this embodiment, the face recognition loss is generated based on the first similarity between the second training face feature representation and the central representation of each face category and the sample category label. Specifically, the cosine similarity between the second training face feature representation and the central representation of each face category is calculated to obtain each first similarity, and then the similarity corresponding to the sample category label is selected from each first similarity as the intra-class similarity, and the first similarity that is not the intra-class similarity is used as the inter-class similarity, and then the face recognition loss is calculated based on each inter-class similarity and the intra-class similarity.
[0045] The first similarity includes intra-class similarity and inter-class similarity.
[0046] The step of based on the first similarity between the second training face feature representation and each face category center representation and the sample category label comprises:
[0047] Step S211, based on the sample category label, determining the corresponding category center representation of the second training facial feature representation and the corresponding non-category center representations in each of the face category center representations;
[0048] In this embodiment, it should be noted that the sample category label is an identifier of the sample category to which the training face sample belongs, wherein one sample category corresponds to a face category center representation.
[0049] Based on the sample category label, the belonging category center representation corresponding to the second training facial feature representation and the corresponding non-belonging category center representations are determined in each of the face category center representations. Specifically, based on the correspondence between the sample category and the face category center representation, the face category center representation corresponding to the sample category label is used as the belonging category center representation, and the other face category center representations that do not correspond to the sample category label are used as non-belonging category center representations.
[0050] Step S212, calculating the similarity between the second training face feature representation and the center representation of the category to which it belongs, to obtain the intra-category similarity;
[0051] In this embodiment, the similarity between the second training facial feature representation and the central representation of the category to which it belongs is calculated to obtain the intra-class similarity. Specifically, the intra-class similarity is generated by calculating the cosine value between the second training facial feature representation and the central representation of the category to which it belongs. It should be noted that, preferably, before calculating the cosine value between the second training facial feature representation and the central representation of the category to which it belongs, it is necessary to normalize the second training facial feature representation and the central representation of the category to which it belongs.
[0052] Step S213, respectively calculating the similarity between the second training face feature representation and each non-class center representation to obtain each inter-class similarity;
[0053] In this embodiment, the similarities between the second training facial feature representation and the central representation of each non-belonging category are calculated respectively to obtain the inter-class similarities. Specifically, the inter-class similarities are generated by calculating the cosine values between the second training facial feature representation and the central representation of each non-belonging category respectively. It should be noted that, preferably, before calculating the similarities between the second training facial feature representation and the central representation of each non-belonging category respectively, the second training facial feature representation and the central representation of each non-belonging category need to be normalized.
[0054] Step S214: generating the face recognition loss based on the intra-class similarity and the inter-class similarities.
[0055] In this embodiment, based on the intra-class similarity and the inter-class similarities, the calculation formula for calculating the face recognition loss is as follows:
[0056]
[0057] Among them, L reg is the face recognition loss, N is the number of training face samples in one round of iteration when iteratively training the face recognition student model to be trained, s represents the scale, and s=64 can be selected, m1, m2 and m3 represent the margin in three dimensions, and m1=1, m2=0.5, m3=0 can be selected, cos(m1θ yi +m2) is the similarity within the class, cos(θ j ) is the inter-class similarity, θ yi is the angle between the second training face feature representation and the face category center representation corresponding to the sample category to which it belongs, θ j It is the angle between the second training face feature representation and the face category center representation corresponding to the non-belonging sample category, wherein the belonging sample category is the sample category to which the training face sample belongs, and the non-belonging sample category is the sample category to which the training face sample does not belong.
[0058] Step S22, generating the category distribution similarity loss based on each of the first similarities and a second similarity between the first training facial feature representation and each of the face category centers;
[0059] In this embodiment, the category distribution similarity loss is generated based on each of the first similarities and the second similarities between the first training face feature representation and each of the face category centers. Specifically, the cosine values between the first training feature representation and each of the face category centers are calculated to obtain each second similarity, and then based on each of the first similarities and each of the second similarities, the KL divergence loss is calculated, and the KL divergence loss is used as the category distribution similarity loss, wherein the calculation formula for calculating the KL divergence loss is as follows:
[0060]
[0061] Among them, L kl is the KL divergence loss, N is the number of training face samples in one round of iteration when iteratively training the face recognition student model to be trained, C is the number of center representations of the face category, t ij is the second similarity, s ij is the first similarity, and T is a temperature variable, which is used to map the first similarity and the second similarity into a preset value range.
[0062] Step S23, generating the feature representation similarity loss based on the first training face feature representation and the second training face feature representation;
[0063] In this embodiment, based on the first training face feature representation and the second training face feature representation, the feature representation similarity loss is generated. Specifically, the first training face feature representation and the second training face feature representation are input into a preset feature representation similarity loss calculation formula to calculate the feature representation similarity loss, wherein the preset feature representation similarity loss calculation formula is as follows:
[0064]
[0065] Among them, L cos is the similarity loss of the feature representation, N is the number of training face samples in one round of iteration when iteratively training the face recognition student model to be trained, feat_t is the first training face feature representation, and feat_s is the second training face feature representation.
[0066] Step S24, generating the target model loss based on the face recognition loss, the category distribution similarity loss and the feature representation similarity loss.
[0067] In this embodiment, the target model loss is generated based on the face recognition loss, the class distribution similarity loss and the feature representation similarity loss. Specifically, the face recognition loss, the class distribution similarity loss and the feature representation similarity loss are weighted and summed to obtain the target model loss, wherein the calculation formula for weighted sum of the face recognition loss, the class distribution similarity loss and the feature representation similarity loss is as follows:
[0068] Loss = αL reg +βL kl +γL cos
[0069] Among them, Loss is the target model loss, L reg is the face recognition loss, L kl is the category distribution similarity loss, L cos represents the similarity loss of the feature, and α, β and γ are all weighted weights.
[0070] Wherein, the step of generating the target model loss corresponding to the face recognition student model to be trained according to the center representation of each face category, the sample category label, the first training face feature representation and the second training face feature representation also includes:
[0071] Step A10, generating the face recognition loss based on the first similarity between the second training face feature representation and each of the face category center representations and the sample category label;
[0072] In this embodiment, the face recognition loss is generated based on the first similarity between the second training face feature representation and the central representation of each face category and the sample category label. Specifically, the cosine similarity between the second training face feature representation and the central representation of each face category is calculated to obtain each first similarity, and then the similarity corresponding to the sample category label is selected from each of the first similarities as the intra-class similarity, and the first similarity that is not the intra-class similarity is used as the inter-class similarity, and then based on each of the inter-class similarities and the intra-class similarity, the face recognition loss is calculated. Specifically, the calculation of the face recognition loss can refer to the contents of steps S211 to S214, which will not be repeated here.
[0073] Step A20, generating the category distribution similarity loss based on each of the first similarities and the second similarities between the first training facial feature representation and each of the face category centers;
[0074] In this embodiment, the category distribution similarity loss is generated based on each of the first similarities and the second similarities between the first training facial feature representation and each of the face category centers. Specifically, the cosine values between the first training feature representation and each of the face category centers are calculated respectively to obtain each second similarity, and then based on each of the first similarities and each of the second similarities, the KL divergence loss is calculated, and the KL divergence loss is used as the category distribution similarity loss. The method for calculating the KL divergence loss can be specifically parameterized in step S22, which will not be repeated here.
[0075] Step A30, generating the target model loss based on the face recognition loss and the category distribution similarity loss.
[0076] In this embodiment, the target model loss is generated based on the face recognition loss and the category distribution similarity loss. Specifically, the face recognition loss and the category distribution similarity loss are weighted and summed to obtain the target model loss. Then, based on the target model loss, the face recognition student model to be trained is optimized, so as to achieve the purpose of combining the face category center representation with the face recognition teacher model and performing combined distillation on the face recognition teacher model based on the face recognition loss and the category distribution similarity loss. Compared with the model compression method of direct model distillation, the face recognition student model to be trained can learn more knowledge of the face recognition teacher model more efficiently, and then the face recognition compression model obtained after the iterative training is completed will have higher face recognition accuracy, thereby improving the effect of the compressed face recognition model.
[0077] Step S30, based on the target model loss, optimizing the face recognition student model to be trained to obtain a face recognition compression model corresponding to the face recognition teacher model.
[0078] In this embodiment, based on the target model loss, the face recognition student model to be trained is optimized to obtain a face recognition compression model corresponding to the face recognition teacher model. Specifically, based on the model gradient corresponding to the target model loss, the face recognition student model to be trained is optimized, and it is determined whether the optimized face recognition student model to be trained meets the preset iterative training end condition. If so, the face recognition student model to be trained is used as the face recognition compression model corresponding to the face recognition teacher model. If not, the step of obtaining training face samples and sample category labels corresponding to the training face samples is returned, wherein the preset iterative training end condition includes an iteration maximum iteration number threshold and model loss convergence, etc.
[0079] Among them, it should be noted that, due to the extremely high number of classification categories involved in the face recognition model, if the face recognition student model to be trained is optimized only based on the category distribution similarity loss, it is difficult for the face recognition learning model to be trained to comprehensively learn the knowledge of the face recognition teacher model, which will cause the face recognition learning model to be trained to be difficult to converge during the iterative training process. The embodiment of the present application optimizes the face recognition student model to be trained by combining the face recognition loss, the category distribution similarity loss and the feature representation similarity loss to generate the target model loss, so that the face recognition learning model to be trained can converge faster during the iterative training process and can comprehensively learn the knowledge of the face recognition teacher model, thereby achieving the purpose of combined distillation of the face recognition teacher model based on the face recognition loss, the category distribution similarity loss and the feature representation similarity loss. Compared with the method of directly performing model distillation, the face recognition student model to be trained can learn more knowledge of the face recognition teacher model more efficiently, and then the face recognition accuracy of the face recognition compression model obtained after the iterative training is completed will be higher, so the effect of the compressed face recognition model is improved, such as Figure 2 As shown is a flow chart of iterative training of the student model for face recognition to be trained in an embodiment of the present application, wherein I is the training face sample, Label is the sample category label, the teacher model is the face recognition teacher model, feat_t is the first training face feature representation, feat_s is the second training face feature representation, the student model is the student model for face recognition to be trained, the category center class weights are the category center representations of each face, Lreg is the face recognition loss, Lkl is the KL divergence loss, Lcos is the feature representation similarity loss, the total loss function is the target model loss, and the model parameters are the model parameters of the student model for face recognition to be trained.
[0080] The step of optimizing the face recognition student model to be trained based on the target model loss to obtain the face recognition compression model corresponding to the face recognition teacher model includes:
[0081] Step S31, based on the model gradient corresponding to the target model loss, updating the model parameters of the face recognition student model to be trained, and judging whether the updated face recognition student model to be trained meets the preset iterative training end condition;
[0082] In this embodiment, based on the model gradient corresponding to the target model loss, the model parameters of the face recognition student model to be trained are updated, and it is judged whether the updated face recognition student model to be trained meets the preset iterative training end condition. Specifically, based on the target model loss, the model gradient corresponding to the face recognition student model to be trained is calculated, and then based on the model gradient, the model parameters of the face recognition student model to be trained are updated by a preset model parameter updating method, and it is judged whether the face recognition student model to be trained after the updated model parameters meets the preset iterative training end condition, wherein the preset model parameter updating method includes gradient descent method and gradient ascent method, etc.
[0083] Step S32: if satisfied, the face recognition student model to be trained is used as the face recognition compression model;
[0084] Step S33: If not satisfied, return to the step of obtaining training face samples and sample category labels corresponding to the training face samples.
[0085] In this embodiment, if the conditions are met, the face recognition student model to be trained is used as the face recognition compression model; if not met, the step of obtaining training face samples and sample category labels corresponding to the training face samples is returned to continue iterative training of the face recognition student model to be trained until the face recognition student model to be trained meets the preset iterative training end conditions.
[0086] Wherein, after the step of optimizing the face recognition student model to be trained based on the target model loss to obtain the target compression model corresponding to the face recognition teacher model, the face recognition model compression method further includes:
[0087] Step S40, obtaining a face image to be identified, and based on the face recognition compression model, performing feature extraction on the face image to be identified to obtain a feature representation of the target face;
[0088] In this embodiment, a face image to be identified is obtained, and based on the face recognition compression model, feature extraction is performed on the face image to be identified to obtain a feature representation of a target face. Specifically, a face image to be identified is obtained, and the face image to be identified is input into the face recognition compression model, and feature extraction is performed on the face image to be identified, so that the face image to be identified is mapped into a vector of a preset dimension to obtain a feature representation of a target face.
[0089] Step S50, generating a face recognition result corresponding to the face image to be recognized by calculating the similarity between the target face feature representation and the feature representations corresponding to each pre-recorded face image.
[0090] In this embodiment, it should be noted that the pre-recorded face is a pre-recorded face used for comparison with the input face to be recognized to realize face recognition.
[0091] By calculating the similarity between the feature representation of the target face and the feature representation corresponding to each pre-recorded face image, a face recognition result corresponding to the face image to be recognized is generated. Specifically, the cosine similarity between the feature representation of the target face and the feature representation corresponding to each pre-recorded face is calculated, and then the face identity label of the pre-recorded face image with the highest cosine similarity is selected as the face recognition result corresponding to the face image to be recognized, wherein the face identity label is an identifier representing the identity of the face, such as an ID number and a mobile phone number, etc., wherein, since the face recognition compression model is generated by combining the face category center representation of the face recognition teacher model, the face recognition teacher model is generated by combined distillation based on the face recognition loss, the category distribution similarity loss and the feature representation similarity loss, so that the face recognition student model to be trained can learn more knowledge of the face recognition teacher model more efficiently, thereby improving the accuracy of face recognition.
[0092] The embodiment of the present application provides a face recognition model compression method. Compared with the technical means adopted in the prior art to compress the face recognition model by pruning the trained face recognition model, the embodiment of the present application first obtains the training face samples and the sample category labels corresponding to the training face samples, and based on the face recognition teacher model and the face recognition student model to be trained, respectively extracts features of the training face samples to obtain the first training face feature representation and the second training face feature representation, and then extracts the center representation of each face category in the face recognition teacher model, and generates the target model loss based on the center representation of each face category, the sample category label, the first training face feature representation and the second training face feature representation, thereby achieving the purpose of directly sharing the category center representation of the face recognition teacher model with the face recognition student model to be trained. However, since the face recognition teacher model is a complex model, the face recognition teacher model is difficult to be trained. Based on the loss generated by the category center representation of the face recognition teacher model, the face recognition student model to be trained is directly optimized, so that the face recognition student model to be trained learns the feature distribution of the face recognition teacher model directly on the basis of the category center representation of the face recognition teacher model. Under the premise that the face recognition learning model to be trained is a lightweight model, the learning efficiency and accuracy of the face recognition student model to be trained in learning the knowledge of the face recognition teacher model are improved, and then the face recognition compression model corresponding to the face recognition teacher model is obtained, and the accuracy of the face recognition compression model as a lightweight model is improved. Therefore, the technical defect that when the pruning ratio is high, the accuracy of the compressed face recognition model after pruning is affected, and when the pruning ratio is low, the compressed face recognition model is still relatively complex and inconvenient for model deployment, resulting in poor compression effect of the face recognition model is overcome, thereby improving the compression effect of the face recognition model.
[0093] Further, refer to Figure 3 In another embodiment of the present application, the face recognition method is applied to a face recognition device, and the face recognition method includes:
[0094] Step B10, obtaining a face image to be recognized, and extracting features from the face image to be recognized based on a face recognition compression model optimized by the central representation of each face category of the face recognition teacher model, to obtain a feature representation of the target face;
[0095] In this embodiment, it should be noted that the face recognition compression model is generated based on directly sharing the category center representation of the face recognition teacher model with the face recognition student model to be trained. Since the face recognition teacher model is a complex model, the face recognition compression model is used to directly learn the knowledge of the face recognition teacher model based on the category center representation of the face recognition teacher model. Under the premise that the face recognition learning model to be trained is a lightweight model, the learning efficiency and accuracy of the face recognition student model to be trained in learning the knowledge of the face recognition teacher model are improved.
[0096] A face image to be recognized is obtained, and a face recognition compression model based on which the central representations of each face category of a face recognition teacher model are optimized is used to perform feature extraction on the face image to be recognized, so as to obtain a feature representation of the target face. Specifically, a face image to be recognized is obtained, and a face recognition compression model based on which the central representations of each category of a face recognition teacher model are optimized is used to perform feature extraction on the face image to be recognized, so as to map the face image to be recognized into a vector of a preset dimension, so as to obtain a face feature representation.
[0097] Wherein, before the step of extracting features from the face image to be recognized and obtaining a face feature representation by using the face recognition compression model optimized by the category center representation based on the face recognition teacher model, the face recognition method further comprises:
[0098] Step C10, obtaining training face samples and sample category labels corresponding to the training face samples, and performing feature extraction on the training face samples based on the face recognition teacher model and the face recognition student model to be trained, respectively, to obtain a first training face feature representation and a second training face feature representation;
[0099] In this embodiment, training face samples and sample category labels corresponding to the training face samples are obtained, and based on the face recognition teacher model and the face recognition student model to be trained, feature extraction is performed on the training face samples respectively to obtain a first training face feature representation and a second training face feature representation. Specifically, the training face samples and sample category labels corresponding to the training face samples are obtained, wherein the training face samples are face image pixel matrices representing face images, and then based on the face recognition teacher model, feature extraction is performed on the face image pixel matrix to map the face image pixel matrix to a vector of a preset dimension to obtain a first training face feature representation, and based on the face recognition student model to be trained, feature extraction is performed on the face image pixel matrix to map the face image pixel matrix to a vector of a preset dimension to obtain a second training face feature representation, wherein the specific explanation of step C10 can refer to the content in step S10, which will not be repeated here.
[0100] Step C20, generating a target model loss corresponding to the face recognition student model to be trained according to the face category center representation, the sample category label, the first training face feature representation and the second training face feature representation;
[0101] In this embodiment, based on the central representation of each face category, the sample category label, the first training face feature representation and the second training face feature representation, the target model loss corresponding to the face recognition student model to be trained is generated. Specifically, based on the central representation of each face category, the sample category label, the first training face feature representation and the second training face feature representation, the face recognition loss, the category distribution similarity loss and the feature representation similarity loss are generated, and then the face recognition loss, the category distribution similarity loss and the feature representation similarity loss are weightedly summed to obtain the target model loss. The specific content of generating the target model loss can refer to the content in step S20, steps S21 to S24 and steps A10 to A30, which will not be repeated here.
[0102] The step of generating the target model loss corresponding to the face recognition student model to be trained according to the center representation of each face category, the sample category label, the first training face feature representation and the second training face feature representation comprises:
[0103] Step C21, generating the face recognition loss based on the first similarity between the second training face feature representation and each face category center representation and the sample category label;
[0104] In this embodiment, the face recognition loss is generated based on the first similarity between the second training face feature representation and the central representation of each face category and the sample category label. Specifically, the cosine similarity between the second training face feature representation and the central representation of each face category is calculated to obtain each first similarity, and then the similarity corresponding to the sample category label is selected from each first similarity as the intra-class similarity, and the first similarity that is not the intra-class similarity is used as the inter-class similarity, and then based on each of the inter-class similarities and the intra-class similarity, the face recognition loss is calculated. The specific content of calculating the face recognition loss can refer to the content in step S21 and steps S211 to S214, which will not be repeated here.
[0105] Step C22, generating the category distribution similarity loss based on each of the first similarities and a second similarity between the first training facial feature representation and each of the face category centers;
[0106] In this embodiment, the category distribution similarity loss is generated based on each of the first similarities and the second similarities between the first training facial feature representation and each of the face category centers. Specifically, the cosine values between the first training feature representation and each of the face category centers are calculated respectively to obtain each second similarity, and then based on each of the first similarities and each of the second similarities, the KL divergence loss is calculated, and the KL divergence loss is used as the category distribution similarity loss. The specific content of calculating the KL divergence loss can be referred to the content in step S22, which will not be repeated here.
[0107] Step C23, generating the feature representation similarity loss based on the first training face feature representation and the second training face feature representation;
[0108] In this embodiment, the first training face feature representation and the second training face feature representation are input into a preset feature representation similarity loss calculation formula to calculate the feature representation similarity loss. The specific content of calculating the feature representation similarity loss can refer to the content in step S23 and will not be repeated here.
[0109] Step C24, generating the target model loss based on the face recognition loss, the category distribution similarity loss and the feature representation similarity loss.
[0110] In this embodiment, the target model loss is generated based on the face recognition loss, the category distribution similarity loss and the feature representation similarity loss. Specifically, the face recognition loss, the category distribution similarity loss and the feature representation similarity loss are weightedly summed to obtain the target model loss.
[0111] Step C30, based on the target model loss, optimizing the face recognition student model to be trained to obtain the face recognition compression model corresponding to the face recognition teacher model.
[0112] In this embodiment, based on the target model loss, the face recognition student model to be trained is optimized to obtain a face recognition compression model corresponding to the face recognition teacher model. Specifically, based on the model gradient corresponding to the target model loss, the face recognition student model to be trained is optimized, and it is determined whether the optimized face recognition student model to be trained meets the preset iterative training end condition. If so, the face recognition student model to be trained is used as the face recognition compression model corresponding to the face recognition teacher model. If not, the step of obtaining training face samples and sample category labels corresponding to the training face samples is returned, wherein the preset iterative training end condition includes an iteration maximum iteration number threshold and model loss convergence, etc.
[0113] Step B20, generating a face recognition result corresponding to the face image to be recognized by calculating the similarity between the target face feature representation and the face feature representations corresponding to each pre-recorded face.
[0114] In this embodiment, the face recognition result corresponding to the face image to be recognized is generated by calculating the similarity between the target face feature representation and the face feature representation corresponding to each pre-recorded face. Specifically, the cosine similarity between the target face feature representation and the feature representation corresponding to each pre-recorded face is calculated, and then the face identity label of the pre-recorded face image with the highest cosine similarity is selected as the face recognition result corresponding to the face image to be recognized, wherein the face identity label is an identifier representing the identity of the face, such as an ID number and a mobile phone number, etc., wherein, since the face recognition compression model is generated by combining the face category center representation of the face recognition teacher model, the face recognition teacher model is generated by combined distillation based on the face recognition loss, the category distribution similarity loss and the feature representation similarity loss, so that the face recognition student model to be trained can learn more knowledge of the face recognition teacher model more efficiently, thereby improving the accuracy of face recognition.
[0115] An embodiment of the present application provides a face recognition method, that is, first obtaining a face image to be recognized, and then extracting features of the face image to be recognized based on a face recognition compression model optimized by the central representations of each face category of a face recognition teacher model, obtaining a target face feature representation, and then generating a face recognition result corresponding to the face image to be recognized by calculating the similarity between the target face feature representation and the face feature representations corresponding to each pre-recorded face, wherein, since the face recognition compression model is a model of a lightweight network structure generated by combining the central representation of the face category of the face recognition teacher model and performing combined distillation on the face recognition teacher model based on face recognition loss, the category distribution similarity loss and the feature representation similarity loss, the face recognition student model to be trained can learn more knowledge of the face recognition teacher model with a complex network structure more efficiently, thereby improving the accuracy of the face recognition compression model with a lightweight network structure, and thereby improving the accuracy of face recognition.
[0116] Reference Figure 4 , Figure 4 It is a schematic diagram of the device structure of the hardware operating environment involved in the embodiment of the present application.
[0117] like Figure 4As shown, the face recognition model compression device may include: a processor 1001, such as a CPU, a memory 1005, and a communication bus 1002. The communication bus 1002 is used to realize the connection and communication between the processor 1001 and the memory 1005. The memory 1005 may be a high-speed RAM memory or a stable memory (non-volatile memory), such as a disk memory. The memory 1005 may optionally be a storage device independent of the aforementioned processor 1001.
[0118] Optionally, the face recognition model compression device may also include a rectangular user interface, a network interface, a camera, an RF (Radio Frequency) circuit, a sensor, an audio circuit, a WiFi module, etc. The rectangular user interface may include a display screen (Display), an input submodule such as a keyboard (Keyboard), and the optional rectangular user interface may also include a standard wired interface and a wireless interface. The network interface may optionally include a standard wired interface and a wireless interface (such as a WI-FI interface).
[0119] Those skilled in the art will understand that Figure 4 The face recognition model compression device structure shown in the figure does not constitute a limitation of the face recognition model compression device, and may include more or fewer components than shown in the figure, or a combination of certain components, or a different arrangement of components.
[0120] like Figure 4 As shown, the memory 1005 as a computer storage medium may include an operating system, a network communication module, and a face recognition model compression program. The operating system is a program that manages and controls the hardware and software resources of the face recognition model compression device, and supports the operation of the face recognition model compression program and other software and / or programs. The network communication module is used to realize the communication between the components inside the memory 1005, and the communication with other hardware and software in the face recognition model compression system.
[0121] exist Figure 4 In the face recognition model compression device shown, the processor 1001 is used to execute the face recognition model compression program stored in the memory 1005 to implement the steps of the face recognition model compression method described in any one of the above items.
[0122] The specific implementation of the face recognition model compression device of the present application is basically the same as the embodiments of the above-mentioned face recognition model compression method, and will not be repeated here.
[0123] Reference Figure 5 , Figure 5 It is a schematic diagram of the device structure of the hardware operating environment involved in the embodiment of the present application.
[0124] like Figure 5 As shown, the face recognition device may include: a processor 1001, such as a CPU, a memory 1005, and a communication bus 1002. The communication bus 1002 is used to realize the connection and communication between the processor 1001 and the memory 1005. The memory 1005 may be a high-speed RAM memory or a stable memory (non-volatile memory), such as a disk memory. The memory 1005 may also be a storage device independent of the aforementioned processor 1001.
[0125] Optionally, the face recognition device may also include a rectangular user interface, a network interface, a camera, an RF (Radio Frequency) circuit, a sensor, an audio circuit, a WiFi module, etc. The rectangular user interface may include a display screen (Display), an input submodule such as a keyboard (Keyboard), and the optional rectangular user interface may also include a standard wired interface and a wireless interface. The network interface may optionally include a standard wired interface and a wireless interface (such as a WI-FI interface).
[0126] Those skilled in the art will understand that Figure 5 The face recognition device structure shown in the figure does not constitute a limitation on the face recognition device, and may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently.
[0127] like Figure 5 As shown, the memory 1005 as a computer storage medium may include an operating system, a network communication module and a face recognition program. The operating system is a program that manages and controls the hardware and software resources of the face recognition device, and supports the operation of the face recognition program and other software and / or programs. The network communication module is used to realize the communication between the components inside the memory 1005, and the communication with other hardware and software in the face recognition system.
[0128] exist Figure 5 In the face recognition device shown, the processor 1001 is used to execute the face recognition program stored in the memory 1005 to implement the steps of any of the above-mentioned face recognition methods.
[0129] The specific implementation of the face recognition device of the present application is basically the same as the embodiments of the above-mentioned face recognition method, and will not be repeated here.
[0130] The embodiment of the present application also provides a face recognition model compression device, which is applied to a face recognition model compression device, and the face recognition model compression device includes:
[0131] A feature extraction module is used to obtain training face samples and sample category labels corresponding to the training face samples, and based on the face recognition teacher model and the face recognition student model to be trained, respectively extract features from the training face samples to obtain a first training face feature representation and a second training face feature representation;
[0132] A loss calculation module, used to extract the central representation of each face category in the face recognition teacher model, and generate a target model loss corresponding to the face recognition student model to be trained based on the central representation of each face category, the sample category label, the first training face feature representation and the second training face feature representation;
[0133] The model optimization module is used to optimize the face recognition student model to be trained based on the target model loss, and obtain the face recognition compression model corresponding to the face recognition teacher model.
[0134] Optionally, the loss calculation module is further used to:
[0135] generating the face recognition loss based on a first similarity between the second training face feature representation and each of the face category center representations and the sample category label;
[0136] generating the category distribution similarity loss based on each of the first similarities and a second similarity between the first training face feature representation and each of the face category centers;
[0137] generating the feature representation similarity loss based on the first training face feature representation and the second training face feature representation;
[0138] The target model loss is generated based on the face recognition loss, the category distribution similarity loss and the feature representation similarity loss.
[0139] Optionally, the loss calculation module is further used to:
[0140] Based on the sample category label, determining the center representation of the category to which the second training facial feature representation corresponds and the corresponding center representations of each non-category in each of the face category center representations;
[0141] Calculating the similarity between the second training face feature representation and the center representation of the category to which it belongs, to obtain the intra-category similarity;
[0142] Respectively calculating the similarity between the second training face feature representation and each non-class center representation to obtain each inter-class similarity;
[0143] The face recognition loss is generated based on the intra-class similarity and each of the inter-class similarities.
[0144] Optionally, the loss calculation module is further used to:
[0145] generating the face recognition loss based on a first similarity between the second training face feature representation and each of the face category center representations and the sample category label;
[0146] generating the category distribution similarity loss based on each of the first similarities and a second similarity between the first training face feature representation and each of the face category centers;
[0147] The target model loss is generated based on the face recognition loss and the category distribution similarity loss.
[0148] Optionally, the model optimization module is further used to:
[0149] Based on the model gradient corresponding to the target model loss, the model parameters of the face recognition student model to be trained are updated, and it is determined whether the updated face recognition student model to be trained meets the preset iterative training end condition;
[0150] If satisfied, the face recognition student model to be trained is used as the face recognition compression model;
[0151] If not satisfied, return to the step of obtaining training face samples and sample category labels corresponding to the training face samples.
[0152] Optionally, the face recognition model compression device is further used for:
[0153] Acquire a face image to be identified, and based on the face recognition compression model, perform feature extraction on the face image to be identified to obtain a feature representation of the target face;
[0154] By calculating the similarity between the target face feature representation and the feature representation corresponding to each pre-recorded face image, a face recognition result corresponding to the face image to be recognized is generated.
[0155] The specific implementation of the face recognition model compression device of the present application is basically the same as the embodiments of the above-mentioned face recognition model compression method, and will not be repeated here.
[0156] The embodiment of the present application further provides a face recognition device, which is applied to a face recognition device, and the face recognition device includes:
[0157] A feature extraction module is used to obtain a face image to be identified, and based on a face recognition compression model optimized by the central representation of each face category of the face recognition teacher model, extract features from the face image to be identified to obtain a feature representation of the target face;
[0158] The generation module is used to generate a face recognition result corresponding to the face image to be recognized by calculating the similarity between the target face feature representation and the face feature representation corresponding to each pre-recorded face.
[0159] Optionally, the face recognition device is also used for:
[0160] Obtain training face samples and sample category labels corresponding to the training face samples, and based on the face recognition teacher model and the face recognition student model to be trained, respectively perform feature extraction on the training face samples to obtain a first training face feature representation and a second training face feature representation;
[0161] Generate a target model loss corresponding to the face recognition student model to be trained based on the face category center representation, the sample category label, the first training face feature representation and the second training face feature representation;
[0162] Based on the target model loss, the face recognition student model to be trained is optimized to obtain a face recognition compression model corresponding to the face recognition teacher model.
[0163] Optionally, the face recognition device is also used for:
[0164] generating the face recognition loss based on a first similarity between the second training face feature representation and each of the face category center representations and the sample category label;
[0165] generating the category distribution similarity loss based on each of the first similarities and a second similarity between the first training face feature representation and each of the face category centers;
[0166] generating the feature representation similarity loss based on the first training face feature representation and the second training face feature representation;
[0167] The target model loss is generated based on the face recognition loss, the category distribution similarity loss and the feature representation similarity loss.
[0168] The specific implementation of the face recognition device of the present application is basically the same as the embodiments of the above-mentioned face recognition method, and will not be repeated here.
[0169] An embodiment of the present application provides a medium, which is a readable storage medium, and the readable storage medium stores one or more programs, and the one or more programs can also be executed by one or more processors to implement the steps of any of the above-mentioned face recognition model compression methods.
[0170] The specific implementation of the readable storage medium of the present application is basically the same as the embodiments of the above-mentioned face recognition model compression method, and will not be repeated here.
[0171] An embodiment of the present application provides a medium, which is a readable storage medium, and the readable storage medium stores one or more programs, and the one or more programs can also be executed by one or more processors to implement the steps of any of the above-mentioned face recognition methods.
[0172] The specific implementation of the readable storage medium of the present application is basically the same as the above-mentioned embodiments of the face recognition method, and will not be repeated here.
[0173] An embodiment of the present application provides a computer program product, and the computer program product includes one or more computer programs, and the one or more computer programs can also be executed by one or more processors to implement the steps of any of the above-mentioned face recognition model compression methods.
[0174] The specific implementation methods of the computer program product of the present application are basically the same as the embodiments of the above-mentioned face recognition model compression method, and will not be repeated here.
[0175] An embodiment of the present application provides a computer program product, and the computer program product includes one or more computer programs, and the one or more computer programs can also be executed by one or more processors to implement the steps of any of the above-mentioned face recognition methods.
[0176] The specific implementation methods of the computer program product of the present application are basically the same as the above-mentioned embodiments of the face recognition method, and will not be repeated here.
[0177] The above are only preferred embodiments of the present application, and are not intended to limit the patent scope of the present application. Any equivalent structure or equivalent process transformation made using the contents of the present application specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent processing scope of the present application.
Claims
1. A face recognition model compression method, characterized in that: The face recognition model compression method comprises: Acquire training face samples and sample category labels corresponding to the training face samples, perform feature extraction on the training face samples based on the face recognition teacher model to obtain a first training face feature representation, perform feature extraction on the training face samples based on the face recognition student model to be trained to obtain a second training face feature representation; Extracting the central representation of each face category in the face recognition teacher model, and generating a target model loss corresponding to the face recognition student model to be trained based on the central representation of each face category, the sample category label, the first training face feature representation and the second training face feature representation; Based on the target model loss, optimizing the face recognition student model to be trained, and obtaining a face recognition compression model corresponding to the face recognition teacher model; The step of generating the target model loss corresponding to the face recognition student model to be trained according to the face category center representation, the sample category label, the first training face feature representation and the second training face feature representation comprises: generating the face recognition loss based on the first similarity between the second training face feature representation and each of the face category center representations and the sample category label; generating the category distribution similarity loss based on each of the first similarities and a second similarity between the first training face feature representation and each of the face category centers; generating the feature representation similarity loss based on the first training face feature representation and the second training face feature representation; The target model loss is generated based on the face recognition loss, the category distribution similarity loss and the feature representation similarity loss.
2. The face recognition model compression method according to claim 1, characterized in that: The first similarity includes intra-class similarity and inter-class similarity. The step of based on the first similarity between the second training face feature representation and each face category center representation and the sample category label comprises: Based on the sample category label, determining the center representation of the category to which the second training facial feature representation corresponds and the corresponding center representations of each non-category in each of the face category center representations; Calculating the similarity between the second training face feature representation and the center representation of the category to which it belongs, to obtain the intra-category similarity; Respectively calculating the similarity between the second training face feature representation and each non-class center representation to obtain each inter-class similarity; The face recognition loss is generated based on the intra-class similarity and each of the inter-class similarities.
3. The face recognition model compression method according to claim 1, characterized in that: The step of generating the target model loss corresponding to the face recognition student model to be trained according to the face category center representation, the sample category label, the first training face feature representation and the second training face feature representation also includes: generating the face recognition loss based on the first similarity between the second training face feature representation and each of the face category center representations and the sample category label; generating the category distribution similarity loss based on each of the first similarities and a second similarity between the first training face feature representation and each of the face category centers; The target model loss is generated based on the face recognition loss and the category distribution similarity loss.
4. The face recognition model compression method according to claim 1, characterized in that: The step of optimizing the face recognition student model to be trained based on the target model loss to obtain the face recognition compression model corresponding to the face recognition teacher model comprises: Based on the model gradient corresponding to the target model loss, the model parameters of the face recognition student model to be trained are updated, and it is determined whether the updated face recognition student model to be trained meets the preset iterative training end condition; If satisfied, the face recognition student model to be trained is used as the face recognition compression model; If not satisfied, return to the step of obtaining training face samples and sample category labels corresponding to the training face samples.
5. The face recognition model compression method according to claim 1, characterized in that: After the step of optimizing the face recognition student model to be trained based on the target model loss to obtain the target compression model corresponding to the face recognition teacher model, the face recognition model compression method further includes: Acquire a face image to be identified, and based on the face recognition compression model, perform feature extraction on the face image to be identified to obtain a feature representation of the target face; By calculating the similarity between the target face feature representation and the feature representation corresponding to each pre-recorded face image, a face recognition result corresponding to the face image to be recognized is generated.
6. A face recognition method, characterized in that: The face recognition method comprises: Obtain a face image to be recognized, and extract features of the face image to be recognized based on a face recognition compression model optimized by the central representation of each face category of the face recognition teacher model, to obtain a feature representation of the target face; Generate a face recognition result corresponding to the face image to be recognized by calculating the similarity between the target face feature representation and the face feature representations corresponding to each pre-recorded face; Before the step of extracting features from the face image to be recognized and obtaining a feature representation of the target face using the face recognition compression model based on the optimized central representation of each face category of the face recognition teacher model, the face recognition method further comprises: Acquire training face samples and sample category labels corresponding to the training face samples, perform feature extraction on the training face samples based on the face recognition teacher model to obtain a first training face feature representation, perform feature extraction on the training face samples based on the face recognition student model to be trained to obtain a second training face feature representation; Generate a target model loss corresponding to the face recognition student model to be trained based on the face category center representation, the sample category label, the first training face feature representation and the second training face feature representation; Based on the target model loss, optimizing the face recognition student model to be trained, and obtaining a face recognition compression model corresponding to the face recognition teacher model; The step of generating the target model loss corresponding to the face recognition student model to be trained according to the face category center representation, the sample category label, the first training face feature representation and the second training face feature representation comprises: generating the face recognition loss based on a first similarity between the second training face feature representation and each of the face category center representations and the sample category label; generating the category distribution similarity loss based on each of the first similarities and a second similarity between the first training face feature representation and each of the face category centers; generating the feature representation similarity loss based on the first training face feature representation and the second training face feature representation; The target model loss is generated based on the face recognition loss, the category distribution similarity loss and the feature representation similarity loss.
7. A face recognition model compression device, characterized in that: The face recognition model compression device includes: a memory, a processor, and a program stored in the memory for implementing the face recognition model compression method. The memory is used to store a program for implementing a face recognition model compression method; The processor is used to execute a program for implementing the face recognition model compression method to implement the steps of the face recognition model compression method as described in any one of claims 1 to 5.
8. A face recognition device, characterized in that: The face recognition device comprises: a memory, a processor, and a program stored in the memory for implementing the face recognition method. The memory is used to store a program for implementing a face recognition method; The processor is used to execute a program for implementing the face recognition method to implement the steps of the face recognition method as claimed in claim 6.
9. A medium, the medium being a readable storage medium, characterized in that: The readable storage medium stores a program for implementing a face recognition model compression method, and the program for implementing a face recognition model compression method is executed by a processor to implement the steps of the face recognition model compression method as described in any one of claims 1 to 5.
10. A medium, the medium being a readable storage medium, characterized in that: The readable storage medium stores a program for implementing the face recognition method, and the program for implementing the face recognition method is executed by the processor to implement the steps of the face recognition method as claimed in claim 6.
11. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, it implements the steps of the face recognition model compression method as described in any one of claims 1 to 5 or implements the steps of the face recognition method as described in any one of claim 6.
Citation Information
Patent Citations
Face recognition model acquisition method and system for video monitoring scene, and medium
CN110674688A
Multi-language model compression method and device based on knowledge distillation
CN111062489A