Face anti-counterfeiting recognition method and device
The generator generates face interference images with the same category, same semantics and external distribution as the original face image, which solves the problems of high face anti-counterfeiting recognition training cost and high error rate in the existing technology, and improves the recognition accuracy.
Patent Information
- Application Number
- CN202311714485.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-12-13
- Publication Date
- 2024-09-03
- Estimated Expiration
- 2043-12-13
AI Technical Summary
Existing face anti-counterfeiting recognition methods have high training costs and high error rates, and are difficult to effectively distinguish between different types of attacks, resulting in low recognition accuracy.
The interference image is generated through the generator, and the clustering contrast loss value, category loss value and semantic loss value are used to adjust the weight, and a face interference image with the same category, same semantics and outer distribution as the original face image is generated to improve classifier training. The diversity of samples reduces training costs and improves recognition accuracy.
On the basis of face images in the source domain, it is possible to proactively intervene in fraud-irrelevant factors, eliminate false correlations, learn generalized causal features, reduce training costs, and improve face anti-counterfeiting recognition accuracy.
Smart Images

Figure CN117854159B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of image processing technology, and in particular to a face anti-counterfeiting recognition method and device. Background Art
[0002] Face anti-counterfeiting recognition technology is used to protect the security of face recognition model systems. It aims to further distinguish the type of attack presented by the prosthesis when the face recognition system verifies that the face is a prosthesis.
[0003] Most existing face anti-counterfeiting recognition methods learn manual features or deep features through feature description or deep learning networks. However, current face anti-counterfeiting recognition methods require multiple source domain images to train a generalized face anti-counterfeiting recognition model, and most of them train unknown attack detection based on the premise that the training set and the test set have similar data distribution, which leads to high training costs and high error rates of face anti-counterfeiting recognition. Summary of the invention
[0004] The present invention provides a face anti-counterfeiting recognition method and device, which are used to solve the defects of high training cost and high error rate of face anti-counterfeiting recognition in the prior art, thereby reducing the training cost and improving the recognition accuracy.
[0005] The present invention provides a face anti-counterfeiting recognition method, comprising:
[0006] Based on a generator, generating an interference image of a first face image sample, the generator adjusting weights based on a clustering contrast loss value, a category loss value, and a semantic loss value between a second face image sample and the interference image of the second face image sample, the interference image of the second face image sample being generated based on the generator;
[0007] Training a classifier based on the first face image sample, the interference image of the first face image sample, and the face forgery type label of the first face image sample;
[0008] Based on the trained classifier, a predicted value of the face forgery type of the target face image is determined.
[0009] According to a face anti-counterfeiting recognition method provided by the present invention, before generating an interference image of the first face image sample based on the generator, the method further includes:
[0010] Encoding the interference image of each second face image sample based on the feature encoder to obtain features of the interference image of each second face image sample;
[0011] Encoding each of the second facial image samples based on a feature encoder to obtain features of each of the second facial image samples;
[0012] Determining centroid features of the second facial image samples with the same facial forgery type label based on the features of the second facial image samples;
[0013] Determine a first similarity between a feature of an interference image of each second facial image sample and a centroid feature corresponding to a facial forgery type label of each second facial image sample;
[0014] Determine a second similarity between features of the interference image of each second facial image sample and centroid features corresponding to other forged facial type labels, wherein the other forged facial type labels are facial forgery type labels other than the facial forgery type labels of each second facial image sample among the facial forgery type labels;
[0015] The first similarity and the second similarity are added together to obtain a clustering contrast loss value between each of the second face image samples and an interference image of each of the second face image samples.
[0016] According to a face anti-counterfeiting recognition method provided by the present invention, before generating an interference image of the first face image sample based on the generator, the method further includes:
[0017] Based on the features of the interference image of each second facial image sample, using the classifier to determine the face forgery type prediction value of the interference image of each second facial image sample;
[0018] Based on the face forgery type prediction value of the interference image of each second face image sample and the face forgery type label of each second face image sample, the category loss value between each second face image sample and the interference image of each second face image sample is determined.
[0019] According to a face anti-counterfeiting recognition method provided by the present invention, before generating an interference image of the first face image sample based on the generator, the method further includes:
[0020] Determine a difference between a feature of an interference image of each second facial image sample and a feature of each second facial image sample;
[0021] Based on the difference, a semantic loss value between each second face image sample and an interference image of each second face image sample is determined.
[0022] According to a face anti-counterfeiting recognition method provided by the present invention, before generating an interference image of the first face image sample based on the generator, the method further includes:
[0023] Determine the sum of the category loss value and the semantic loss between each second face image sample and the interference image of each second face image sample;
[0024] Subtracting the cluster contrast loss value from the sum of the category loss value and the semantic loss to obtain a total loss value between each second face image sample and an interference image of each second face image sample;
[0025] Based on the total loss value between each second face image sample and the interference image of each second face image sample, the weight of the generator is adjusted until the generator converges.
[0026] According to a face anti-counterfeiting identification method provided by the present invention, training a classifier based on the first face image sample, an interference image of the first face image sample and a face forgery type label of the first face image sample includes:
[0027] Using the interference image of the first face image sample and the first face image sample as a third face image sample, and using the face forgery type label of the corresponding first face image sample as the face forgery type label of the third face image sample;
[0028] Based on the classifier, a predicted value of the face forgery type of each third face image sample is obtained;
[0029] Masking the predicted probabilities of the face forgery type labels belonging to the third face image samples in the face forgery type prediction values of the third face image samples;
[0030] Determine a discrimination loss value of each third face image sample for the unknown forged type label based on the face forgery type prediction value and the unknown forged type label after the mask processing of each third face image sample;
[0031] Based on the discrimination loss value of each third face image sample for the unknown forgery type label, the weight of the classifier is adjusted until the classifier converges.
[0032] According to a face anti-counterfeiting recognition method provided by the present invention, the weight adjustment of the classifier is performed based on the discrimination loss value of each third face image sample for the unknown counterfeit type label until the classifier converges, including:
[0033] Determining a recognition loss value of each of the third facial image samples based on the facial forgery type prediction value and the facial forgery type label of each of the third facial image samples;
[0034] Determine a total loss value of each of the third face image samples based on the recognition loss value of each of the third face image samples and the discrimination loss value for the unknown forgery type label;
[0035] Based on the total loss value of each third face image sample, the weight of the classifier is adjusted until the generator converges.
[0036] The present invention also provides a face anti-counterfeiting recognition device, comprising:
[0037] a generating module, configured to generate an interference image of a first face image sample based on a generator, wherein the generator is weighted based on a clustering contrast loss value, a category loss value, and a semantic loss value between a second face image sample and the interference image of the second face image sample, and the interference image of the second face image sample is generated based on the generator;
[0038] A training module, configured to train a classifier based on the first face image sample, an interference image of the first face image sample, and a face forgery type label of the first face image sample;
[0039] The recognition module is used to determine the face forgery type prediction value of the target face image based on the trained classifier.
[0040] The present invention also provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the face anti-counterfeiting recognition method as described above is implemented.
[0041] The present invention also provides a non-transitory computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the face anti-counterfeiting recognition method as described above is implemented.
[0042] The present invention also provides a computer program product, including a computer program, which, when executed by a processor, implements any of the above-mentioned face anti-counterfeiting recognition methods.
[0043] The face anti-counterfeiting recognition method and device provided by the present invention generate an interference image of a first face image sample based on a generator, and the generator is obtained by weight adjustment based on the clustering contrast loss value, category loss value and semantic loss value between a second face image sample and the interference image of the second face image sample, so as to actively intervene in fraud-irrelevant factors based on causal inference on the basis of face images in the source domain, eliminate false correlations, learn generalized causal features, and generate face interference images with the same category and semantics as the original face images and external distribution, thereby increasing the types and distribution diversity of classifier training samples, reducing training costs, and improving the accuracy of face anti-counterfeiting recognition. BRIEF DESCRIPTION OF THE DRAWINGS
[0044] In order to more clearly illustrate the technical solutions in the present invention or the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are 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.
[0045] Figure 1 This is one of the flow charts of the face anti-counterfeiting recognition method provided by the present invention;
[0046] Figure 2 This is the second flow chart of the face anti-counterfeiting recognition method provided by the present invention;
[0047] Figure 3 This is the third flow chart of the face anti-counterfeiting recognition method provided by the present invention;
[0048] Figure 4 It is a structural schematic diagram of the face anti-counterfeiting recognition device provided by the present invention;
[0049] Figure 5 It is a structural schematic diagram of the electronic device provided by the present invention. DETAILED DESCRIPTION
[0050] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the drawings of the present invention. Obviously, the described embodiments are 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.
[0051] Combine the following Figure 1 A face anti-counterfeiting recognition method of the present invention is described, comprising:
[0052] Step 101, generating an interference image of a first face image sample based on a generator, wherein the generator performs weight adjustment based on a clustering contrast loss value, a category loss value, and a semantic loss value between a second face image sample and the interference image of the second face image sample, and the interference image of the second face image sample is generated based on the generator;
[0053] The generator is a generative model, such as a generative adversarial network (GAN). This embodiment does not limit the type of the generator.
[0054] A certain number of first face image samples are obtained for training the classifier, and the faces in the first face image samples include living faces and prosthetic faces.
[0055] The first face image sample is the source domain image Can generate interference images based on source domain images based on category-agnostic contrast image generation based on causal inference i is the serial number of the first face image sample. The generator may generate an interference image of the first face image sample by adding noise to the first face image sample.
[0056] Before using the generator to generate interference images of the first face image samples, a certain number of second face image samples are obtained for training the generator, and the faces in the second face image samples include living faces and prosthetic faces.
[0057] The second facial image sample may be identical to the first facial image sample, or may have a partial intersection or no intersection with the first facial image sample.
[0058] When training the generator, the second face image sample is input into the generator to obtain an interference image of the second face image sample. A total loss value between the interference image of the second face image sample and the second face image sample is calculated using a loss function. The weight of the generator is adjusted based on the total loss value until the generator converges.
[0059] Based on the total loss value between the interference image of the second face image sample and the second face image sample, the weight of the generator can be iteratively adjusted using the gradient back propagation algorithm until convergence to obtain a trained generator.
[0060] In order to supervise the training process of the generator, the clustering contrast loss value, category loss value and semantic loss value between the interference image of the second face image sample and the second face image sample are used to constrain the generation of the interference image, so as to generate the original category face image out of the distribution as much as possible based on causal inference.
[0061] Step 102, training a classifier based on the first face image sample, the interference image of the first face image sample, and the face forgery type label of the first face image sample;
[0062] The first face image sample and the interference image of the first face image sample can be used as samples, and the face forgery type label of the first face image sample can be used as a label to train the classifier. in is the first face image sample, is the face forgery type label for the first face image sample, is an interference image generated based on the first face image sample, is the face forgery type label of the first face image sample to which the interference image belongs, Ns is the number of samples of the first face image. The face forgery type labels may include living face, printed face, photo face and masked face.
[0063] In order to make the model have good training stability and reduce the demanding requirements on hardware, a phased training method is adopted, that is, the generator is trained first, and then the classifier is trained. This embodiment does not limit the training method of the classifier.
[0064] Step 103: Determine a predicted value of the face forgery type of the target face image based on the trained classifier.
[0065] The target face image is an image that needs to be identified for face anti-counterfeiting. The target face image is input into the trained classifier to obtain a predicted value of the face forgery type of the target face image.
[0066] This embodiment generates an interference image of the first face image sample based on a generator, and the generator is obtained by weighting adjustment based on the clustering contrast loss value, category loss value and semantic loss value between the second face image sample and the interference image of the second face image sample, so as to actively intervene in fraud-irrelevant factors based on causal inference on the basis of face images in the source domain, eliminate false correlations, learn generalized causal features, and generate face interference images with the same category and semantics as the original face images and external distribution, thereby increasing the types and distribution diversity of classifier training samples, reducing training costs, and improving the accuracy of face anti-counterfeiting recognition.
[0067] On the basis of the above embodiment, before the generator generates the interference image of the first face image sample, the present embodiment further includes:
[0068] Encoding the interference image of each second face image sample based on the feature encoder to obtain features of the interference image of each second face image sample;
[0069] Encoding each of the second facial image samples based on a feature encoder to obtain features of each of the second facial image samples;
[0070] Determining centroid features of the second facial image samples with the same facial forgery type label based on the features of the second facial image samples;
[0071] Determine a first similarity between a feature of an interference image of each second facial image sample and a centroid feature corresponding to a facial forgery type label of each second facial image sample;
[0072] Determine a second similarity between features of the interference image of each second facial image sample and centroid features corresponding to other forged facial type labels, wherein the other forged facial type labels are facial forgery type labels other than the facial forgery type labels of each second facial image sample among the facial forgery type labels;
[0073] The first similarity and the second similarity are added together to obtain a clustering contrast loss value between each of the second face image samples and an interference image of each of the second face image samples.
[0074] The clustering contrast loss value l between each second face image sample and the interference image of each second face image sample con The calculation formula is as follows:
[0075]
[0076] in, represents the i-th second face image sample, represents the interference image of the i-th second face image sample, represents the face forgery type label of the i-th second face image sample, E represents the feature encoder, represents the set of centroid features corresponding to the K face forgery type labels of the second face image sample, d represents the feature dimension extracted from the feature encoder E, represents the centroid feature corresponding to the face forgery type label of the i-th second face image sample. The centroid feature corresponding to a certain face forgery type label is the feature average of all second face image samples with a certain face forgery type label.
[0077] On the basis of the above embodiment, before the generator generates the interference image of the first face image sample, the present embodiment further includes:
[0078] Based on the features of the interference image of each second facial image sample, using the classifier to determine the face forgery type prediction value of the interference image of each second facial image sample;
[0079] Based on the face forgery type prediction value of the interference image of each second face image sample and the face forgery type label of each second face image sample, the category loss value between each second face image sample and the interference image of each second face image sample is determined.
[0080] The class loss value l between each second face image sample and the interference image of each second face image sample cp The calculation formula is as follows:
[0081]
[0082] in, represents the interference image of the i-th second face image sample, represents the face forgery type label of the i-th second face image sample, E represents the feature encoder, F represents the classifier, and L represents the cross entropy loss function.
[0083] On the basis of the above embodiment, before the generator generates the interference image of the first face image sample, the present embodiment further includes:
[0084] Determine a difference between a feature of an interference image of each second facial image sample and a feature of each second facial image sample;
[0085] Based on the difference, a semantic loss value between each second face image sample and an interference image of each second face image sample is determined.
[0086] The semantic loss value l between each second face image sample and the interference image of each second face image sample sem The calculation formula is as follows:
[0087]
[0088] in, represents the i-th second face image sample, represents the interference image of the i-th second face image sample, and E represents the feature encoder.
[0089] On the basis of the above embodiment, before the generator generates the interference image of the first face image sample, the present embodiment further includes:
[0090] Determine the sum of the category loss value and the semantic loss between each second face image sample and the interference image of each second face image sample;
[0091] Subtracting the cluster contrast loss value from the sum of the category loss value and the semantic loss to obtain a total loss value between each second face image sample and an interference image of each second face image sample;
[0092] Based on the total loss value between each second face image sample and the interference image of each second face image sample, the weight of the generator is adjusted until the generator converges.
[0093] The total loss value between each second face image sample and the interference image of each second face image sample is calculated by the following formula:
[0094] l cp +l sem -lcom .
[0095] The total loss value is minimized, that is Iteratively optimize the objective function.
[0096] The weights of the generator can be updated using the gradient back propagation algorithm until convergence. The interference image can be generated according to the following paradigm:
[0097]
[0098] Among them, η g represents the learning rate for optimizing the face image generation process, l cp , l sem , and l con Represents the loss function used in the face image generation process.
[0099] On the basis of the above embodiments, the method of training a classifier based on the first face image sample, the interference image of the first face image sample and the face forgery type label of the first face image sample in this embodiment includes:
[0100] Using the interference image of the first face image sample and the first face image sample as a third face image sample, and using the face forgery type label of the corresponding first face image sample as the face forgery type label of the third face image sample;
[0101] Based on the classifier, a predicted value of the face forgery type of each third face image sample is obtained;
[0102] Masking the predicted probabilities of the face forgery type labels belonging to the third face image samples in the face forgery type prediction values of the third face image samples;
[0103] Determine a discrimination loss value of each third face image sample for the unknown forged type label based on the face forgery type prediction value and the unknown forged type label after the mask processing of each third face image sample;
[0104] Based on the discrimination loss value of each third face image sample for the unknown forgery type label, the weight of the classifier is adjusted until the classifier converges.
[0105] The interference image of the first face image sample and the first face image sample As the third face image sample, the face forgery type label of the corresponding first face image sample is and As the face forgery type label of the third face image sample, that is,
[0106]
[0107] The discriminant loss value l of each third face image sample for the unknown forgery type label unk The calculation formula is as follows:
[0108] l unk (x i ,y i )=L(F(E(x i ))\y i , K+1);
[0109] Where L is the cross entropy loss function, is the logits encoding output by classifier F, Denotes the face forgery type label y of the third face image sample masked from the logits encoding output by the classifier F i The corresponding logits encoding is used to force the third face image sample not to be classified into the face forgery type label y i K+1 is the preset number of unknown type.
[0110] Based on the discrimination loss value of each third face image sample for the unknown forgery type label, the loss gradient back propagation algorithm can be used to iteratively adjust the weights of the classifier until convergence.
[0111] This embodiment adjusts the weights of the classifier based on the discrimination loss value of each third face image sample for the unknown forgery type label, so that the classifier can detect known forgery types and unknown forgery types on the face image, obtain the detection probability of the face image for the known forgery type and the unknown forgery type, and further judge whether the face image is alive or fake, thereby realizing robust face anti-counterfeiting recognition based on open set single domain generalization of causal inference.
[0112] On the basis of the above embodiment, the method of adjusting the weight of the classifier based on the discrimination loss value of each third face image sample for the unknown forgery type label until the classifier converges includes:
[0113] Determining a recognition loss value of each of the third facial image samples based on the facial forgery type prediction value and the facial forgery type label of each of the third facial image samples;
[0114] Determine a total loss value of each of the third face image samples based on the recognition loss value of each of the third face image samples and the discrimination loss value for the unknown forgery type label;
[0115] Based on the total loss value of each third face image sample, the weight of the classifier is adjusted until the generator converges.
[0116] The recognition loss value l of each third face image sample is determined by the following formula: known :
[0117] l known (x i ,y i )=L(F(E(x i )),y i );
[0118] Where L is the cross entropy loss function, is the logits encoding of the third face image sample of the i-th output of classifier F, y i Forge the face type label for the i-th third face image sample.
[0119] The calculation formula for the total loss value of each third face image sample is as follows:
[0120] l known +l unk .
[0121] The total loss value of each third face image sample is minimized, that is, The classifier is iteratively optimized for the objective function. The classifier is constrained by the recognition loss value and the discrimination loss value for unknown forged type labels.
[0122] Based on the total loss value of each third face image sample, the parameters of the classifier can be iteratively adjusted using a gradient back propagation algorithm until convergence.
[0123] The complete process diagram of the face anti-counterfeiting recognition method is as follows Figure 2 and Figure 3 As shown in the figure, the training process of the generator includes: extracting features from face images; inputting face features into the face generator, and obtaining face interference images based on causal inference; calculating clustering contrast loss values, category loss values, and semantic loss values for the face images in the source domain and the generated face interference images, and iteratively adjusting the generator using the loss gradient back propagation algorithm until convergence.
[0124] The training process of the classifier includes: extracting features from the face image to obtain its encoding; inputting the face encoding into the classifier to obtain the logits encoding; performing known attack category probability detection through the logits encoding, and inputting the logits encoding into the label-aware mask; obtaining the unknown logits encoding through the label-aware mask, and performing unknown-aware category probability detection; calculating the known attack category probability and the unknown attack category probability for the face image, and inputting the logits encoding into the loss function, calculating the recognition loss value and the discrimination loss value for the unknown forged type label, and iteratively adjusting the classifier using the loss gradient back-propagation algorithm until convergence.
[0125] This embodiment adjusts the weights of the classifier based on the recognition loss value of each third face image sample and the discrimination loss value for the unknown forgery type label, so that the classifier can detect known forgery types and unknown forgery types on the face image, obtain the detection probability of the face image for the known forgery type and the unknown forgery type, and further judge whether the face image is alive or fake, thereby realizing robust face anti-counterfeiting recognition based on open set single domain generalization of causal inference.
[0126] The face anti-counterfeiting recognition device provided by the present invention is described below. The face anti-counterfeiting recognition device described below and the face anti-counterfeiting recognition method described above can be referenced to each other.
[0127] Figure 4 Schematic diagram of the structure of the face anti-counterfeiting recognition device provided by the present invention. Figure 4 As shown, the device includes a generation module 401, a training module 402 and a recognition module 403, wherein:
[0128] The generating module 401 is used to generate an interference image of a first face image sample based on a generator, wherein the generator is weighted based on a clustering contrast loss value, a category loss value, and a semantic loss value between a second face image sample and the interference image of the second face image sample, and the interference image of the second face image sample is generated based on the generator;
[0129] The training module 402 is used to train a classifier based on the first face image sample, the interference image of the first face image sample and the face forgery type label of the first face image sample;
[0130] The recognition module 403 is used to determine the face forgery type prediction value of the target face image based on the trained classifier.
[0131] This embodiment generates an interference image of the first face image sample based on a generator, and the generator is obtained by weighting adjustment based on the clustering contrast loss value, category loss value and semantic loss value between the second face image sample and the interference image of the second face image sample, so as to actively intervene in fraud-irrelevant factors based on causal inference on the basis of face images in the source domain, eliminate false correlations, learn generalized causal features, and generate face interference images with the same category and semantics as the original face images and external distribution, thereby increasing the types and distribution diversity of classifier training samples, reducing training costs, and improving the accuracy of face anti-counterfeiting recognition.
[0132] Figure 5 An example of a physical structure diagram of an electronic device is shown in FIG. Figure 5 As shown, the electronic device may include: a processor 510, a communication interface 520, a memory 530 and a communication bus 540, wherein the processor 510, the communication interface 520 and the memory 530 communicate with each other through the communication bus 540. The processor 510 may call the logic instructions in the memory 530 to execute the face anti-counterfeiting recognition method, the method comprising: generating an interference image of a first face image sample based on a generator, the generator is obtained by weight adjustment based on the clustering contrast loss value, the category loss value and the semantic loss value between the second face image sample and the interference image of the second face image sample, and the interference image of the second face image sample is generated based on the generator; training a classifier based on the first face image sample, the interference image of the first face image sample and the face forgery type label of the first face image sample; determining the face forgery type prediction value of the target face image based on the trained classifier.
[0133] In addition, the logic instructions in the above-mentioned memory 530 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art or the 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, including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform 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, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk, etc. Various media that can store program codes.
[0134] On the other hand, the present invention also provides a computer program product, which includes a computer program. The computer program can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer can execute the face anti-counterfeiting recognition method provided by the above-mentioned methods, the method including: based on a generator, generating an interference image of a first face image sample, the generator is weighted adjusted based on the clustering contrast loss value, category loss value and semantic loss value between a second face image sample and the interference image of the second face image sample, and the interference image of the second face image sample is generated based on the generator; based on the first face image sample, the interference image of the first face image sample and the face forgery type label of the first face image sample, a classifier is trained; based on the trained classifier, a face forgery type prediction value of the target face image is determined.
[0135] On the other hand, the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, is implemented to execute the facial anti-counterfeiting recognition method provided by the above-mentioned methods, the method comprising: based on a generator, generating an interference image of a first facial image sample, the generator adjusting the weights based on the clustering contrast loss value, category loss value and semantic loss value between a second facial image sample and the interference image of the second facial image sample, the interference image of the second facial image sample being generated based on the generator; training a classifier based on the first facial image sample, the interference image of the first facial image sample and the facial forgery type label of the first facial image sample; and determining a facial forgery type prediction value of the target facial image based on the trained classifier.
[0136] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.
[0137] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.
[0138] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A face anti-counterfeiting recognition method, It is characterized in that include: Based on a generator, generating an interference image of a first face image sample, the generator adjusting weights based on a clustering contrast loss value, a category loss value, and a semantic loss value between a second face image sample and the interference image of the second face image sample, the interference image of the second face image sample being generated based on the generator; Training a classifier based on the first face image sample, the interference image of the first face image sample, and the face forgery type label of the first face image sample; Determine a face forgery type prediction value of the target face image based on the trained classifier; Before generating the interference image of the first face image sample based on the generator, the method further includes: Encoding the interference image of each second face image sample based on the feature encoder to obtain features of the interference image of each second face image sample; Encoding each of the second facial image samples based on a feature encoder to obtain features of each of the second facial image samples; Determining centroid features of the second facial image samples with the same face forgery type label based on the features of the second facial image samples; Determine a first similarity between a feature of an interference image of each second facial image sample and a centroid feature corresponding to a facial forgery type label of each second facial image sample; Determine a second similarity between features of the interference image of each second facial image sample and centroid features corresponding to other forged facial type labels, wherein the other forged facial type labels are facial forgery type labels other than the facial forgery type labels of each second facial image sample among the facial forgery type labels; Adding the first similarity and the second similarity to obtain a clustering contrast loss value between each of the second face image samples and an interference image of each of the second face image samples; Before generating the interference image of the first face image sample based on the generator, the method further includes: Based on the features of the interference image of each second face image sample, using the classifier to determine the face forgery type prediction value of the interference image of each second face image sample; Determining a category loss value between each second face image sample and the interference image of each second face image sample based on a face forgery type prediction value of the interference image of each second face image sample and a face forgery type label of each second face image sample; Before generating the interference image of the first face image sample based on the generator, the method further includes: Determine a difference between a feature of an interference image of each second facial image sample and a feature of each second facial image sample; Determining a semantic loss value between each of the second face image samples and an interference image of each of the second face image samples based on the difference; Before generating the interference image of the first face image sample based on the generator, the method further includes: Determine the sum of the category loss value and the semantic loss between each second face image sample and the interference image of each second face image sample; Subtracting the cluster contrast loss value from the sum of the category loss value and the semantic loss to obtain a total loss value between each second face image sample and an interference image of each second face image sample; Based on the total loss value between each second face image sample and the interference image of each second face image sample, the weight of the generator is adjusted until the generator converges.
2. The face anti-counterfeiting recognition method according to claim 1, It is characterized in that The training of a classifier based on the first face image sample, the interference image of the first face image sample and the face forgery type label of the first face image sample comprises: Using the interference image of the first face image sample and the first face image sample as a third face image sample, and using the face forgery type label of the corresponding first face image sample as the face forgery type label of the third face image sample; Based on the classifier, a predicted value of the face forgery type of each third face image sample is obtained; Masking the predicted probabilities of the face forgery type labels belonging to the third face image samples in the face forgery type prediction values of the third face image samples; Determine a discrimination loss value of each third face image sample for the unknown forged type label based on the face forgery type prediction value and the unknown forged type label after the mask processing of each third face image sample; Based on the discrimination loss value of each third face image sample for the unknown forgery type label, the weight of the classifier is adjusted until the classifier converges.
3. The face anti-counterfeiting recognition method according to claim 2, It is characterized in that The step of adjusting the weight of the classifier based on the discrimination loss value of each third face image sample for the unknown forgery type label until the classifier converges includes: Determining a recognition loss value of each of the third facial image samples based on the facial forgery type prediction value and the facial forgery type label of each of the third facial image samples; Determine a total loss value of each of the third face image samples based on the recognition loss value of each of the third face image samples and the discrimination loss value for the unknown forgery type label; Based on the total loss value of each third face image sample, the weight of the classifier is adjusted until the classifier converges.
4. A face anti-counterfeiting recognition device, It is characterized in that include: a generating module, configured to generate an interference image of a first face image sample based on a generator, wherein the generator is weighted based on a clustering contrast loss value, a category loss value, and a semantic loss value between a second face image sample and the interference image of the second face image sample, and the interference image of the second face image sample is generated based on the generator; A training module, configured to train a classifier based on the first face image sample, an interference image of the first face image sample, and a face forgery type label of the first face image sample; A recognition module, used to determine a predicted value of a face forgery type of a target face image based on the trained classifier; Before generating the interference image of the first face image sample based on the generator, the generating module is further used for: Encoding the interference image of each second face image sample based on the feature encoder to obtain features of the interference image of each second face image sample; Encoding each of the second facial image samples based on a feature encoder to obtain features of each of the second facial image samples; Determining centroid features of the second facial image samples with the same face forgery type label based on the features of the second facial image samples; Determine a first similarity between a feature of an interference image of each second facial image sample and a centroid feature corresponding to a facial forgery type label of each second facial image sample; Determine a second similarity between features of the interference image of each second facial image sample and centroid features corresponding to other forged facial type labels, wherein the other forged facial type labels are facial forgery type labels other than the facial forgery type labels of each second facial image sample among the facial forgery type labels; Adding the first similarity and the second similarity to obtain a clustering contrast loss value between each of the second face image samples and an interference image of each of the second face image samples; Before generating the interference image of the first face image sample based on the generator, the generating module is further used for: Based on the features of the interference image of each second face image sample, using the classifier to determine the face forgery type prediction value of the interference image of each second face image sample; Determining a category loss value between each second face image sample and the interference image of each second face image sample based on a face forgery type prediction value of the interference image of each second face image sample and a face forgery type label of each second face image sample; Before generating the interference image of the first face image sample based on the generator, the generating module is further used for: Determine a difference between a feature of an interference image of each second facial image sample and a feature of each second facial image sample; Determining a semantic loss value between each of the second face image samples and an interference image of each of the second face image samples based on the difference; Before generating the interference image of the first face image sample based on the generator, the generating module is further used for: Determine the sum of the category loss value and the semantic loss between each second face image sample and the interference image of each second face image sample; Subtracting the cluster contrast loss value from the sum of the category loss value and the semantic loss to obtain a total loss value between each second face image sample and an interference image of each second face image sample; Based on the total loss value between each second face image sample and the interference image of each second face image sample, the weight of the generator is adjusted until the generator converges.
5. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, It is characterized in that When the processor executes the program, the face anti-counterfeiting recognition method as described in any one of claims 1 to 3 is implemented.
6. A non-transitory computer-readable storage medium having a computer program stored thereon, It is characterized in that When the computer program is executed by a processor, the face anti-counterfeiting recognition method as claimed in any one of claims 1 to 3 is implemented.
