Face recognition and model training methods, devices, equipment, media and products

Through equiangular transformation and loss function construction technology, the features of small face recognition models are mapped to the feature space of large models, which solves the problems of large calculation, large storage and information leakage in face recognition model training, and achieves high efficiency. , low-resource lightweight face recognition model training.

CN118230396BActive Publication Date: 2024-09-10INSPUR SUZHOU INTELLIGENT TECH CO LTD
View PDF 11 Cites 0 Cited by

Patent Information

Application Number
CN202410635953.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-05-22
Publication Date
2024-09-10
Estimated Expiration
2044-05-22

AI Technical Summary

Technical Problem

The application server corresponding to the existing face recognition model training task requires a high-performance graphics processing unit, which requires a large amount of calculation and storage, and there is a risk of information leakage. The model learning is difficult and the computing efficiency is low.

Method used

Use equiangular transformation to map the output features of the backbone network of the small face recognition model to the feature space of the large face recognition model, and use the output features of the large model to construct a target loss function, and train the small model by minimizing the loss function to reduce the amount of calculations. and storage capacity, and reduce the risk of information leakage.

Benefits of technology

It realizes the training of high-precision and lightweight face recognition models, reduces the difficulty of model learning and hardware processing speed, reduces the amount of data storage and calculation, reduces resource occupancy and carbon emissions, and effectively reduces the risk of information leakage.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118230396B
    Figure CN118230396B
Patent Text Reader

Abstract

The present invention relates to the field of computer technology, and discloses a face recognition and model training method, device, equipment, medium and product thereof, including: inputting a training data set containing a number of face image samples into a trained first face recognition model and a second face recognition model to be trained, respectively, to obtain the output features of the backbone networks of the two models; using equiangular transformation to map the output features of the backbone network of the second face recognition model to the feature space of the first face recognition model; using the mapping and the output features of the backbone network of the first face recognition model to construct a target loss function; minimizing the target loss function to obtain a target face recognition model. This reduces the difficulty of model learning, improves the hardware processing speed and computing efficiency, and uses the backbone network of the first face recognition model to train a high-precision lightweight target face recognition model, reduces resource occupancy, and effectively reduces the risk of information leakage.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular to a method, device, equipment, medium and product for face recognition and model training thereof. Background Art

[0002] As an important method of identity recognition, face recognition is widely used in various scenarios where people need to be identified. Currently, deep neural networks are used to recognize face images to confirm personal identity, but the application servers corresponding to traditional face recognition model training tasks need to be configured with high-performance graphics processing units, which is relatively limited. Therefore, there is an urgent need to develop and deploy high-precision neural network models with low computational complexity.

[0003] In the related art, a well-trained large network is used to perform knowledge distillation on a small network to achieve training of a small network. In the training process, the classification probability value of the large network is mainly used as a supervisory signal, and the output of the small network is used to directly imitate the output of the large network, that is, the classification probability value of the small network output needs to be close to the classification probability value of the large network output. The model learning is difficult, not easy to converge, and the operation efficiency is low. During training, it is necessary to store the class center vectors corresponding to the two networks. When the face recognition training set contains millions of people or more, storing the class center vectors will take up a lot of video memory / memory space, which becomes a burden for model training. The above method requires the use of all model parameters of the large network. Malicious attackers can restore the face information in the training data set from all model parameters, which creates the risk of information leakage. Summary of the invention

[0004] The purpose of the present invention is to provide a face recognition and model training method, device, equipment, medium and product, which can reduce the difficulty of model learning, reduce data storage and calculation, improve hardware processing speed, and effectively reduce the risk of information leakage.

[0005] In order to solve the above technical problems, the present invention provides a face recognition model training method, comprising:

[0006] Constructing a training data set; the training data set includes a number of face image samples;

[0007] Inputting the training data set into a trained first face recognition model and a second face recognition model to be trained respectively, obtaining output features of a backbone network of the first face recognition model and output features of a backbone network of the second face recognition model; wherein the computational complexity of the first face recognition model is greater than that of the second face recognition model;

[0008] Mapping the output features of the backbone network of the second face recognition model to the feature space of the first face recognition model using a conformal transformation;

[0009] Constructing a target loss function by using a mapping of output features of the backbone network of the second face recognition model in the feature space of the first face recognition model and the output features of the backbone network of the first face recognition model;

[0010] The target loss function is minimized to obtain a trained second face recognition model as the target face recognition model.

[0011] In a first aspect, in the above-mentioned face recognition model training method provided by the present invention, before the training data set is respectively input into the trained first face recognition model and the second face recognition model to be trained, it also includes:

[0012] Using the facial image samples with labels in the training data set to train the first facial recognition model to be trained, to obtain a trained first facial recognition model; the labels are marked according to the identity identifiers;

[0013] Correspondingly, the training data set is input into the trained first face recognition model and the second face recognition model to be trained respectively, including:

[0014] Under unsupervised learning, the unlabeled face image samples in the training data set are respectively input into the trained first face recognition model and the second face recognition model to be trained; or, under supervised learning, the labeled face image samples in the training data set are respectively input into the trained first face recognition model and the second face recognition model to be trained.

[0015] On the other hand, in the above-mentioned face recognition model training method provided by the present invention, the first face recognition model includes a backbone network;

[0016] Under unsupervised learning, the second face recognition model includes a backbone network; or, under supervised learning, the second face recognition model includes a backbone network, a fully connected layer and a classification loss layer.

[0017] On the other hand, in the above-mentioned face recognition model training method provided by the present invention, the output features of the backbone network of the second face recognition model are mapped to the feature space of the first face recognition model by using conformal transformation, including:

[0018] Mapping the output features of the backbone network of the second face recognition model to the feature space of the first face recognition model using a conversion matrix;

[0019] Among them, the input of the conversion matrix is ​​the output of the backbone network of the second face recognition model, and the output features of the conversion matrix are features with the same dimension as the output features of the backbone network of the first face recognition model.

[0020] On the other hand, in the above-mentioned face recognition model training method provided by the present invention, the transformation matrix is ​​a fully connected neural network without hidden layers;

[0021] The transformation matrix is ;in, , is the transformation matrix The transposed vector of Both rows and columns are dimensional identity matrix, is the output feature dimension of the backbone network of the first face recognition model, is the output feature dimension of the backbone network of the second face recognition model, for -dimensional real vector.

[0022] On the other hand, in the above-mentioned face recognition model training method provided by the present invention, when the output feature of the backbone network of the second face recognition model is , for When the output feature of the backbone network of the second face recognition model is a real number vector of dimension , the first formula is used to map the output feature of the backbone network of the second face recognition model to the feature space of the first face recognition model; the first formula is:

[0023] ;

[0024] in, A mapping of output features of the backbone network of the second face recognition model in the feature space of the first face recognition model;

[0025] When the output feature of the backbone network of the first face recognition model is , for -dimensional real vector, and When the cosine similarity between the output features of the backbone network of the first face recognition model is equal to the cosine similarity between the output features of the backbone network of the second face recognition model.

[0026] On the other hand, in the above-mentioned face recognition model training method provided by the present invention, the target loss function is constructed by using the mapping of the output features of the backbone network of the second face recognition model in the feature space of the first face recognition model and the output features of the backbone network of the first face recognition model, including:

[0027] Constructing a first loss value according to the output features of the backbone network of the first face recognition model, the output features of the backbone network of the second face recognition model and the conversion matrix;

[0028] constructing a second loss value according to a product matrix between the transformation matrix and the transpose of the transformation matrix and an identity matrix;

[0029] Construct a target loss function according to the first loss value and the second loss value.

[0030] On the other hand, in the above-mentioned face recognition model training method provided by the present invention, constructing a target loss function according to the first loss value and the second loss value includes:

[0031] Linearly combine the first loss value and the second loss value to construct a target loss function;

[0032] Wherein, the second loss value includes a weight coefficient.

[0033] On the other hand, in the above-mentioned face recognition model training method provided by the present invention, constructing a first loss value according to the output features of the backbone network of the first face recognition model, the output features of the backbone network of the second face recognition model and the transformation matrix includes:

[0034] The output features of the backbone network of the second face recognition model are subjected to isotropic transformation by the transformation matrix to obtain new features;

[0035] The Euclidean distance between the new feature and the output feature of the backbone network of the first face recognition model is calculated to construct a first loss value.

[0036] On the other hand, in the above-mentioned face recognition model training method provided by the present invention, the Euclidean distance between the new feature and the output feature of the backbone network of the first face recognition model is calculated, and the first loss value is constructed using the third formula; the third formula is:

[0037] ;

[0038] in, is the first loss value, is the number of samples contained in each batch, , is the input face image, The input face image is is the output feature of the backbone network in the first face recognition model, represents the new feature, The input face image is is the output feature of the backbone network in the second face recognition model, Represents the 2-norm.

