Disclosure of Invention
The inventor finds that the existing fake face recognition methods all need to train a model by using a large number of samples, and the trained model can accurately recognize the fake face. When the novel class of false face images appear, the number of false face image samples is very small, and the model cannot be retrained, so that the model cannot timely identify the novel class of false faces, and the attack of the novel class of false faces cannot be effectively prevented in time.
The technical problem to be solved by the method is how to realize timely and effective identification of the novel class of fake face images and improve the safety of a face recognition system under the condition that a small number of novel class of fake face images appear.
According to some embodiments of the present disclosure, a method for recognizing a fake face is provided, which includes obtaining a small sample set of a new type of fake face image, updating parameters of a pre-trained face anti-fake model by using the small sample set of the new type of fake face image, wherein the parameters of the pre-trained face anti-fake model are multiple groups of parameters of the face anti-fake model determined according to multiple tasks respectively, and are redetermined according to the multiple groups of parameters, the tasks include one or more small sample sets formed by the existing type of fake face image and a real face image, inputting the face image to be recognized into the updated face anti-fake model, and determining whether the face image to be recognized is a fake face image.
In some embodiments, updating parameters of the face anti-counterfeiting model by using a small sample set of the new class of false face images comprises updating the parameters of the face anti-counterfeiting model according to the false face images in the small sample set of the new class and corresponding fine classification labels when the face anti-counterfeiting model is a classification model, or updating the parameters of the face anti-counterfeiting model according to the false face images in the small sample set of the new class and corresponding coarse classification labels when the face anti-counterfeiting model is a regression model, wherein the fine classification labels are used for labeling the class of the false face images, and the coarse classification labels are used for labeling the false face images as positive samples or negative samples.
In some embodiments, updating the parameters of the face anti-counterfeiting model according to the fake face image in the new class of small sample set and the corresponding fine classification label when the face anti-counterfeiting model is the classification model comprises inputting the fake face image in the new class of small sample set into the face anti-counterfeiting model to obtain probabilities that the fake face images respectively belong to different classes, determining a first gradient according to the probabilities that the fake face images respectively belong to different classes and the corresponding fine classification label, and updating the parameters of the face anti-counterfeiting model according to the first gradient, or updating the parameters of the face anti-counterfeiting model according to the fake face image in the new class of small sample set and the corresponding coarse classification label when the face anti-counterfeiting model is the regression model, wherein the step of inputting the fake face image in the new class of small sample set into the face anti-counterfeiting model to obtain corresponding output values of the fake face images and determining the second gradient according to the corresponding output values of the fake face images and the corresponding coarse classification label when the face anti-counterfeiting model is the regression model.
In some embodiments, the method further comprises dividing the existing classified fake face image and the real face image into a plurality of tasks, wherein each task comprises a real face image class and a first preset number of existing classes, each class comprises a small sample set formed by a second preset number of support sample images and a third preset number of inquiry sample images, each task of a fourth preset number is selected to form a batch, the batch is input into the face anti-counterfeiting model, multiple groups of parameters of the face anti-counterfeiting model are respectively determined according to the multiple tasks of the batch, the parameters of the face anti-counterfeiting model are redetermined according to the multiple groups of parameters, and the pre-training of the face anti-counterfeiting model is completed until the face anti-counterfeiting model reaches a convergence condition.
In some embodiments, determining multiple groups of parameters of the face anti-counterfeiting model according to multiple tasks of the batch respectively, and redefining parameters of the face anti-counterfeiting model according to the multiple groups of parameters comprises determining a third gradient corresponding to each task in the batch according to the support sample image and the corresponding label, determining a group of parameters of the face anti-counterfeiting model according to the third gradient, determining multiple groups of parameters according to multiple tasks in the batch respectively, querying sample images and labels corresponding to the query sample images of the multiple tasks, determining a fourth gradient corresponding to the batch, and redefining parameters of the face anti-counterfeiting model according to the fourth gradient corresponding to the batch.
In some embodiments, for each task in the batch, determining the third gradient corresponding to the task according to the support sample image and the corresponding label includes determining, for each task in the batch, the third gradient corresponding to the task according to the support sample image and the corresponding fine classification label if the face anti-counterfeiting model is a classification model, or determining, for each task in the batch, the third gradient corresponding to the task according to the support sample image and the corresponding coarse classification label if the face anti-counterfeiting model is a regression model, wherein the fine classification label is used for labeling the class of the counterfeit face image and the coarse classification label is used for labeling the counterfeit face image as a positive sample or a negative sample.
In some embodiments, the initial parameters of the face anti-counterfeiting model prior to pre-training are determined according to a deep learning training method.
In some embodiments, the existing class comprises at least one of a photo class, a video class and a mask class, the existing class of fake face images comprises existing class fake face images of at least one of a depth mode, a near infrared mode and a red, green and blue (RGB) mode, the real face images comprise real face images of at least one of a depth mode, a near infrared mode and a red, green and blue (RGB) mode, and the mode of the new class fake face images is different from the mode of the existing class fake face images and the real face images.
According to other embodiments of the present disclosure, a recognition device for a fake face is provided, which includes a small sample acquiring module configured to acquire a small sample set of a new type of fake face image, and a model adjusting module configured to update parameters of a pre-trained face anti-fake model by using the small sample set of the new type of fake face image, where the parameters of the pre-trained face anti-fake model are respectively determined according to a plurality of tasks and are redetermined according to the plurality of sets of parameters, the tasks include one or more small sample sets formed by an existing type of fake face image and a real face image, and the face recognition module is configured to input the face image to be recognized into the updated face anti-fake model, and determine whether the face image to be recognized is a fake face image.
In some embodiments, the model adjustment module is configured to update parameters of the face anti-counterfeiting model according to a fake face image in a new class of small sample set and a corresponding fine classification label when the face anti-counterfeiting model is a classification model, or update parameters of the face anti-counterfeiting model according to a fake face image in a new class of small sample set and a corresponding coarse classification label when the face anti-counterfeiting model is a regression model, wherein the fine classification label is used for labeling a class of the fake face image, and the coarse classification label is used for labeling whether the fake face image is a positive sample or a negative sample.
In some embodiments, the model adjustment module is configured to input the false face images in the small sample set of the new class into the face anti-counterfeiting model to obtain probabilities that the false face images belong to different classes respectively when the face anti-counterfeiting model is a classification model, determine a first gradient according to the probabilities that the false face images belong to different classes respectively and the corresponding fine classification labels, and update parameters of the face anti-counterfeiting model according to the first gradient, or input the false face images in the small sample set of the new class into the face anti-counterfeiting model to obtain output values corresponding to the false face images when the face anti-counterfeiting model is a regression model, determine a second gradient according to the output values corresponding to the false face images and the corresponding coarse classification labels, and update parameters of the face anti-counterfeiting model according to the second gradient.
In some embodiments, the device further comprises a pre-training module for dividing the existing classified fake face image and the real face image into a plurality of tasks, wherein each task comprises a real face image class and a first preset number of existing classes, each class comprises a small sample set formed by a second preset number of support sample images and a third preset number of inquiry sample images, each task of a fourth preset number is selected to form a batch, the batch is input into the face anti-counterfeiting model, multiple groups of parameters of the face anti-counterfeiting model are respectively determined according to the multiple tasks of the batch, the parameters of the face anti-counterfeiting model are redetermined according to the multiple groups of parameters, and the pre-training of the face anti-counterfeiting model is completed until the face anti-counterfeiting model reaches a convergence condition.
In some embodiments, the pre-training module is configured to determine, for each task in a batch, a third gradient corresponding to the task according to the support sample image and the corresponding label, determine a set of parameters of the face anti-counterfeiting model according to the third gradient, determine a plurality of sets of parameters according to a plurality of tasks in the batch, determine a fourth gradient corresponding to the batch according to the query sample image and the label corresponding to the query sample image of the plurality of tasks, and redetermine parameters of the face anti-counterfeiting model according to the fourth gradient corresponding to the batch.
In some embodiments, the pre-training module is configured to determine, for each task in the batch, a third gradient corresponding to the task according to the support sample image and a corresponding fine classification label if the face anti-counterfeiting model is a classification model, or determine, for each task in the batch, a third gradient corresponding to the task according to the support sample image and a corresponding coarse classification label if the face anti-counterfeiting model is a regression model, wherein the fine classification label is used for labeling a class of a fake face image, and the coarse classification label is used for labeling whether the fake face image is a positive sample or a negative sample.
In some embodiments, the initial parameters of the face anti-counterfeiting model prior to pre-training are determined according to a deep learning training method.
In some embodiments, the existing class comprises at least one of a photo class, a video class and a mask class, the existing class of fake face images comprises existing class fake face images of at least one of a depth mode, a near infrared mode and a red, green and blue (RGB) mode, the real face images comprise real face images of at least one of a depth mode, a near infrared mode and a red, green and blue (RGB) mode, and the mode of the new class fake face images is different from the mode of the existing class fake face images and the real face images.
According to still further embodiments of the present disclosure, there is provided a fake face recognition apparatus including a memory, and a processor coupled to the memory, the processor configured to perform the steps of the fake face recognition method of any of the previous embodiments based on instructions stored in the memory.
According to still further embodiments of the present disclosure, a computer-readable storage medium is provided, on which a computer program is stored, wherein the program, when executed by a processor, implements the steps of the fake face recognition method of any of the previous embodiments.
In the method, the parameters of the pre-trained face anti-counterfeiting model are updated by directly utilizing the small sample set of the new-class fake face images, and the updated face anti-counterfeiting model can identify various fake face images of the existing class and the new class. The pre-trained face anti-counterfeiting model is trained by using one or more small sample sets consisting of the existing class of fake face images and real face images, a plurality of tasks respectively determine a plurality of groups of parameters of the face anti-counterfeiting model in the training process, and then the parameters of the face anti-counterfeiting model are redetermined according to the plurality of groups of parameters. The training process comprises two stages, namely a stage of training a human face anti-counterfeiting model by utilizing a plurality of small sample sets of the existing class of false human face images and real human face images respectively, wherein the stage is a stage of learning the characteristics of the small sample sets or a stage of learning and identifying the false human face and the real human face, and a stage of updating parameters of the human face anti-counterfeiting model again according to a plurality of training results in a summarizing way, wherein the stage is a stage of learning the characteristics of the small sample sets or a stage of learning and identifying the false human face and the real human face.
Therefore, after the human face anti-counterfeiting model learns a plurality of tasks of a small sample set containing the existing class of fake human face images and real human face images, a method for learning the small sample set is mastered, or a method for learning and identifying the fake human face and the real human face or learning and searching fake clues is mastered, and good initialization parameters are obtained. When the novel class of false face images are in a small sample set, the face anti-counterfeiting model is updated, and the novel class of false face features can be quickly learned due to the quick learning ability of the prior learning, so that the novel class of false face images can be effectively updated timely, the novel class of false face images can be effectively identified timely, and attacks of the novel class of false faces can be effectively defended timely.
Other features of the present disclosure and its advantages will become apparent from the following detailed description of exemplary embodiments of the disclosure, which proceeds with reference to the accompanying drawings.
Detailed Description
The following description of the technical solutions in the embodiments of the present disclosure will be made clearly and completely with reference to the accompanying drawings in the embodiments of the present disclosure, and it is apparent that the described embodiments are only some embodiments of the present disclosure, not all embodiments. The following description of at least one exemplary embodiment is merely illustrative in nature and is in no way intended to limit the disclosure, its application, or uses. Based on the embodiments in this disclosure, all other embodiments that a person of ordinary skill in the art would obtain without making any inventive effort are within the scope of protection of this disclosure.
The scheme is provided for solving the problems that when the novel class of fake face images appear and the number of samples is very small, the model cannot be used for timely and effectively identifying the novel class of fake faces and the attack of the novel class of fake faces cannot be timely and effectively prevented. Some embodiments of the identification method of counterfeit faces of the present disclosure are described below in conjunction with fig. 1.
Fig. 1 is a flow chart of some embodiments of a method of recognizing a counterfeit face of the present disclosure. As shown in FIG. 1, the method of the embodiment includes steps S102-S106.
In step S102, a small sample set of counterfeit face images of a new class is acquired.
The number of images in a small sample set in the present disclosure is less than a threshold, e.g., 10. The threshold value enables the human face anti-counterfeiting model to be updated by adopting a small sample set according to the training method of deep learning, the model can not be converged, the new type of false human face image is different from the type of the false human face image used in the process of pre-training the human face anti-counterfeiting model, and the type of the false human face image used in the process of pre-training the human face anti-counterfeiting model can be called as the existing type. For example, the existing categories include at least one of photo category, video category, mask category. The new class may then be a fake face of another class.
In step 104, parameters of the pre-trained face anti-counterfeiting model are updated with a small sample set of new classes of counterfeited face images. The parameters of the pre-trained face anti-counterfeiting model are respectively determined according to a plurality of tasks, and are redetermined according to the plurality of groups of parameters, wherein the tasks comprise one or more small sample sets formed by the existing type of fake face images and real face images.
The false face image in the new class of small sample set can be input into the pre-trained face anti-counterfeiting model, the gradient of the parameters of the face anti-counterfeiting model is determined according to the output result, the label corresponding to the false face image and the preset loss function, and the parameters of the pre-trained face anti-counterfeiting model are updated according to the gradient. In the case that the face anti-counterfeiting model is a classification model, the preset loss function may employ an MSE (mean square error) loss function. In the case that the face anti-counterfeiting model is a regression model, the preset loss function may be a cross entropy loss function, which is not limited to the illustrated example. The method for updating the parameters of the pre-trained face anti-counterfeiting model according to the gradient can select the existing gradient descent method according to the requirement, and will not be described in detail here.
A task may be constructed from a small sample set of new class of counterfeited face images, and the counterfeited face images in the small sample set of new class are used as support sample images for the task, similar to the setting form of the task in the pretraining method of the face counterfeiting model to be described later, which will be described later in detail. One or more different new categories may be included in the task, each new category having a corresponding small sample set. A small sample set of real face images, etc. may also be included in the task.
In some embodiments, the face anti-counterfeiting model may adopt a classification model, and parameters of the face anti-counterfeiting model may be updated according to the forged face image in the new class of small sample set and the corresponding fine classification label. The fine classification labels are used for labeling the types of the fake face images. For example, the fine classification label of a real face image is 0, the fine classification label of a fake face image of a mask class is 1, and the fine classification label of a new class is 2.
In the process of updating parameters of the face anti-counterfeiting model, the fine classification labels can be adopted to calculate loss function values, gradient values and the like, so that the accuracy of the model can be improved. When the face anti-counterfeiting model classifies and outputs the image, the image can be divided into two categories, namely a real face image and a fake face image. In the testing process after the face anti-counterfeiting model is pre-trained, the rough classification labels can be utilized to test the false or real accuracy of the face anti-counterfeiting model identification image. The rough classification labels are used for labeling the forged face image as a positive sample or a negative sample. For example, the rough classification label indicating a counterfeit face image is 0, and the rough classification label indicating a genuine face image is 1.
Further, under the condition that the face anti-counterfeiting model is a classification model, the false face images in the small sample set of the new class are input into the face anti-counterfeiting model, the probability that each false face image belongs to different classes is obtained, a first gradient is determined according to the probability that each false face image belongs to different classes and the corresponding fine classification label, and parameters of the face anti-counterfeiting model are updated according to the first gradient.
In some embodiments, the face anti-counterfeiting model may adopt a regression model, and parameters of the face anti-counterfeiting model may be updated according to the fake face image in the new class small sample set and the corresponding rough class label. The regression model outputs a value for the input image, and a corresponding threshold value can be set, if the value is higher than the threshold value, the image is represented as a real face image, and if the value is lower than the threshold value, the image is represented as a fake face image. Thus, a coarse classification label of the image may be employed in the regression model.
Further, under the condition that the face anti-counterfeiting model is a regression model, the false face images in the new class of small sample set are input into the face anti-counterfeiting model to obtain output values corresponding to the false face images, a second gradient is determined according to the output values corresponding to the false face images and the corresponding rough classification labels, and parameters of the face anti-counterfeiting model are updated according to the second gradient.
The parameters of the pre-trained face anti-counterfeiting model are obtained by training by respectively determining multiple groups of parameters of the face anti-counterfeiting model according to multiple tasks and then redetermining the parameters of the face anti-counterfeiting model according to the multiple groups of parameters. The task includes one or more small sample sets of existing classes of counterfeit face images and real face images. That is, small sample sets composed of existing fake face images and real face images are distributed to a plurality of tasks, different small sample sets are used for training the face anti-fake model, but parameters of the face anti-fake model are redetermined according to a plurality of training results after training. The process of training the human face anti-counterfeiting model by different small sample sets is a model learning process, and the process of redetermining parameters according to a plurality of training results is a model learning process.
Through two processes, the model learns not only the characteristics of the small sample set, but also the method how to learn the characteristics of the small sample set, or the human face anti-counterfeiting model finally learns how to learn and identify the fake human face and the real human face, and learns how to learn and look for fake clues, instead of only learning how to identify the fake human face and the real human face, or only learning fake clues. Therefore, when the novel class of fake face images are small sample sets, the face fake model can be quickly converged, and the novel class of fake face features can be quickly learned, so that effective and timely defense is performed.
In step S106, the face image to be recognized is input into the updated face anti-fake model, and it is determined whether the face image to be recognized is a fake face image.
The face image to be identified can be a new type or a fake face image of a known type, and can be identified by the face anti-fake model.
According to the method, the parameters of the pre-trained face anti-counterfeiting model are updated directly by using the small sample set of the new type of forged face image, and the updated face anti-counterfeiting model can identify various forged face images of the existing type and the new type. The pre-trained face anti-counterfeiting model is trained by using one or more small sample sets consisting of the existing class of fake face images and real face images, a plurality of tasks respectively determine a plurality of groups of parameters of the face anti-counterfeiting model in the training process, and then the parameters of the face anti-counterfeiting model are redetermined according to the plurality of groups of parameters. The training process comprises two stages, namely a stage of training a human face anti-counterfeiting model by utilizing a plurality of small sample sets of the existing class of false human face images and real human face images respectively, wherein the stage is a stage of learning the characteristics of the small sample sets or a stage of learning and identifying the false human face and the real human face, and a stage of updating parameters of the human face anti-counterfeiting model again according to a plurality of training results in a summarizing way, wherein the stage is a stage of learning the characteristics of the small sample sets or a stage of learning and identifying the false human face and the real human face.
Therefore, after the human face anti-counterfeiting model learns a plurality of tasks of a small sample set containing the existing class of fake human face images and real human face images, a method for learning the small sample set is mastered, or a method for learning and identifying the fake human face and the real human face or learning and searching fake clues is mastered, and good initialization parameters are obtained. When the novel class of false face images are in a small sample set, the face anti-counterfeiting model is updated, and the novel class of false face features can be quickly learned due to the quick learning ability of the prior learning, so that the novel class of false face images can be effectively updated timely, the novel class of false face images can be effectively identified timely, and attacks of the novel class of false faces can be effectively defended timely.
Further embodiments of the identification method of counterfeit faces of the present disclosure are described below in conjunction with fig. 2. The embodiment comprises a pre-training method, a using method and the like of the face anti-counterfeiting model.
Fig. 2 is a flowchart of other embodiments of a method for recognizing a fake face according to the present disclosure. As shown in FIG. 2, the method of this embodiment includes steps S202-S214.
In step S202, the face anti-counterfeiting model is initially trained according to the training method of deep learning by using the existing class of fake face images and real face images, and initial parameters of the face anti-counterfeiting model before pre-training are determined.
The training method comprises the steps of firstly adopting the existing deep learning training method to perform initial training on the face anti-counterfeiting model, and then performing a subsequent pre-training process, so that the face anti-counterfeiting model has good discriminant and generalization after double training. Because the training method of deep learning enables the face anti-counterfeiting model to judge the image more accurately, the pre-training method in the present disclosure can generalize the model in different types of fake face images. After the human face anti-counterfeiting model is trained twice, the human face anti-counterfeiting model can be rapidly adapted to new tasks, and has good discrimination capability on known tasks or similar tasks.
In step S204, the forged face image and the real face image of the existing category are divided into a plurality of tasks, wherein each task includes a real face image category and a first preset number of existing categories, and each category includes a small sample set composed of a second preset number of supporting sample images and a third preset number of inquiry sample images.
One Task (Task) includes multiple categories (which may also be referred to as paths (Way)) including both a real face image category and one or more existing categories. Each category includes a second preset number of Support (Support) sample images and a third preset number of Query (Query) sample images. The support sample images form a small sample set, i.e. the support sample images for each category in each task are smaller than a threshold, e.g. 10. The number of images in the small sample set that support the formation of sample images during the pre-training process may be the same or different than the number of images in the new class of small sample set. Under the condition that the number of images in the small sample set formed by the support sample images in the pre-training process is smaller than or equal to the number of images in the small sample set of the new class, the recognition effect of the model is better after the human face anti-counterfeiting model is updated according to the small sample set of the new class. The method is characterized in that the pre-training process of the human face anti-counterfeiting model learns how to learn a smaller amount of samples, and the parameter updating of the model can be completed better when the number of images of a new class is larger during updating.
The first preset number of existing categories can be randomly selected each time, then the second preset number of support sample images and the third preset number of inquiry sample images are randomly extracted from the forged face images and the real face images which are selected from the existing categories respectively, a task is generated, and the images in different tasks cannot be completely identical.
In step S206, a fourth preset number of tasks are selected to form a batch, the batch is input into the face anti-counterfeiting model, multiple groups of parameters of the face anti-counterfeiting model are respectively determined according to the multiple tasks of the batch, and the parameters of the face anti-counterfeiting model are redetermined according to the multiple groups of parameters.
The fourth predetermined number of tasks may be randomly selected as a Batch (Batch), e.g., 5 tasks are selected as a Batch. The parameters of the face anti-counterfeiting model are updated twice for each batch. The first updating is to update parameters of the face anti-counterfeiting model by using supporting sample images in each task. And the second updating is to update the parameters of the face anti-counterfeiting model by using the query sample set in each task. I.e. the aforementioned learning process, and the "learn how to learn". Different from the existing deep learning method, each batch is directly input into a model to update parameters once.
In some embodiments, for each task in the batch, a third gradient (first gradient update) corresponding to the task is determined from the support sample image and the corresponding label, and a set of parameters of the face anti-counterfeiting model is determined from the third gradient. The multiple groups of parameters determined by the tasks belong to intermediate parameters, so that the parameters of the face anti-counterfeiting model cannot be truly updated and can be stored for next updating. Further, a plurality of groups of parameters are respectively determined according to a plurality of tasks in the batch, query sample images of the plurality of tasks and labels corresponding to the query sample images are determined, and a fourth gradient (second gradient update) corresponding to the batch is determined. And re-determining parameters of the face anti-counterfeiting model according to the fourth gradient corresponding to the batch. The parameters of the face anti-counterfeiting model determined for the second time are used for updating the parameters of the face anti-counterfeiting model.
For example, a plurality of tasks τi e T in one lot, i being a positive integer representing a task number, T being a task set of one lot. For each task taui, calculating a third gradient of the parameters of the face anti-counterfeiting model corresponding to the taskΘ represents the current parameters of the face anti-counterfeiting model,Representing a loss function calculated with support sample images for task τiGradient with respect to the current parameter θ. The parameters of the face anti-counterfeiting model determined for the task τi can be expressed asAlpha represents a first step size. Multiple tasks in a batch may determine multiple θ 'i (which may be a matrix of weight parameters) and multiple θ'i are stored.
Further, determining for a lot a fourth gradient corresponding to the lot may be expressed asMeaning that the losses of multiple tasks for the batch are summed prior to the gradient. The loss and fourth gradient are calculated from the query sample image of task τi and the corresponding θ'i. Updating parameters of face anti-counterfeiting model for the batchBeta is the second step size. It can be seen that θ'i belongs to the intermediate variable used to calculate the fourth gradient, and that the parameters of the model are updated for each batch based on θ at the start of the batch. The query sample image is utilized to update the human face anti-counterfeiting model, so that the generalization capability of the model on tasks can be enhanced, and the support sample image is prevented from being overfitted.
And under the condition that the human face anti-counterfeiting model is a classification model, determining a third gradient corresponding to each task in the batch according to the support sample image and the corresponding fine classification label. Or under the condition that the face anti-counterfeiting model is a regression model, determining a third gradient corresponding to each task in the batch according to the support sample image and the corresponding rough classification label.
In step S208, it is determined whether the face anti-counterfeiting model reaches the convergence condition, if so, the pre-training of the face anti-counterfeiting model is performed, otherwise, the step S206 is returned to restart the execution.
The convergence condition is, for example, that the loss function value reaches the minimum or reaches a preset loss function value, etc. If the loss function value does not meet the convergence condition, the step S206 can be returned to select a batch again, and training of the face anti-counterfeiting model is performed.
The steps belong to the pre-training process of the face anti-counterfeiting model. It should be noted that although the number of the supported sample images of each category in each task is very small, a large number of samples (including a large number of sample images of the existing category and the real face category) are used in the whole pre-training process, and the larger the number of samples is, the better the model is, and only a plurality of tasks and a plurality of small sample sets are divided, so that the model can learn how to learn in the pre-training process, and the accuracy of the model is improved.
In step S210, a small sample set of counterfeit face images of a new class is acquired.
A small sample set of new classes of counterfeited face images can be used as a supporting sample image in one task. A task may include one or more new categories, each corresponding to a small sample set.
In step S212, parameters of the pre-trained face anti-counterfeiting model are updated with a small sample set of new classes of counterfeited face images.
The method of updating the parameters of the pre-trained face anti-counterfeiting model using the small sample set of the new class of counterfeit face images is similar to the process of determining the parameters θ'i of the face anti-counterfeiting model using the supporting sample image of one task τi in step S206. For example, a small sample set of a new class of fake face images is used as a support sample set of the task τj, and a third gradient of the parameters of the face anti-counterfeiting model corresponding to the task τj is calculatedThe parameters of the face anti-counterfeiting model determined for the task τj can be expressed asAlpha represents a first step size. The updated face anti-counterfeiting model has a parameter of theta'j. The process of updating with the query sample image is no longer performed.
In step S214, the face image to be recognized is input into the updated face anti-counterfeiting model, and it is determined whether the face image to be recognized is a fake face image.
The scheme disclosed by the invention not only can be used for identifying the forged face images of new types, but also can be used for identifying the forged face images of new modes. When the face anti-counterfeiting model is pre-trained, the task can comprise fake face images and real face images of the existing modes, such as a Depth mode, a Near Infrared (NIR) mode and a red, green and blue (RGB) mode.
In some embodiments, a small sample set of counterfeit face images of a new modality is acquired. And updating parameters of the pre-trained face anti-counterfeiting model by using a small sample set of the fake face image of the new mode. The parameters of the pre-trained face anti-counterfeiting model are respectively determined according to a plurality of tasks, and are redetermined according to the plurality of groups of parameters, wherein the tasks comprise one or more small sample sets formed by the fake face image of the existing mode and the real face image of the existing mode, the face image to be identified is input into the updated face anti-counterfeiting model, and whether the face image to be identified is the fake face image is determined.
The forged face image of the new modality may be the same or different in category as the forged face image of the existing modality, for example, a forged face image of the new modality and of a new category. The pre-training process is similar to that in the previous embodiment. In the pre-training process, one task can comprise a real face image category and a first preset number of existing categories, wherein each category comprises a small sample set formed by a second preset number of support sample images and a third preset number of inquiry sample images. The real face image and the counterfeit face image may belong to a fifth preset number of modalities. For example, there are three known modalities, three known classes and real class face images, and a maximum of twelve small sample sets may be included in a task generated. Of course, a task may also include a real face class and an existing class, each class corresponding to images of multiple existing modalities, and the new small sample set includes images of the same existing class as the small sample set in the pre-training process but belonging to the new modality.
In the above embodiment, the pre-trained face anti-counterfeiting model is trained by using one or more small sample sets formed by the forged face image and the real face image of the existing mode, and a plurality of tasks respectively determine a plurality of groups of parameters of the face anti-counterfeiting model in the training process, and then redetermine the parameters of the face anti-counterfeiting model according to the plurality of groups of parameters. The training process comprises two stages, namely a stage of training a human face anti-counterfeiting model by utilizing a plurality of small sample sets of the existing class of false human face images and real human face images respectively, wherein the stage is a stage of learning the characteristics of the small sample sets, or a stage of learning and identifying the false human faces and the real human faces in different modes, and a stage of updating parameters of the human face anti-counterfeiting model again according to a plurality of training results in a summarizing way, namely a stage of learning how the model learns the characteristics of the small sample sets, or a stage of learning and identifying the false human faces and the real human faces in different modes.
Therefore, the human face anti-counterfeiting model is pre-trained, so that a method for learning a small sample set is mastered, or a method for learning and identifying the fake human face and the real human face in different modes is mastered, and good initialization parameters are obtained. When the fake face image of the new mode is a small sample set, the fake face model is updated, and the fake face model can be quickly converged due to the quick learning capability learned before, so that the fake face characteristic of the new mode can be quickly learned, the fake face model can be timely and effectively updated, the fake face image of the new mode can be timely and effectively identified, and attack of the fake face of the new mode can be timely and effectively defended.
The present disclosure also provides a counterfeit face recognition device, described below in conjunction with fig. 3.
Fig. 3 is a block diagram of some embodiments of a face-counterfeit identification device of the present disclosure. As shown in fig. 3, the apparatus 30 of this embodiment includes a small sample acquisition module 302, a model adjustment module 304, and a face recognition module 306.
A small sample acquiring module 302, configured to acquire a small sample set of the new class of forged face images.
The model adjustment module 304 is configured to update parameters of the pre-trained face anti-counterfeiting model by using a small sample set of new types of fake face images, where the parameters of the pre-trained face anti-counterfeiting model are respectively determined according to a plurality of tasks, and redetermined according to the plurality of groups of parameters, and the tasks include one or more small sample sets formed by the existing types of fake face images and real face images.
In some embodiments, the model adjustment module 304 is configured to update parameters of the face anti-counterfeiting model according to the fake face image in the new class of small sample set and the corresponding fine classification label in case the face anti-counterfeiting model is a classification model, or update parameters of the face anti-counterfeiting model according to the fake face image in the new class of small sample set and the corresponding coarse classification label in case the face anti-counterfeiting model is a regression model. The fine classification labels are used for labeling the types of the fake face images, and the coarse classification labels are used for labeling whether the fake face images are positive samples or negative samples.
In some embodiments, the model adjustment module 304 is configured to input the false face images in the new class of small sample set into the face anti-counterfeiting model to obtain probabilities that the false face images belong to different classes respectively when the face anti-counterfeiting model is a classification model, determine a first gradient according to the probabilities that the false face images belong to different classes respectively and corresponding fine classification labels, and update parameters of the face anti-counterfeiting model according to the first gradient, or input the false face images in the new class of small sample set into the face anti-counterfeiting model to obtain output values corresponding to the false face images when the face anti-counterfeiting model is a regression model, determine a second gradient according to the output values corresponding to the false face images and corresponding coarse classification labels, and update parameters of the face anti-counterfeiting model according to the second gradient.
The face recognition module 306 is configured to input the face image to be recognized into the updated face anti-counterfeiting model, and determine whether the face image to be recognized is a fake face image.
In some embodiments, the apparatus 30 further includes a pre-training module 308. The pre-training module 308 is configured to divide the existing type of fake face image and the real face image into a plurality of tasks, where each task includes a real face image type and a first preset number of existing types, each type includes a small sample set formed by a second preset number of supporting sample images and a third preset number of querying sample images, select a fourth preset number of tasks each time to form a batch, input the batch into the face anti-counterfeiting model, respectively determine a plurality of groups of parameters of the face anti-counterfeiting model according to the plurality of tasks of the batch, and redetermine the parameters of the face anti-counterfeiting model according to the plurality of groups of parameters until the face anti-counterfeiting model reaches a convergence condition, and complete pre-training of the face anti-counterfeiting model.
In some embodiments, the pre-training module 308 is configured to determine, for each task in a batch, a third gradient corresponding to the task according to the support sample image and the corresponding label, determine a set of parameters of the face anti-counterfeiting model according to the third gradient, determine a plurality of sets of parameters according to a plurality of tasks in the batch, determine a fourth gradient corresponding to the batch according to the query sample image and the label corresponding to the query sample image of the plurality of tasks, and redetermine parameters of the face anti-counterfeiting model according to the fourth gradient corresponding to the batch.
In some embodiments, the pre-training module 308 is configured to determine, for each task in the batch, a third gradient corresponding to the task according to the support sample image and the corresponding fine classification label if the face anti-counterfeiting model is a classification model, or determine, for each task in the batch, a third gradient corresponding to the task according to the support sample image and the corresponding coarse classification label if the face anti-counterfeiting model is a regression model. The fine classification labels are used for labeling the types of the fake face images, and the coarse classification labels are used for labeling whether the fake face images are positive samples or negative samples.
In some embodiments, the initial parameters of the face anti-counterfeiting model prior to pre-training are determined according to a deep learning training method.
In some embodiments, the existing categories include at least one of photo categories, video categories, mask categories. The forged face image of the existing category comprises forged face images of the existing category of at least one of a depth mode, a near infrared mode and a red, green and blue (RGB) mode. The real face image comprises a real face image of at least one of a depth mode, a near infrared mode and a red, green and blue (RGB) mode. The mode of the fake face image of the new category is different from the mode of the fake face image and the real face image of the existing category.
The identification means of counterfeited faces in embodiments of the present disclosure may each be implemented by various computing devices or computer systems, as described below in connection with fig. 4 and 5.
Fig. 4 is a block diagram of some embodiments of a face-counterfeit identification device of the present disclosure. As shown in fig. 4, the apparatus 40 of this embodiment includes a memory 410 and a processor 420 coupled to the memory 410, the processor 420 being configured to perform the method of recognizing a fake face in any of the embodiments of the present disclosure based on instructions stored in the memory 410.
The memory 410 may include, for example, system memory, fixed nonvolatile storage media, and the like. The system memory stores, for example, an operating system, application programs, boot Loader (Boot Loader), database, and other programs.
Fig. 5 is a block diagram of other embodiments of a face counterfeit identification device of the present disclosure. As shown in FIG. 5, the apparatus 50 of this embodiment includes a memory 510 and a processor 520, similar to the memory 410 and the processor 420, respectively. Input/output interface 530, network interface 540, storage interface 550, and the like may also be included. These interfaces 530,540,550 and the memory 510 and processor 520 may be connected by, for example, a bus 560. The input/output interface 530 provides a connection interface for input/output devices such as a display, a mouse, a keyboard, a touch screen, etc. The network interface 540 provides a connection interface for various networking devices, such as may be connected to a database server or cloud storage server, or the like. The storage interface 550 provides a connection interface for external storage devices such as SD cards, U discs, and the like.
It will be appreciated by those skilled in the art that embodiments of the present disclosure may be provided as a method, system, or computer program product. Accordingly, the present disclosure may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present disclosure may take the form of a computer program product embodied on one or more computer-usable non-transitory storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) having computer-usable program code embodied therein.
The present disclosure is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the disclosure. It will be understood that each flowchart and/or block of the flowchart illustrations and/or block diagrams, and combinations of flowcharts and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
The foregoing description of the preferred embodiments of the present disclosure is not intended to limit the disclosure, but rather to enable any modification, equivalent replacement, improvement or the like, which fall within the spirit and principles of the present disclosure.