[0039] On the other hand, in the above-mentioned face recognition model training method provided by the present invention, under unsupervised learning, a second loss value is constructed according to the product matrix between the transformation matrix and the transpose of the transformation matrix and the unit matrix, including:

[0040] Constructing a first part of a second loss value using the square of the F-norm between the product matrix between the transformation matrix and the transpose of the transformation matrix and the identity matrix;

[0041] Calculating the sum of squares of off-diagonal elements of a product matrix between the transformation matrix and the transpose of the transformation matrix to construct a second part of a second loss value;

[0042] The first part of the second loss value and the second part of the second loss value are linearly combined to construct a second loss value.

[0043] On the other hand, in the above-mentioned face recognition model training method provided by the present invention, under supervised learning, a second loss value is constructed according to the product matrix between the transformation matrix and the transpose of the transformation matrix and the unit matrix, including:

[0044] Constructing a first part of a second loss value using the square of the F-norm between the product matrix between the transformation matrix and the transpose of the transformation matrix and the identity matrix;

[0045] Calculating the sum of squares of off-diagonal elements of a product matrix between the transformation matrix and the transpose of the transformation matrix to construct a second part of a second loss value;

[0046] Calculate the classification loss function;

[0047] The first part of the second loss value, the second part of the second loss value, and the classification loss function are linearly combined to construct a second loss value.

[0048] On the other hand, in the above-mentioned face recognition model training method provided by the present invention, the distance between the product matrix between the transformation matrix and the transpose of the transformation matrix and the unit matrix is ​​the square of the F norm, and the first part of the second loss value is constructed using the fourth formula; the fourth formula is:

[0049] ;

[0050] in, is the first part of the second loss value, is the weight coefficient, Represents the F-norm.

[0051] On the other hand, in the above-mentioned face recognition model training method provided by the present invention, the sum of the squares of the non-diagonal elements of the product matrix between the transformation matrix and the transpose of the transformation matrix is ​​calculated, and the fifth formula is used to construct the second part of the second loss value; the fifth formula is:

[0052] ;

[0053] in, is the second part of the second loss value, is the weight coefficient, represents the F-norm, Represents pixel-by-pixel matrix multiplication.

[0054] On the other hand, in the above-mentioned face recognition model training method provided by the present invention, the sixth formula is used to calculate the classification loss function; the sixth formula is:

[0055] ;

[0056] in, is the classification loss function, is the number of samples contained in each batch, , represents the total number of labels of the training dataset, , is the input face image, yes The corresponding category label, The input face image is is the output feature of the backbone network in the second face recognition model, is the weight matrix of the fully connected layer of the second face recognition model, is the weight matrix of List, represent The transposed vector of is the weight matrix No. List, represent The transposed vector of Represents the dot product of two vectors.

[0057] On the other hand, in the above-mentioned face recognition model training method provided by the present invention, while minimizing the target loss function, it also includes:

[0058] Using a stochastic gradient algorithm to update the parameters of the second face recognition model and the transformation matrix;

[0059] Among them, the parameters of the first face recognition model are not updated.

[0060] In order to solve the above technical problems, the present invention also provides a face recognition method, comprising:

[0061] Inputting the image to be tested into a target face recognition model to obtain at least one feature output by a backbone network of the target face recognition model; the target face recognition model is trained using the above-mentioned face recognition model training method;

[0062] Comparing the features output by the backbone network of the target face recognition model with the face features in the face recognition database to be queried, and obtaining the similarity between the features output by the backbone network of the target face recognition model and the face features in the face recognition database to be queried; the face recognition database to be queried contains the face features and corresponding identity identifiers of at least one person, and each person has at least one face feature;

[0063] According to the obtained similarity, the identity identifier corresponding to the facial feature in the face recognition database to be queried with the highest similarity is selected as the face recognition result.

[0064] On the other hand, in the above-mentioned face recognition method provided by the present invention, the features output by the backbone network of the target face recognition model are compared with the face features in the face recognition database to be queried, and the similarity between the features output by the backbone network of the target face recognition model and the face features in the face recognition database to be queried is obtained, including:

[0065] The mean of the features output by the backbone network of the target face recognition model is compared with the mean of the facial features of each person in the face recognition database to be queried, and the cosine similarity between the mean of the features output by the backbone network of the target face recognition model and the mean of the facial features of each person in the face recognition database to be queried is obtained.

[0066] In order to solve the above technical problems, the present invention also provides a face recognition model training device, comprising:

[0067] A training set construction module, used to construct a training data set; the training data set includes a number of face image samples;

[0068] an output feature acquisition module, used to input the training data set into the trained first face recognition model and the second face recognition model to be trained, respectively, to obtain the output features of the backbone network of the first face recognition model and the output features of the backbone network of the second face recognition model; wherein the computational complexity of the first face recognition model is greater than that of the second face recognition model;

[0069] A conformal transformation module, used to map the output features of the backbone network of the second face recognition model to the feature space of the first face recognition model by adopting conformal transformation;

[0070] A loss function construction module, used to construct a target loss function by using a mapping of the output features of the backbone network of the second face recognition model in the feature space of the first face recognition model and the output features of the backbone network of the first face recognition model;

[0071] The model training module is used to minimize the target loss function to obtain a trained second face recognition model as the target face recognition model.

[0072] In order to solve the above technical problems, the present invention further provides a face recognition device, comprising:

[0073] A model inference module, used for inputting the image to be tested into a target face recognition model to obtain at least one feature output by a backbone network of the target face recognition model; the target face recognition model is trained using the above-mentioned face recognition model training method;

[0074] A similarity acquisition module is used to compare the features output by the backbone network of the target face recognition model with the face features in the face recognition database to be queried, and obtain the similarity between the features output by the backbone network of the target face recognition model and the face features in the face recognition database to be queried; the face recognition database to be queried contains the face features and corresponding identity identifiers of at least one person, and each person has at least one face feature;

[0075] The recognition result output module is used to select the identity identifier corresponding to the facial feature with the highest similarity in the face recognition database to be queried as the face recognition result according to the obtained similarity.

[0076] In order to solve the above technical problem, the present invention further provides an electronic device, comprising:

[0077] Memory for storing computer programs;

[0078] A processor is used to implement the steps of the above-mentioned face recognition model training method when executing the computer program; and / or, implement the steps of the above-mentioned face recognition method.

[0079] In order to solve the above technical problems, the present invention also provides a non-volatile storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the steps of the above-mentioned face recognition model training method are implemented; and / or, the steps of the above-mentioned face recognition method are implemented.

[0080] In order to solve the above technical problems, the present invention also provides a computer program product, including a computer program / instruction, which, when executed by a processor, implements the steps of the above face recognition model training method; and / or implements the steps of the above face recognition method.

[0081] It can be seen from the above technical scheme that a face recognition model training method provided by the present invention includes: constructing a training data set; the training data set includes a number of face image samples; inputting the training data set into a trained first face recognition model and a second face recognition model to be trained respectively, to obtain the output features of the backbone network of the first face recognition model and the output features of the backbone network of the second face recognition model; wherein the computational complexity of the first face recognition model is greater than the computational complexity of the second face recognition model; using equiangular transformation to map the output features of the backbone network of the second face recognition model to the feature space of the first face recognition model; using the mapping of the output features of the backbone network of the second face recognition model in the feature space of the first face recognition model and the output features of the backbone network of the first face recognition model to construct a target loss function; minimizing the target loss function to obtain the trained second face recognition model and use it as the target face recognition model.

[0082] The beneficial effect of the present invention is that, in the above-mentioned face recognition model training method provided by the present invention, the training data set only needs to contain face image samples, and is not restricted by whether there are labels or not. During the training process, the output features of the backbone network of the second face recognition model are mapped to the feature space of the first face recognition model by using conformal transformation, and the mapping of the output features of the backbone network of the second face recognition model in the feature space of the first face recognition model and the output features of the backbone network of the first face recognition model are used to construct a target loss function. Such conformal transformation technology and loss function construction do not require the output of the second face recognition model to directly imitate the output of the first face recognition model, thereby reducing the difficulty of model learning and achieving the same optimization effect, improving the hardware processing speed and computing efficiency, and only using the backbone network of the first face recognition model to train a high-precision lightweight target face recognition model, reducing the amount of data storage and calculation, reducing resource occupancy, reducing carbon emissions, and effectively reducing the risk of information leakage by the first face recognition model, which is conducive to the healthy development of artificial intelligence technology.

[0083] In addition, the present invention also provides a corresponding face recognition method, a face recognition model training device, a face recognition device, an electronic device, a non-volatile storage medium and a computer program product for the face recognition model training method, which have the same or corresponding technical features as the above-mentioned face recognition model training method and have the same effects as above. BRIEF DESCRIPTION OF THE DRAWINGS

[0084] In order to more clearly illustrate the embodiments of the present invention, the following briefly introduces the drawings required for use in the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0085] Figure 1 A flowchart of a face recognition model training method provided by an embodiment of the present invention;

[0086] Figure 2 A schematic diagram of the architecture of the second face recognition model provided by an embodiment of the present invention for training under unsupervised learning;

[0087] Figure 3 A schematic diagram of the architecture of the second face recognition model provided in an embodiment of the present invention for training under supervised learning;

[0088] Figure 4 A flow chart of a face recognition method provided by an embodiment of the present invention;

[0089] Figure 5 A schematic diagram of the structure of a face recognition model training device provided by an embodiment of the present invention;

[0090] Figure 6 A schematic diagram of the structure of a face recognition device provided by an embodiment of the present invention;

[0091] Figure 7 A schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0092] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0093] In order to enable those skilled in the art to better understand the solution of the present invention, the present invention is further described in detail below in conjunction with the accompanying drawings and specific implementation methods. Figure 1 A flowchart of a face recognition model training method provided by an embodiment of the present invention, such as Figure 1 As shown, the method includes:

[0094] S101, constructing a training data set; the training data set includes a number of face image samples.

[0095] In implementation, the input image of the face recognition model is a color image with three channels (R, G, B channels) of a fixed size. The face image samples in the training data set of the present invention can also be color images with three channels (R, G, B channels) of a fixed size, wherein the image width can be 112 pixels, the image height can be 112 pixels, and the number of channels can be 3. When the size of the input image is not the above size, the present invention can be simply expanded to adapt to the change of the input image size. When the input image is a single-channel grayscale image or an image in other formats, such as: YUV format, the present invention can also be simply expanded to adapt to the change of the input image (channel).

[0096] It should be noted that the training data set includes unlabeled face image samples and may also include labeled face image samples, that is, the face image samples are not restricted in terms of whether they are labeled or not. In the absence of a labeled training data set, the present invention can train a high-precision lightweight (low computational complexity) face recognition model; under the supervision of a labeled data set, the present invention can train a higher-precision lightweight (low computational complexity) face recognition model.

[0097] The present invention can select a large number of face images (for example, millions or more face images) and cut them into sizes that meet the input specifications of the face recognition model. In the unlabeled mode setting, the face images have no corresponding labels. Alternatively, the present invention can select a large number of natural images (for example, face images, animal images, plant images, and images of various categories) and cut them into sizes that meet the input specifications of the face recognition model, and these images do not require label data. The present invention can also use randomly generated images, but it is difficult to train a high-precision face recognition model using a random image collection. In the unlabeled setting, the present invention preferentially recommends the use of unlabeled face images.

[0098] Similarly, the present invention can also select a large number of labeled face images. One of the prerequisites for deep learning-based face recognition technology to achieve high accuracy is to use a large-scale training data set to train the face recognition model. In order to train a high-precision face recognition model, the training data set can have sufficient depth and breadth, where depth refers to the number of face images of each person, the more face images the better, and these images can come from a variety of scenes, and include factors such as illumination changes, occlusion changes, accessory changes, face posture changes, and age changes; breadth refers to the number of people included in the training data set, the more people the better, and can include different races, different genders, different skin colors, etc. In practical applications, when the face training data set contains more training data, the accuracy of the face recognition model trained using the method proposed in the present invention is higher. The labeled face images in the training data set used by the present invention can be grouped according to the identity (ID), each group contains a face image of one person, and then a category label is given to each group. Assuming that the training data set contains K people, the present invention can adopt a simple category label assignment method, with labels from 0 to K-1. In order to train a high-precision target face recognition model, the training data set in the present invention may contain at least 10,000 face images of people, wherein the number of images of each person is 20 on average. The face images are normalized face images preprocessed by a face alignment algorithm.

[0099] S102. Input the training data set into the trained first face recognition model and the second face recognition model to be trained respectively, and obtain the output features of the backbone network of the first face recognition model and the output features of the backbone network of the second face recognition model; wherein the computational complexity of the first face recognition model is greater than that of the second face recognition model.

[0100] It should be noted that the first face recognition model of the present invention can be understood as a teacher network, and the second face recognition model can be understood as a student network. In the process of training the target face recognition model, the first face recognition model used in the present invention is a trained network, and the second face recognition model is an untrained network. The computational complexity of the first face recognition model is greater than that of the second face recognition model. The first face recognition model with a large computational complexity has a stronger feature expression capability and higher performance. After the present invention inputs the training data set into the two face recognition models respectively, the output features of the backbone networks (i.e., the face feature extraction networks) of the two models are obtained, and the backbone network of the first face recognition model is used to guide the training process of the second face recognition model, so as to further improve the performance of the second face recognition model, so that the performance of the second face recognition model gradually approaches the performance of the first face recognition model.

[0101] In practical applications, the first face recognition model and the second face recognition model are one or more input network model description files, and the network model description files contain weight parameters of the network model and a description of the network model. The neural network training algorithm reads the input network model description file, and constructs the input neural network model according to the network model description file, and initializes the weight parameters of the constructed input neural network model. The weight parameters of the network model are parameters obtained by the model training method or randomly initialized parameters. The present invention needs to use the output features of the backbone network of the first face recognition model and the output features of the backbone network of the second face recognition model to perform subsequent model training and update the model parameters until convergence.

[0102] S103, using conformal transformation to map the output features of the backbone network of the second face recognition model to the feature space of the first face recognition model.

[0103] In implementation, the feature space describes the characteristic attributes of the sample data and is a multidimensional vector space in which each dimension represents an independent facial image feature. The present invention uses conformal transformation to map the features in the feature space of the second face recognition model to the feature space of the first face recognition model, so that the feature space of the second face recognition model is not forced to be the same as the feature space of the first face recognition model, thereby reducing the difficulty of distillation learning. Thanks to the conformal transformation's angle-preserving property, the cosine similarity between two feature vectors in the feature space of the second face recognition model and the cosine similarity between the mappings of the two feature vectors in the feature space of the first face recognition model can be equal.

[0104] S104, constructing a target loss function by using the mapping of the output features of the backbone network of the second face recognition model in the feature space of the first face recognition model and the output features of the backbone network of the first face recognition model.

[0105] In implementation, the target loss function is constructed using the mapping of the features of the second face recognition model in the feature space of the first face recognition model and the features of the first face recognition model.

[0106] S105. Minimize the target loss function to obtain a trained second face recognition model and use it as the target face recognition model.

[0107] In implementation, by minimizing the target loss function, the feature map distribution of the second face recognition model learns the feature distribution of the first face recognition model. It should be noted that the present invention does not force the features of the second face recognition model to be the same as those of the first face recognition model, but can make the expression capabilities of the second face recognition model close to those of the first face recognition model. The target face recognition model finally obtained has a lower computational cost in the forward reasoning process and is more suitable for deployment on computing devices with weak computing power.

[0108] In specific implementation, while minimizing the target loss function, it can also include: using a stochastic gradient descent algorithm to update the parameters of the second face recognition model and the transformation matrix; wherein the parameters of the first face recognition model are not updated. That is, the present invention does not require a preset equiangular transformation matrix, but uses a stochastic gradient descent algorithm to simultaneously learn the parameters of the second face recognition model and the parameters of the equiangular transformation to achieve the best optimization effect.

[0109] In the above-mentioned face recognition model training method provided by the embodiment of the present invention, the training data set only needs to contain face image samples, and there is no restriction on whether there are labels or not. During the training process, the output features of the backbone network of the second face recognition model are mapped to the feature space of the first face recognition model by using conformal transformation, and the mapping of the output features of the backbone network of the second face recognition model in the feature space of the first face recognition model and the output features of the backbone network of the first face recognition model are used to construct the target loss function. Such conformal exchange technology and the construction of the loss function do not require the output of the second face recognition model to directly imitate the output of the first face recognition model, thereby reducing the difficulty of model learning and achieving the same optimization effect, improving the hardware processing speed and computing efficiency, and only using the backbone network of the first face recognition model to train a high-precision lightweight target face recognition model, reducing the amount of data storage and calculation, reducing resource occupancy, reducing carbon emissions, and effectively reducing the risk of information leakage of the first face recognition model, which is conducive to the healthy development of artificial intelligence technology.

[0110] Furthermore, in a specific implementation, in the above-mentioned face recognition model training method provided in an embodiment of the present invention, before executing step S102 to input the training data set into the trained first face recognition model and the second face recognition model to be trained respectively, it can also include: using the face image samples with labels in the training data set to train the first face recognition model to be trained, so as to obtain the trained first face recognition model; the labels are marked according to the identity identifiers.

[0111] In implementation, when a trained first face recognition model cannot be obtained, the first face recognition model to be trained needs to be trained. At this time, the first face recognition model to be trained needs to include a fully connected layer and a classification loss layer for supervised learning, that is, a labeled training data set is used to train the first face recognition model. Of course, the present invention can also directly use an open source / shared first face recognition model.

[0112] In the process of training the first face recognition model, the total training cycle (epoch) can be set to 20 cycles, and one training cycle means that all training samples are used once without repetition. In order to avoid the order of samples in the data set affecting the performance of the model, and to improve the generalization performance of the model, at the beginning of each training cycle, all samples in the training data set are rearranged randomly, that is, the order is disrupted. In each training cycle, the disrupted training data set is divided into smaller sets, and this small sample set is also called a batch of samples. According to the configuration of the training server, the number of samples of the small batch samples in the present invention can be at least 1024. The training method reads a batch of training samples each time, and uses these samples to calculate the model loss value, update the model parameters, etc. The present invention can use Softmax loss function or other loss functions (such as ArcFace, CosFace, etc.) to train the first face recognition model.

[0113] The following is a specific example to describe the training process of the first face recognition model:

[0114] Initial parameter settings for training input may include: labeled face recognition training set ; Initial training cycle , total training cycle ; The relevant parameters of the stochastic gradient descent algorithm are the initial learning rate , momentum coefficient , weight decay coefficient , in the 10th training cycle, the learning rate drops to , in the 15th training cycle, the learning rate drops to , in the 18th training cycle, the learning rate dropped to The number of samples in a batch is 512). The loss function is Softmax loss function.

[0115] The training steps of the first face recognition model include: firstly initializing the learnable parameters of the first face recognition model using a random initialization method; When , perform the operation: ; Randomly shuffle the sample order of the data set and divide it into several training batches; select a batch of training samples; update the model parameters using the stochastic gradient descent algorithm based on the above training samples and parameter settings; repeat the above steps of selecting samples and updating parameters until the current training cycle ends and outputs the first face recognition model.

[0116] In the process of training the first neural network model, the Softmax loss function of the first neural network model can be calculated using the following formula:

[0117] ; (1)

[0118] Among them, the first face recognition model is defined as , is the loss function of the first neural network model, is the number of samples contained in each batch, , represents the total number of labels in the training dataset, , is the input face image, yes The corresponding category label, The input face image is is the output feature of the backbone network in the first neural network model, is the weight matrix of the fully connected layer of the first neural network model, is the weight matrix of List, represent The transposed vector of is the weight matrix No. List, represent The transposed vector of Represents the dot product of two vectors. Represents the dot product of two vectors.

[0119] Furthermore, in the specific implementation, step S102 inputs the training data set into the trained first face recognition model and the second face recognition model to be trained respectively, which may specifically include: under unsupervised learning, inputting the unlabeled face image samples in the training data set into the trained first face recognition model and the second face recognition model to be trained respectively; or, under supervised learning, inputting the labeled face image samples in the training data set into the trained first face recognition model and the second face recognition model to be trained respectively.

[0120] In the implementation, there are two settings in the process of training the second face recognition model. The first setting is the unlabeled training mode. In the unlabeled training mode, the inputs of the first face recognition model and the second face recognition model are all unlabeled face image samples. The total training cycle (epoch) can be set to 80 cycles (more training cycles are required in the unsupervised setting), and there is no category supervision signal; the second setting is the labeled training mode. In the labeled training mode, the inputs of the first face recognition model and the second face recognition model are all labeled face image samples. The total training cycle (epoch) is set to 20 cycles, and the label is used as an additional supervision signal. Moreover, the data input to the first face recognition model and the second face recognition model at the same time are the same data, that is, the face image samples input to the two face recognition models at the same time are the same.

[0121] When a training cycle ends, the next training cycle begins. When the total number of training cycles reaches the preset value, the training ends. It is worth noting that in special cases, within a training cycle, the total number of samples in the data set cannot be divided into integer batches, and individual samples are not used (discarded directly) or are used multiple times (to complete the data, such as adding several samples that have been used to the end of the data set). The impact of these individual samples on the training results can be ignored.

[0122] In a specific implementation, in the above-mentioned face recognition model training method provided in an embodiment of the present invention, the first face recognition model may include a backbone network; under unsupervised learning, the second face recognition model may include a backbone network; or, under supervised learning, the second face recognition model may include a backbone network, a fully connected layer and a classification loss layer.

[0123] In implementation, the backbone network can be extracted from the first face recognition model obtained after the training of the first face recognition model to be trained, and the extracted backbone network can be used to guide the training of the second face recognition model; the backbone network of the open source / shared first face recognition model can also be directly used to guide the training of the second face recognition model. Under supervised learning, since the fully connected layer and the classification loss layer are required in the calculation of the loss function, the second face recognition model needs to include the backbone network, the fully connected layer and the classification loss layer.

[0124] It is understandable that the basic structures of the first face recognition model and the second face recognition model can be the same or similar, which can ensure better results of the distillation algorithm. Of course, the basic structures of the first face recognition model and the second face recognition model can also be different. The trained first face recognition model may not include a fully connected layer and a classification loss layer.

[0125] Furthermore, in a specific implementation, in the above-mentioned face recognition model training method provided in an embodiment of the present invention, step S103 uses an equiangular transformation to map the output features of the backbone network of the second face recognition model to the feature space of the first face recognition model, which may specifically include: using a transformation matrix to map the output features of the backbone network of the second face recognition model to the feature space of the first face recognition model; wherein the input of the transformation matrix is ​​the output of the backbone network of the second face recognition model, and the output features of the transformation matrix are features with the same dimension as the output features of the backbone network of the first face recognition model.

[0126] In implementation, the present invention is not limited to requiring that the output dimension of the backbone network of the first face recognition model is the same as the output dimension of the backbone network of the second face recognition model. The present invention uses a learnable equiangular transformation matrix to transform the output features of the backbone network of the second face recognition model. The transformation matrix can be a fully connected neural network without hidden layers.

[0127] The above transformation matrix can be ;in, , is the transformation matrix The transposed vector of Both rows and columns are dimensional identity matrix (a square matrix with all diagonal elements being 1 and all other elements being 0), is the output feature dimension of the backbone network of the first face recognition model, and the second face recognition model is defined as , is the output feature dimension of the backbone network of the second face recognition model, for -dimensional real vector.

[0128] In the specific implementation, in the above-mentioned face recognition model training method provided in the embodiment of the present invention, when the output feature of the backbone network of the second face recognition model is , for When the output features of the backbone network of the second face recognition model are a real vector of dimension , the following formula can be used to map the output features of the backbone network of the second face recognition model to the feature space of the first face recognition model:

[0129] ; (2)

[0130] in, is the mapping of the output features of the backbone network of the second face recognition model in the feature space of the first face recognition model. After a learnable equiangular transformation matrix Transformed to .

[0131] When the output feature of the backbone network of the first face recognition model is , for -dimensional real vector, and When , the cosine similarity between the output features of the backbone network of the first face recognition model is equal to the cosine similarity between the output features of the backbone network of the second face recognition model. The specific principle is as follows:

[0132] Assume that the two unit features output by the second face recognition model are given and , their mapping in the feature space of the first face recognition model is and ,So .

[0133] if , ,So . That is to say, the cosine similarity between the output features of the backbone network of the second face recognition model is equal to the cosine similarity between the mappings of the output features of the backbone network of the second face recognition model in the feature space of the first face recognition model. If the mapping of the output features of the backbone network of the second face recognition model is equal to the output features of the backbone network of the first face recognition model, then the cosine similarity between the output features of the backbone network of the second face recognition model is equal to the cosine similarity between the output features of the backbone network of the first face recognition model. Therefore, as long as the mapping of the output features of the backbone network of the second face recognition model in the feature space of the first face recognition model is equal to the output features of the backbone network of the first face recognition model, the recognition capabilities of the first face recognition model and the second face recognition model are the same.

[0134] It should be noted that when the cosine distance is used as the similarity measurement function, for two input images, the similarity value output by the second face recognition model obtained by the present invention is theoretically equal to the similarity value output by the first face recognition model. The method of the present invention can be directly applied to various image classification tasks, and can also be applied to other computer vision tasks through simple extension, such as image classification tasks, target detection tasks, and instance segmentation tasks.

[0135] Further, in the specific implementation, in the above-mentioned face recognition model training method provided in the embodiment of the present invention, step S104 uses the mapping of the output features of the backbone network of the second face recognition model in the feature space of the first face recognition model and the output features of the backbone network of the first face recognition model to construct a target loss function, which may specifically include the following steps:

[0136] Step 1: construct a first loss value according to the output features of the backbone network of the first face recognition model, the output features of the backbone network of the second face recognition model and the conversion matrix;

[0137] Step 2: construct a second loss value according to the product matrix between the transformation matrix and the transpose of the transformation matrix and the identity matrix;

[0138] Step 3: Construct the target loss function based on the first loss value and the second loss value.

[0139] In specific implementation, in the above step three, a target loss function is constructed according to the first loss value and the second loss value, which may specifically include: linearly combining the first loss value and the second loss value to construct the target loss function; wherein the second loss value includes a weight coefficient.

[0140] In specific implementation, the above step 1 constructs a first loss value based on the output features of the backbone network of the first face recognition model, the output features of the backbone network of the second face recognition model and the transformation matrix. Specifically, it may include: first, subjecting the output features of the backbone network of the second face recognition model to an equiangular transformation of the transformation matrix to obtain new features; then, calculating the Euclidean distance between the new features and the output features of the backbone network of the first face recognition model to construct a first loss value.

[0141] In the implementation, the Euclidean distance between the new feature and the output feature of the backbone network of the first face recognition model is calculated, and the first loss value is constructed using the following formula:

[0142] ; (3)

[0143] in, is the first loss value, is the number of samples contained in each batch, , is the input face image, The input face image is is the output feature of the backbone network in the first face recognition model, Indicates new features, The input face image is is the output feature of the backbone network in the second face recognition model, Represents the 2-norm. From formula (3), it can be seen that when minimizing the objective loss function, the output features of the backbone network of the second face recognition model are required to be close to the output features of the backbone network of the first face recognition model after isotropic transformation.

[0144] In specific implementation, there are two implementation methods for constructing the second loss value in step 2:

[0145] The first implementation method is implemented under unsupervised learning. Specifically, the first part of the second loss value can be constructed by first using the distance between the product matrix between the transformation matrix and the transpose of the transformation matrix and the unit matrix as the square of the F norm; then the sum of the squares of the non-diagonal elements of the product matrix between the transformation matrix and the transpose of the transformation matrix is ​​calculated to construct the second part of the second loss value; finally, the first part of the second loss value and the second part of the second loss value are linearly combined to construct the second loss value.

[0146] The second implementation method is implemented under supervised learning. Specifically, the first part of the second loss value can be constructed by first using the distance between the product matrix between the transformation matrix and the transpose of the transformation matrix and the unit matrix as the square of the F norm; then the sum of the squares of the non-diagonal elements of the product matrix between the transformation matrix and the transpose of the transformation matrix is ​​calculated to construct the second part of the second loss value; then the classification loss function is calculated; finally, the first part of the second loss value, the second part of the second loss value and the classification loss function are linearly combined to construct the second loss value.

[0147] From the above, we can see that under supervised learning, that is, in the labeled training mode, in the process of constructing the second loss value, there is an additional step of calculating the classification loss function compared to unsupervised learning. Finally, the second loss value needs to be obtained by linearly combining the first part of the second loss value, the second part of the second loss value and the classification loss function.

[0148] In a specific implementation, the distance between the product matrix between the transformation matrix and the transpose of the transformation matrix and the identity matrix is ​​the square of the F norm, and the first part of the second loss value can be constructed using the following formula:

[0149] ; (4)

[0150] in, is the first part of the second loss value, is the weight coefficient, for example: , represents the F-norm (Frobenius norm). From the above formula (4), we can see that when minimizing the objective loss function, Close to or equal to , that is It is an isometric transformation.

[0151] In a specific implementation, the sum of squares of the off-diagonal elements of the product matrix between the transformation matrix and the transpose of the transformation matrix is ​​calculated, and the second part of the second loss value can be constructed using the following formula:

[0152] ; (5)

[0153] in, is the second part of the second loss value, is the weight coefficient, represents the F-norm, represents the matrix multiplication by pixel (by position). From the above formula (5), it can be seen that when minimizing the target loss function, The two different vectors in are orthogonal.

[0154] At this point, under unsupervised learning, the target loss function can be constructed using the following formula:

[0155] . (6)

[0156] In the specific implementation, the following formula is used to calculate the classification loss function; the sixth formula is:

[0157] ; (7)

[0158] in, is the classification loss function, is the number of samples contained in each batch, , represents the total number of labels in the training dataset, , is the input face image, yes The corresponding category label, The input face image is is the output feature of the backbone network in the second face recognition model, is the weight matrix of the fully connected layer of the second face recognition model, is the weight matrix of List, represent The transposed vector of is the weight matrix No. List, represent The transposed vector of Represents the dot product of two vectors.

[0159] At this point, under supervised learning, the target loss function can be constructed using the following formula:

[0160] . (8)

[0161] The following uses ResNet50 as the first face recognition model and ResNet18 as the second face recognition model as an example to illustrate the face recognition model training method provided by the embodiment of the present invention:

[0162] The backbone network of ResNet50 in the present invention may include a first group of convolutions (conv1), a second group of convolutions (conv2_x), a third group of convolutions (conv3_x), a fourth group of convolutions (conv4_x), a fifth group of convolutions (conv5_x) and a first fully connected layer (Fully-connected layer_1, FC1), and ResNet50 may also include a second fully connected layer (Fully-connected layer_2, FC2) and a loss function layer. The input of the FC1 layer is the output feature of the conv5_x layer, and the output of the FC1 layer is a 512-dimensional feature. The input of the FC2 layer is the output feature of the FC1 layer (512-dimensional feature), and the dimension of the output feature of the FC2 layer is the same as the number of categories (number of IDs) in the training set, and one dimension corresponds to one category. Among them, conv1 is a 7×7 convolution layer, and the convolution step is 2 (in fact, conv1 is a 7×7×3 convolution, where 3 means that the number of input channels of conv1 is 3 channels. In order to express more concisely and clearly, the number of channels is ignored here); in the present invention, the conv1 layer adopts a 3×3 convolution layer, and the convolution step is 1. Assuming that the FC2 layer may not contain a bias term, of course, it can also be extended to the case of containing a bias term. After adding the bias term, there is no obvious difference in performance.

[0163] The backbone network of ResNet18 adopted in the present invention may also include a first group of convolutions (conv1), a second group of convolutions (conv2_x), a third group of convolutions (conv3_x), a fourth group of convolutions (conv4_x), a fifth group of convolutions (conv5_x) and a first fully connected layer (Fully-connected layer_1, FC1), and ResNet18 may also include a second fully connected layer (Fully-connected layer_2, FC2) and a loss function layer. The input of the FC1 layer is the output feature of the conv5_x layer, and the output of the FC1 layer is a 512-dimensional feature. The input of the FC2 layer is the output feature of the FC1 layer (512-dimensional feature), and the dimension of the output feature of the FC2 layer is the same as the number of categories in the training set, and one dimension corresponds to one category. Among them, conv1 is a 7×7 convolution with a step size of 2 (in fact, conv1 is a 7×7×3 convolution, where 3 means that the number of input channels of conv1 is 3 channels. In order to express more concisely and clearly, the number of channels is ignored here); in the present invention, the conv1 layer adopts a 3×3 convolution layer with a convolution step size of 1. Assuming that the FC2 layer may not contain a bias term, of course, it can also be extended to the case of containing a bias term. After adding the bias term, there is no obvious difference in performance.

[0164] The above network structure and parameter settings are exemplary settings, and the present invention is not limited to a specific network structure and specific parameters in the network structure.

[0165] The following two specific examples describe the training process of the second face recognition model:

[0166] In the first specific example, the initial parameter settings for the training input may include: ; Initial training cycle , total training cycle ; Stochastic gradient descent method related parameters: The initial learning rate is , momentum coefficient , the weight decay coefficient is , in the 40th training cycle, the learning rate drops to , in the 60th training cycle, the learning rate drops to , in the 70th training cycle, the learning rate dropped to The number of samples in a batch . Regularization term ratio .

[0167] Figure 2 A schematic diagram of the architecture of the second face recognition model provided by the embodiment of the present invention for training under unsupervised learning. Figure 2 As shown, the backbone network of the first face recognition model uses the backbone network of ResNet50, including the first group of convolutions, the second group of convolutions, the third group of convolutions, the fourth group of convolutions, the fifth group of convolutions and a fully connected layer; the backbone network of the second face recognition model uses the backbone network of ResNet18, also including the first group of convolutions, the second group of convolutions, the third group of convolutions, the fourth group of convolutions, the fifth group of convolutions and a fully connected layer. The output features of the backbone network of the first face recognition model are equiangularly transformed by the transformation matrix to obtain new features after mapping. The first loss value can be obtained based on the new features and the output features of the backbone network of the first face recognition model. .

[0168] Figure 3 A schematic diagram of the architecture of the second face recognition model provided in an embodiment of the present invention for training under supervised learning. Figure 3 The main structure shown is Figure 2 The difference is that the second face recognition model includes a second fully connected layer in addition to the backbone network. Here, the second fully connected layer is used to obtain the classification loss function. .

[0169] The training steps of the second face recognition model under unsupervised learning or supervised learning may include: firstly initializing the learnable parameters of the second face recognition model using a random initialization method; When , perform the operation: ; Select a batch of training samples; Based on the above training samples and parameter settings, use the stochastic gradient descent algorithm to update the model parameters and the parameters of the transformation matrix; Repeat the above steps of selecting samples and updating parameters until the current training cycle ends and outputs the second face recognition model.

[0170] The present invention also provides an embodiment corresponding to a face recognition method. Figure 4 A flow chart of a face recognition method provided by an embodiment of the present invention, such as Figure 4 As shown, the method includes:

[0171] S401. Input the image to be tested into a target face recognition model to obtain at least one feature output by a backbone network of the target face recognition model; the target face recognition model is trained using the above-mentioned face recognition model training method.

[0172] In implementation, the image to be tested must be a face image that meets the input specifications of the target face recognition model trained by the present invention; the input image to be tested can be an image of a person or multiple images of a person. In addition, the input image to be tested can also be an image containing a face, and then image processing operations such as face detection technology, face feature point positioning technology, and image affine transformation technology are used to obtain an image that meets the input specifications of the target face recognition model trained by the present invention. One or more input images to be tested are input into the target face recognition model to obtain one or more features of the image to be tested.

[0173] S402. Compare the features output by the backbone network of the target face recognition model with the face features in the face recognition database to be queried, and obtain the similarity between the features output by the backbone network of the target face recognition model and the face features in the face recognition database to be queried; the face recognition database to be queried contains the face features and corresponding identity identifiers of at least one person, and each person has at least one face feature.

[0174] In implementation, the face recognition database to be queried is a feature library of faces, wherein the features of each face are features extracted using the backbone network of the target face recognition model trained by the present invention. The library to be queried contains the facial features of at least one person, and each person has at least one facial feature. In addition, each facial feature may contain a weight coefficient, and the weight coefficient indicates the importance of the corresponding facial feature. The weight coefficient may be a detection score output by a face detector, a score of the degree of blurriness of the face, a score of the degree of occlusion of the face, and the like. The face recognition database to be queried contains the facial features of individuals corresponding to the face images. The present invention compares one or more features of one or more input images to be tested with the features of the face recognition database to be queried, and can obtain the similarity between one or more features of one or more input images to be tested and the facial features of the face recognition database to be queried.

[0175] S403: According to the obtained similarity, select the identity identifier corresponding to the facial feature in the to-be-queried face recognition database with the highest similarity as the face recognition result.

[0176] In implementation, based on the comparison result, the identity of the face in the face database with the highest similarity to the image to be tested is output as the face recognition result.

[0177] In the above-mentioned face recognition method provided by the embodiment of the present invention, the trained target face recognition model is used to infer the corresponding features and compare them with the face features in the face recognition database to be queried, and the final recognition result is output according to the degree of similarity. This method is simple and fast, can improve the hardware processing speed, reduce the amount of data storage, and is conducive to the healthy development of artificial intelligence technology.

[0178] Furthermore, in a specific implementation, in the above-mentioned face recognition method provided in an embodiment of the present invention, step S402 compares the features output by the backbone network of the target face recognition model with the face features in the face recognition database to be queried, and obtains the similarity between the features output by the backbone network of the target face recognition model and the face features in the face recognition database to be queried. Specifically, it may include: comparing the mean of the features output by the backbone network of the target face recognition model with the mean of the face features of each person in the face recognition database to be queried, and obtaining the cosine similarity between the mean of the features output by the backbone network of the target face recognition model and the mean of the face features of each person in the face recognition database to be queried.

[0179] In implementation, the similarity may be the cosine similarity between the mean of one or more features of the input one or more images to be tested and the mean of one or more features of each person in the face recognition database to be queried. The mean of the above one or more features may be the average value of one or more features, or the weighted average value of one or more features (weighted by a weight coefficient). In addition, the similarity may also be the cosine similarity between the feature with the highest importance value among one or more features of the input one or more images to be tested and the feature with the highest importance value among one or more features of each person in the face recognition database to be queried. When calculating the similarity, facial features of low importance may also be excluded based on the importance score.

[0180] In the above embodiments, the face recognition model training method and the face recognition method are described in detail. The present invention also provides corresponding embodiments of the face recognition model training device, the face recognition device, and the electronic device.

[0181] Figure 5 This is a structural diagram of a face recognition model training device provided by an embodiment of the present invention. Based on the perspective of functional modules, the device includes:

[0182] The training set construction module 10 is used to construct a training data set; the training data set includes a number of face image samples;

[0183] The output feature acquisition module 11 is used to input the training data set into the trained first face recognition model and the second face recognition model to be trained, respectively, to obtain the output features of the backbone network of the first face recognition model and the output features of the backbone network of the second face recognition model; wherein the computational complexity of the first face recognition model is greater than that of the second face recognition model;

[0184] A conformal transformation module 12, used for mapping the output features of the backbone network of the second face recognition model to the feature space of the first face recognition model by adopting conformal transformation;

[0185] A loss function construction module 13, used to construct a target loss function by using the mapping of the output features of the backbone network of the second face recognition model in the feature space of the first face recognition model and the output features of the backbone network of the first face recognition model;

[0186] The model training module 14 is used to minimize the target loss function, obtain the trained second face recognition model and use it as the target face recognition model.

[0187] In the above-mentioned face recognition model training device provided in the embodiment of the present invention, through the interaction of the above-mentioned five modules, a high-precision lightweight target face recognition model can be trained using only the backbone network of the first face recognition model, without the output of the second face recognition model directly imitating the output of the first face recognition model, thereby reducing the difficulty of model learning and achieving the same optimization effect, improving hardware processing speed and computing efficiency, reducing data storage and calculation amount, reducing resource occupancy, reducing carbon emissions, and effectively reducing the risk of information leakage of the first face recognition model, which is conducive to the healthy development of artificial intelligence technology.

[0188] Since the embodiments of the face recognition model training device part correspond to the embodiments of the face recognition model training method part mentioned above, the embodiments of the face recognition model training device part refer to the description of the embodiments of the face recognition model training method part, and will not be repeated here. And the face recognition model training device has the same beneficial effects as the face recognition model training method.

[0189] Furthermore, in a specific implementation, in the above-mentioned face recognition model training device provided in an embodiment of the present invention, the output feature acquisition module 11 can be specifically used to, under unsupervised learning, input the unlabeled face image samples in the training data set into the trained first face recognition model and the second face recognition model to be trained, respectively; or, under supervised learning, input the labeled face image samples in the training data set into the trained first face recognition model and the second face recognition model to be trained, respectively.

[0190] Furthermore, in specific implementation, in the above-mentioned face recognition model training device provided in an embodiment of the present invention, the equiangular transformation module 12 can be specifically used to use a transformation matrix to map the output features of the backbone network of the second face recognition model to the feature space of the first face recognition model; wherein, the input of the transformation matrix is ​​the output of the backbone network of the second face recognition model, and the output features of the transformation matrix are features with the same dimension as the output features of the backbone network of the first face recognition model.

[0191] Furthermore, in a specific implementation, in the above-mentioned face recognition model training device provided in an embodiment of the present invention, the loss function construction module 13 may specifically include:

[0192] A first loss value constructing unit, used to construct a first loss value according to the output features of the backbone network of the first face recognition model, the output features of the backbone network of the second face recognition model and a conversion matrix;

[0193] A second loss value constructing unit, configured to construct a second loss value according to a product matrix between a transformation matrix and a transpose of the transformation matrix and an identity matrix;

[0194] The target loss function construction unit is used to construct the target loss function according to the first loss value and the second loss value.

[0195] Among them, the first loss value construction unit can be specifically used to obtain new features by isotropic transformation of the output features of the backbone network of the second face recognition model through a transformation matrix; calculate the Euclidean distance between the new features and the output features of the backbone network of the first face recognition model to construct the first loss value.

[0196] The second loss value construction unit can be specifically used to construct the first part of the second loss value under unsupervised learning by using the distance between the product matrix between the transformation matrix and the transpose of the transformation matrix and the unit matrix as the square of the F norm; calculate the sum of the squares of the non-diagonal elements of the product matrix between the transformation matrix and the transpose of the transformation matrix to construct the second part of the second loss value; linearly combine the first part of the second loss value and the second part of the second loss value to construct the second loss value; specifically, it can also be used to construct the first part of the second loss value under supervised learning by using the distance between the product matrix between the transformation matrix and the transpose of the transformation matrix and the unit matrix as the square of the F norm; calculate the sum of the squares of the non-diagonal elements of the product matrix between the transformation matrix and the transpose of the transformation matrix to construct the second part of the second loss value; calculate the classification loss function; linearly combine the first part of the second loss value, the second part of the second loss value and the classification loss function to construct the second loss value.

[0197] The target loss function construction unit can be specifically used to linearly combine the first loss value and the second loss value to construct the target loss function; wherein the second loss value includes a weight coefficient.

[0198] Furthermore, in specific implementation, in the above-mentioned face recognition model training device provided in an embodiment of the present invention, the model training module 14 can also be used to update the parameters of the second face recognition model and the transformation matrix using a stochastic gradient descent algorithm; wherein the parameters of the first face recognition model are not updated.

[0199] Figure 6 This is a structural diagram of a face recognition device provided by an embodiment of the present invention. Based on the perspective of functional modules, the device includes:

[0200] The model inference module 15 is used to input the image to be tested into the target face recognition model to obtain at least one feature output by the backbone network of the target face recognition model. The target face recognition model is trained using the above-mentioned face recognition model training method;

[0201] The similarity acquisition module 16 is used to compare the features output by the backbone network of the target face recognition model with the face features in the face recognition database to be queried, and obtain the similarity between the features output by the backbone network of the target face recognition model and the face features in the face recognition database to be queried. The face recognition database to be queried contains the face features and corresponding identity identifiers of at least one person, and each person has at least one face feature;

[0202] The recognition result output module 17 is used to select, according to the obtained similarity, the identity identifier corresponding to the facial feature with the highest similarity in the face recognition database to be queried as the face recognition result.

[0203] Since the embodiments of the face recognition device part correspond to the embodiments of the face recognition method part mentioned above, the embodiments of the face recognition device part refer to the description of the embodiments of the face recognition method part, and will not be repeated here. And the face recognition device has the same beneficial effects as the face recognition method.

[0204] Furthermore, in a specific implementation, in the above-mentioned face recognition device provided in an embodiment of the present invention, the similarity acquisition module 16 can be specifically used to compare the mean of the features output by the backbone network of the target face recognition model with the mean of the facial features of each person in the face recognition database to be queried, and obtain the cosine similarity between the mean of the features output by the backbone network of the target face recognition model and the mean of the facial features of each person in the face recognition database to be queried.

[0205] Figure 7 This is a structural diagram of an electronic device provided by an embodiment of the present invention. This embodiment is based on the hardware perspective, such as Figure 7 As shown, the electronic equipment includes:

[0206] A memory 20, for storing computer programs;

[0207] The processor 21 is used to implement the steps of the face recognition model training method mentioned in the above embodiment when executing the computer program; and / or implement the steps of the face recognition method mentioned in the above embodiment.

[0208] Among them, the processor 21 may include one or more processing cores, such as a 4-core processor, an 8-core processor, etc. The processor 21 can be implemented in at least one hardware form of a digital signal processor (DSP), a field-programmable gate array (FPGA), and a programmable logic array (PLA). The processor 21 may also include a main processor and a coprocessor. The main processor is a processor for processing data in the awake state, also known as a CPU; the coprocessor is a low-power processor for processing data in the standby state. In some embodiments, the processor 21 may be integrated with a graphics processing unit (GPU), which is responsible for rendering and drawing the content to be displayed on the display screen. In some embodiments, the processor 21 may also include an artificial intelligence (AI) processor, which is used to process computing operations related to machine learning.

[0209] The memory 20 may include one or more non-volatile storage media, which may be non-transitory. The memory 20 may also include a high-speed random access memory, and a non-volatile memory, such as one or more disk storage devices, flash memory storage devices. In this embodiment, the memory 20 is at least used to store the following computer program 201, wherein, after the computer program is loaded and executed by the processor 21, it can implement the relevant steps of the face recognition model training method disclosed in any of the aforementioned embodiments. In addition, the resources stored in the memory 20 may also include an operating system 202 and data 203, etc., and the storage method may be temporary storage or permanent storage. Among them, the operating system 202 may include Windows, Unix, Linux, etc. The data 203 may include, but is not limited to, the data involved in the above-mentioned face recognition model training method, etc.

[0210] In some embodiments, the electronic device may further include a display screen 22, an input / output interface 23, a communication interface 24, a power supply 25, and a communication bus 26. Those skilled in the art will appreciate that Figure 7 The structure shown in the figure does not constitute a limitation on the electronic device, and may include more or fewer components than shown in the figure. The electronic device provided by the embodiment of the present invention includes a memory and a processor, and when the processor executes the program stored in the memory, it can implement the following method: a face recognition model training method, the effect is the same as above.

[0211] Finally, the present invention also provides an embodiment corresponding to a non-volatile storage medium. The non-volatile storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the face recognition model training method mentioned in the above embodiment are implemented; and / or the steps of the face recognition method mentioned in the above embodiment are implemented.

[0212] It is understandable that if the method in the above embodiment is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention is essentially or part of the contribution to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium to execute all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM), random access memory (RAM), disk or optical disk, etc. Various media that can store program codes. The non-volatile storage medium provided by the present invention can implement the steps of the face recognition model training method and / or face recognition method mentioned in the above embodiments, and the effect is the same as above.

[0213] Finally, the present invention also provides an embodiment corresponding to a computer program product. The computer program product includes a computer program / instruction, and when the computer program / instruction is executed by a processor, it implements the steps of the face recognition model training method mentioned in the above embodiment; and / or, implements the steps of the face recognition method mentioned in the above embodiment. The computer program product provided by the present invention can implement the steps of the face recognition model training method and / or the face recognition method mentioned in the above embodiment, and the effect is the same as above.

[0214] It should also be noted that, in this specification, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "comprise", "include" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the statement "comprises a ..." does not exclude the presence of other identical elements in the process, method, article or device including the element.

[0215] The above is a detailed introduction to the face recognition and model training method, device, equipment, medium and product provided by the present invention. The various embodiments in the specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same and similar parts between the embodiments can be referred to each other. For the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part description. It should be pointed out that for ordinary technicians in this technical field, without departing from the principle of the present invention, the present invention can also be improved and modified in a number of ways, and these improvements and modifications also fall within the scope of protection of the present invention.

Claims

1. A face recognition model training method, characterized in that: include: Build a training dataset; The training data set includes a number of face image samples; Inputting the training data set into a trained first face recognition model and a second face recognition model to be trained respectively, obtaining output features of a backbone network of the first face recognition model and output features of a backbone network of the second face recognition model; wherein the computational complexity of the first face recognition model is greater than that of the second face recognition model; Mapping the output features of the backbone network of the second face recognition model to the feature space of the first face recognition model using a conversion matrix; wherein the input of the conversion matrix is ​​the output of the backbone network of the second face recognition model, and the output features of the conversion matrix are features with the same dimension as the output features of the backbone network of the first face recognition model; Constructing a target loss function by using a mapping of output features of the backbone network of the second face recognition model in the feature space of the first face recognition model and the output features of the backbone network of the first face recognition model; The target loss function is minimized to obtain a trained second face recognition model as the target face recognition model.

2. The face recognition model training method according to claim 1, characterized in that: Before the training data set is input into the trained first face recognition model and the second face recognition model to be trained respectively, the method further includes: Using the facial image samples with labels in the training data set to train the first facial recognition model to be trained, to obtain a trained first facial recognition model; the labels are marked according to the identity identifiers; Correspondingly, the training data set is input into the trained first face recognition model and the second face recognition model to be trained respectively, including: Under unsupervised learning, the unlabeled face image samples in the training data set are respectively input into the trained first face recognition model and the second face recognition model to be trained; or, under supervised learning, the labeled face image samples in the training data set are respectively input into the trained first face recognition model and the second face recognition model to be trained.

3. The face recognition model training method according to claim 2, characterized in that: The first face recognition model includes a backbone network; Under unsupervised learning, the second face recognition model includes a backbone network; or, under supervised learning, the second face recognition model includes a backbone network, a fully connected layer and a classification loss layer.

4. The face recognition model training method according to claim 1, characterized in that: The conversion matrix is ​​a fully connected neural network without hidden layers; The transformation matrix is ;in, , is the transformation matrix The transposed vector of Both rows and columns are dimensional identity matrix, is the output feature dimension of the backbone network of the first face recognition model, is the output feature dimension of the backbone network of the second face recognition model, for -dimensional real vector.

5. The face recognition model training method according to claim 4, characterized in that: When the output feature of the backbone network of the second face recognition model is , for When the output feature of the backbone network of the second face recognition model is a real number vector of dimension , the first formula is used to map the output feature of the backbone network of the second face recognition model to the feature space of the first face recognition model; the first formula is: ; in, A mapping of output features of the backbone network of the second face recognition model in the feature space of the first face recognition model; When the output feature of the backbone network of the first face recognition model is , for -dimensional real vector, and When the cosine similarity between the output features of the backbone network of the first face recognition model is equal to the cosine similarity between the output features of the backbone network of the second face recognition model.

6. The face recognition model training method according to claim 4, characterized in that: Using the mapping of the output features of the backbone network of the second face recognition model in the feature space of the first face recognition model and the output features of the backbone network of the first face recognition model, a target loss function is constructed, including: Constructing a first loss value according to the output features of the backbone network of the first face recognition model, the output features of the backbone network of the second face recognition model and the conversion matrix; constructing a second loss value according to a product matrix between the transformation matrix and the transpose of the transformation matrix and an identity matrix; Construct a target loss function according to the first loss value and the second loss value.

7. The face recognition model training method according to claim 6, characterized in that: Constructing a target loss function according to the first loss value and the second loss value, including: Linearly combine the first loss value and the second loss value to construct a target loss function; Wherein, the second loss value includes a weight coefficient.

8. The face recognition model training method according to claim 6, characterized in that: Constructing a first loss value according to the output features of the backbone network of the first face recognition model, the output features of the backbone network of the second face recognition model and the conversion matrix, including: The output features of the backbone network of the second face recognition model are subjected to isotropic transformation by the transformation matrix to obtain new features; The Euclidean distance between the new feature and the output feature of the backbone network of the first face recognition model is calculated to construct a first loss value.

9. The face recognition model training method according to claim 8, characterized in that: The Euclidean distance between the new feature and the output feature of the backbone network of the first face recognition model is calculated, and a first loss value is constructed using a third formula; the third formula is: ; in, is the first loss value, is the number of samples contained in each batch, , is the input face image, The input face image is is the output feature of the backbone network in the first face recognition model, represents the new feature, The input face image is is the output feature of the backbone network in the second face recognition model, Represents the 2-norm.

10. The face recognition model training method according to claim 6, characterized in that: Under unsupervised learning, constructing a second loss value according to a product matrix between the transformation matrix and the transpose of the transformation matrix and an identity matrix, including: Constructing a first part of a second loss value using the square of the F-norm between the product matrix between the transformation matrix and the transpose of the transformation matrix and the identity matrix; Calculating the sum of squares of off-diagonal elements of a product matrix between the transformation matrix and the transpose of the transformation matrix to construct a second part of a second loss value; The first part of the second loss value and the second part of the second loss value are linearly combined to construct a second loss value.

11. The face recognition model training method according to claim 6, characterized in that: Under supervised learning, constructing a second loss value according to a product matrix between the transformation matrix and the transpose of the transformation matrix and an identity matrix, including: Constructing a first part of a second loss value using the square of the F-norm between the product matrix between the transformation matrix and the transpose of the transformation matrix and the identity matrix; Calculating the sum of squares of off-diagonal elements of a product matrix between the transformation matrix and the transpose of the transformation matrix to construct a second part of a second loss value; Calculate the classification loss function; The first part of the second loss value, the second part of the second loss value, and the classification loss function are linearly combined to construct a second loss value.

12. The face recognition model training method according to claim 10 or 11, characterized in that: The distance between the product matrix between the transformation matrix and the transpose of the transformation matrix and the identity matrix is ​​the square of the F norm, and the first part of the second loss value is constructed using the fourth formula; the fourth formula is: ; in, is the first part of the second loss value, is the weight coefficient, Represents the F-norm.

13. The face recognition model training method according to claim 10 or 11, characterized in that: The sum of squares of the off-diagonal elements of the product matrix between the transformation matrix and the transpose of the transformation matrix is ​​calculated, and the second part of the second loss value is constructed using the fifth formula; the fifth formula is: ; in, is the second part of the second loss value, is the weight coefficient, represents the F-norm, Represents pixel-by-pixel matrix multiplication.

14. The face recognition model training method according to claim 11, characterized in that: The classification loss function is calculated using the sixth formula; the sixth formula is: ; in, is the classification loss function, is the number of samples contained in each batch, , represents the total number of labels of the training dataset, , is the input face image, yes The corresponding category label, The input face image is is the output feature of the backbone network in the second face recognition model, is the weight matrix of the fully connected layer of the second face recognition model, is the weight matrix of List, represent The transposed vector of is the weight matrix No. List, represent The transposed vector of Represents the dot product of two vectors.

15. The face recognition model training method according to claim 3, characterized in that: While minimizing the objective loss function, it also includes: Updating the parameters of the second face recognition model and the transformation matrix using a stochastic gradient descent algorithm; Among them, the parameters of the first face recognition model are not updated.

16. A face recognition method, characterized in that: include: Inputting the image to be tested into a target face recognition model to obtain at least one feature output by a backbone network of the target face recognition model; The target face recognition model is trained using the face recognition model training method according to any one of claims 1 to 15; Comparing the features output by the backbone network of the target face recognition model with the face features in the face recognition database to be queried, and obtaining the similarity between the features output by the backbone network of the target face recognition model and the face features in the face recognition database to be queried; the face recognition database to be queried contains the face features and corresponding identity identifiers of at least one person, and each person has at least one face feature; According to the obtained similarity, the identity identifier corresponding to the facial feature in the face recognition database to be queried with the highest similarity is selected as the face recognition result.

17. The face recognition method according to claim 16, characterized in that: Comparing the features output by the backbone network of the target face recognition model with the face features in the face recognition database to be queried, and obtaining the similarity between the features output by the backbone network of the target face recognition model and the face features in the face recognition database to be queried, including: The mean of the features output by the backbone network of the target face recognition model is compared with the mean of the facial features of each person in the face recognition database to be queried, and the cosine similarity between the mean of the features output by the backbone network of the target face recognition model and the mean of the facial features of each person in the face recognition database to be queried is obtained.

18. A face recognition model training device, characterized in that: include: Training set construction module, used to construct training data set; The training data set includes a number of face image samples; an output feature acquisition module, used to input the training data set into the trained first face recognition model and the second face recognition model to be trained, respectively, to obtain the output features of the backbone network of the first face recognition model and the output features of the backbone network of the second face recognition model; wherein the computational complexity of the first face recognition model is greater than that of the second face recognition model; An isometric transformation module, used for mapping the output features of the backbone network of the second face recognition model to the feature space of the first face recognition model using a transformation matrix; wherein the input of the transformation matrix is ​​the output of the backbone network of the second face recognition model, and the output features of the transformation matrix are features with the same dimension as the output features of the backbone network of the first face recognition model; A loss function construction module, used to construct a target loss function by using a mapping of the output features of the backbone network of the second face recognition model in the feature space of the first face recognition model and the output features of the backbone network of the first face recognition model; The model training module is used to minimize the target loss function to obtain a trained second face recognition model as the target face recognition model.

19. A face recognition device, characterized in that: include: A model inference module, used to input the image to be tested into a target face recognition model to obtain at least one feature output by a backbone network of the target face recognition model; The target face recognition model is trained using the face recognition model training method according to any one of claims 1 to 15; A similarity acquisition module is used to compare the features output by the backbone network of the target face recognition model with the face features in the face recognition database to be queried, and obtain the similarity between the features output by the backbone network of the target face recognition model and the face features in the face recognition database to be queried; the face recognition database to be queried contains the face features and corresponding identity identifiers of at least one person, and each person has at least one face feature; The recognition result output module is used to select the identity identifier corresponding to the facial feature with the highest similarity in the face recognition database to be queried as the face recognition result according to the obtained similarity.

20. An electronic device, characterized in that: include: Memory for storing computer programs; A processor, used to implement the steps of the face recognition model training method as described in any one of claims 1 to 15 when executing the computer program; and / or, implement the steps of the face recognition method as described in claim 16 or 17.

21. A non-volatile storage medium, characterized in that: The non-volatile storage medium stores a computer program, which, when executed by a processor, implements the steps of the face recognition model training method as described in any one of claims 1 to 15; and / or implements the steps of the face recognition method as described in claim 16 or 17.

22. A computer program product comprising a computer program / instructions, characterized in that When the computer program / instructions are executed by the processor, the steps of the face recognition model training method as described in any one of claims 1 to 15 are implemented; and / or, the steps of the face recognition method as described in claim 16 or 17 are implemented.

Citation Information

Patent Citations

  • Model training method, face recognition method, electronic equipment and storage medium

    CN113887538A

  • Model training method, face recognition method, device, equipment, medium and product

    CN114359993A

  • Cross-modal face recognition method, device, system and equipment and storage medium

    CN116110105A

  • Face recognition model training method, face recognition method and device

    CN116665282A

  • Face recognition model training method, face recognition method and device

    CN117011909A