Training method of face anti-counterfeiting recognition model, face anti-counterfeiting recognition method and device
By pre-training language models and parameter prompts, the network processed face anti-counterfeiting recognition model is generated, the text prompt set is generated and image features is calculated, which solves the generalization ability and recognition efficiency of the face anti-counterfeiting recognition model, and realizes a variety of attacks Efficient identification of types.
Patent Information
- Application Number
- CN202411265940.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-11
- Publication Date
- 2024-12-13
- Estimated Expiration
- 2044-09-11
AI Technical Summary
The existing face anti-counterfeiting recognition model has shortcomings in generalization capabilities and recognition efficiency, especially in domain transfer and unknown attack scenarios, and data collection problems lead to complicated training.
The network is generated by pre-trained language model and parameter prompts. The text prompt set is generated by processing category tags and face anti-counterfeiting training images, and similar information between image features and text features is calculated. The network parameters are iteratively adjusted to generate efficient face anti-counterfeiting recognition. Model that supports the identification of real faces, known and unknown attack types.
It improves the recognition accuracy and recognition efficiency of different attack types, enhances the generalization ability of the model, and can effectively handle a variety of attack types, including printing, replay and unknown attack types.
Smart Images

Figure CN118799947B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of image processing technology, and more specifically, to a training method for a face anti-counterfeiting recognition model, a face anti-counterfeiting recognition method and a device. Background Art
[0002] In recent years, the generalization ability of face anti-counterfeiting models has attracted the attention of the industry and academia. Among all the research problems, domain shift and unknown attacks are the most serious problems affecting generalization performance. Existing research usually focuses on solving one of the above problems. In addition, the method most similar to the present invention requires multiple training domains and known attack types to train it. In actual scenarios, it is a difficult problem to collect data from multiple training domains. In addition, in addition to known categories, there will also be unknown categories in the reasoning domain.
[0003] In the process of realizing the concept of this application, it was found that the related technology had poor recognition accuracy and efficiency in face anti-counterfeiting recognition. Summary of the invention
[0004] In view of this, the present application provides a training method for a face anti-counterfeiting recognition model, a face anti-counterfeiting recognition method, a device, an electronic device, a computer-readable storage medium, and a computer program product.
[0005] One aspect of the present application provides a method for training a face anti-counterfeiting recognition model, comprising:
[0006] In response to the training instruction, a face anti-counterfeiting recognition training set is obtained, wherein the face anti-counterfeiting recognition training set includes a plurality of face anti-counterfeiting training images and a category label set, and the category label set includes a real face type label and a plurality of attack type labels;
[0007] Processing the above-mentioned category label set using a pre-trained language model to obtain a context vector set, wherein the above-mentioned context vector set includes context prompt vectors corresponding to different types of labels;
[0008] Processing the context vector set and the category label set using a parameter prompt generation network to generate a text prompt set, wherein the text prompt set includes text prompt information corresponding to different types of labels;
[0009] For each of the above-mentioned face anti-counterfeiting training images, the above-mentioned face anti-counterfeiting training images and the above-mentioned text prompt set are processed by an encoder network to generate image features and multiple text features respectively, wherein the initial anti-counterfeiting recognition model includes the above-mentioned pre-trained language model, the above-mentioned parameter prompt generation network and the above-mentioned encoder network;
[0010] Calculating sample similarity information between the image feature and the plurality of text features to generate a target loss value according to the plurality of sample similarity information;
[0011] The network parameters of the network generated by the parameter prompts are iteratively adjusted according to the target loss value, thereby obtaining a trained face anti-counterfeiting recognition model.
[0012] According to an embodiment of the present application, the above-mentioned attack type label includes a print attack type label, a replay attack type label and an unknown attack type label;
[0013] The pre-trained language model is used to process the above category label set to obtain a context vector set, including:
[0014] For any type of label, use the pre-trained language model to process the attack type to obtain multiple context vectors.
[0015] Generating the context prompt vector of the type label according to the plurality of context vectors;
[0016] The context vector set is generated according to the multiple context prompt vectors and the multiple category vectors, wherein the multiple category vectors represent different category labels.
[0017] According to an embodiment of the present application, the above-mentioned parameter prompt generation network includes a parameter predictor and a prompt generator.
[0018] According to an embodiment of the present application, a parameter prompt generation network is used to process the context vector set and the category label set to generate a text prompt set, including:
[0019] Processing the context vector set using the above parameter predictor to generate multiple category prior vectors;
[0020] The prompt generator is used to process the plurality of category prior vectors and the category label set to generate the text prompt set.
[0021] According to an embodiment of the present application, the context vector set is processed using the above parameter predictor to generate multiple category prior vectors, including:
[0022] For any context hint vector, use the parameter predictor to process the context hint vector to generate a Gaussian distribution set of the context hint vector, wherein the Gaussian distribution set includes Gaussian distribution values, mean and variance of the Gaussian distribution values, and the mean and variance represent category prior information;
[0023] The category prior vector of the context prompt vector is generated based on the category prior information and the category vector.
[0024] According to an embodiment of the present application, the prompt generator is used to process the plurality of category prior vectors and the category label set to generate the text prompt set, including:
[0025] Processing a plurality of the above-mentioned category prior vectors using the above-mentioned prompt generator to obtain a plurality of text mark information;
[0026] For each of the text mark information, the text prompt information is generated according to the text mark information and the type label corresponding to the text mark information.
[0027] According to an embodiment of the present application, the above-mentioned encoder network includes an image encoder and a text encoder.
[0028] According to an embodiment of the present application, the encoder network is used to process the above-mentioned face anti-counterfeiting training image and the above-mentioned text prompt set to generate image features and multiple text features respectively, including:
[0029] Processing the face anti-counterfeiting training image using the image encoder to obtain image features;
[0030] The text prompt set is processed using the text encoder to obtain a plurality of text features.
[0031] According to an embodiment of the present application, the above-mentioned attack type label includes a known type label and an unknown type label.
[0032] According to an embodiment of the present application, calculating sample similarity information between the image feature and the plurality of text features to generate a target loss value according to the plurality of sample similarity information includes:
[0033] For each of the above text features, a similarity vector and sample similarity information are generated according to the above image features and the above text features;
[0034] Generate a known type loss value according to the similarity vector and the target type label, wherein the target type label includes the real face type label and the known type label;
[0035] Generate an unknown type loss value based on the similarity vector and the unknown type label;
[0036] The target loss value is generated according to the known type loss value and the unknown type loss value.
[0037] Another aspect of the present application provides a face anti-counterfeiting recognition method, comprising:
[0038] Obtain a face image to be identified and a category set, wherein the category set includes a real face type and multiple attack types;
[0039] Input the above-mentioned face image to be identified and the category set into the face anti-counterfeiting recognition model, and output the predicted similarity information corresponding to different types;
[0040] Normalizing the plurality of similar prediction information to obtain a plurality of prediction probabilities;
[0041] The type corresponding to the maximum value among the multiple predicted probabilities is determined as the anti-counterfeiting recognition type corresponding to the face image to be recognized.
[0042] Another aspect of the present application provides a training device for a face anti-counterfeiting recognition model, comprising:
[0043] A first acquisition module is used to obtain a face anti-counterfeiting recognition training set in response to a training instruction, wherein the face anti-counterfeiting recognition training set includes a plurality of face anti-counterfeiting training images and a category label set, and the category label set includes a real face type label and a plurality of attack type labels;
[0044] A first processing module is used to process the above-mentioned category label set using a pre-trained language model to obtain a context vector set, wherein the above-mentioned context vector set includes context prompt vectors corresponding to different types of labels;
[0045] A second processing module is used to process the context vector set and the category label set using a parameter prompt generation network to generate a text prompt set, wherein the text prompt set includes text prompt information corresponding to different types of labels;
[0046] A third processing module is used for processing the face anti-counterfeiting training image and the text prompt set using an encoder network for each of the face anti-counterfeiting training images to generate image features and multiple text features, respectively, wherein the initial anti-counterfeiting recognition model includes the pre-trained language model, the parameter prompt generation network, and the encoder network;
[0047] A calculation module, used for calculating sample similarity information between the above-mentioned image feature and the plurality of above-mentioned text features, so as to generate a target loss value according to the plurality of above-mentioned sample similarity information;
[0048] The training module is used to iteratively adjust the network parameters of the parameter prompt generation network according to the target loss value, so as to obtain a trained face anti-counterfeiting recognition model.
[0049] Another aspect of the present application provides a face anti-counterfeiting recognition device, comprising:
[0050] A second acquisition module is used to acquire a face image to be identified and a category set, wherein the category set includes a real face type and multiple attack types;
[0051] A module is obtained, which is used to input the above-mentioned face image to be identified and the category set into the face anti-counterfeiting recognition model, and output the predicted similarity information corresponding to different types;
[0052] A normalization module is used to normalize the plurality of similar prediction information to obtain a plurality of prediction probabilities;
[0053] A determination module is used to determine the type corresponding to the maximum value among the multiple predicted probabilities as the anti-counterfeiting identification type corresponding to the above-mentioned face image to be identified.
[0054] Another aspect of the present application provides an electronic device, comprising:
[0055] one or more processors;
[0056] a memory for storing one or more programs,
[0057] When the one or more programs are executed by the one or more processors, the one or more processors implement the method as described above.
[0058] Another aspect of the present application provides a computer-readable storage medium storing computer-executable instructions, which are used to implement the method described above when executed.
[0059] Another aspect of the present application provides a computer program product, which includes computer executable instructions, and the instructions are used to implement the method as described above when executed.
[0060] According to an embodiment of the present application, a context vector set is obtained by processing a category label set using a pre-trained language model, and a context vector set and a category label set are processed using a parameter prompt generation network to generate a text prompt set. For each face anti-counterfeiting training image, an encoder network is used to process the face anti-counterfeiting training image and the text prompt set to generate image features and multiple text features, respectively. Thereafter, sample similarity information between the image features and the multiple text features is calculated to generate a target loss value based on the multiple sample similarity information, thereby iteratively updating according to the target loss value to obtain a face anti-counterfeiting recognition model. The face anti-counterfeiting recognition model generated by the pre-trained language model and the parameter prompt generation network in the present application can effectively improve the recognition accuracy of different attack types, while improving the recognition efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0061] The above and other objects, features and advantages of the present application will become more apparent through the following description of the embodiments of the present application with reference to the accompanying drawings, in which:
[0062] Figure 1An exemplary system architecture to which a training method for a face anti-counterfeiting recognition model or a face anti-counterfeiting recognition method can be applied according to an embodiment of the present application is shown;
[0063] Figure 2 A flow chart of a method for training a face anti-counterfeiting recognition model according to an embodiment of the present application is shown;
[0064] Figure 3 A flowchart of a method for training a face anti-counterfeiting recognition model according to another embodiment of the present application is shown;
[0065] Figure 4 A flow chart of a face anti-counterfeiting recognition method according to an embodiment of the present application is shown;
[0066] Figure 5 A block diagram of a training device for a face anti-counterfeiting recognition model according to an embodiment of the present application is shown;
[0067] Figure 6 A block diagram of a face anti-counterfeiting recognition device according to an embodiment of the present application is shown;
[0068] Figure 7 A block diagram of an electronic device suitable for implementing the method described above according to an embodiment of the present application is shown. DETAILED DESCRIPTION
[0069] Below, embodiments of the present application will be described with reference to the accompanying drawings. However, it should be understood that these descriptions are exemplary only and are not intended to limit the scope of the present application. In the following detailed description, for ease of explanation, many specific details are set forth to provide a comprehensive understanding of the embodiments of the present application. However, it is apparent that one or more embodiments may also be implemented without these specific details. In addition, in the following description, descriptions of known structures and technologies are omitted to avoid unnecessary confusion of the concepts of the present application.
[0070] The terms used herein are only for describing specific embodiments and are not intended to limit the present application. The terms "include", "comprising", etc. used herein indicate the existence of the features, steps, operations and / or components, but do not exclude the existence or addition of one or more other features, steps, operations or components.
[0071] All terms (including technical and scientific terms) used herein have the meanings commonly understood by those skilled in the art unless otherwise defined. It should be noted that the terms used herein should be interpreted as having a meaning consistent with the context of this specification and should not be interpreted in an idealized or overly rigid manner.
[0072] When using expressions such as "at least one of A, B, and C, etc.", they should generally be interpreted according to the meaning of the expression commonly understood by those skilled in the art (for example, "a system having at least one of A, B, and C" should include but is not limited to a system having A alone, B alone, C alone, A and B, A and C, B and C, and / or A, B, C, etc.).
[0073] In the embodiments of this application, the collection, updating, analysis, processing, use, transmission, provision, disclosure, storage, etc. of the data involved (for example, including but not limited to user personal information) are in compliance with the provisions of relevant laws and regulations, are used for legitimate purposes, and do not violate public order and good morals. In particular, necessary measures are taken for user personal information to prevent illegal access to user personal information data and maintain the security of user personal information and network security.
[0074] In the embodiments of the present application, before obtaining or collecting user personal information (such as a facial image), the user's authorization or consent is obtained.
[0075] Figure 1 An exemplary system architecture 100 to which a training method for a face anti-counterfeiting recognition model or a face anti-counterfeiting recognition method according to an embodiment of the present application can be applied is shown. It should be noted that: Figure 1 What is shown is merely an example of a system architecture to which the embodiments of the present application can be applied, in order to help those skilled in the art understand the technical content of the present application, but it does not mean that the embodiments of the present application cannot be used in other devices, systems, environments or scenarios.
[0076] like Figure 1 As shown, the system architecture 100 according to this embodiment may include a first terminal device 101, a second terminal device 102, a third terminal device 103, a network 104, and a server 105. The network 104 is used to provide a medium for a communication link between the first terminal device 101, the second terminal device 102, the third terminal device 103, and the server 105. The network 104 may include various connection types, such as wired and / or wireless communication links, etc.
[0077] The user may use the first terminal device 101, the second terminal device 102, and the third terminal device 103 to interact with the server 105 through the network 104 to receive or send messages, etc. Various communication client applications may be installed on the first terminal device 101, the second terminal device 102, and the third terminal device 103, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients, and / or social platform software, etc. (only for example).
[0078] The first terminal device 101, the second terminal device 102, and the third terminal device 103 may be various electronic devices having display screens and supporting web browsing, including but not limited to smart phones, tablet computers, laptop computers, desktop computers, and the like.
[0079] The server 105 may be a server that provides various services, such as a background management server (only as an example) that provides support for websites browsed by users using the first terminal device 101, the second terminal device 102, and the third terminal device 103. The background management server may analyze and process the received data such as user requests, and feed back the processing results (such as web pages, information, or data obtained or generated according to user requests) to the terminal device.
[0080] It should be noted that the training method of the face anti-counterfeiting recognition model or the face anti-counterfeiting recognition method provided in the embodiment of the present application can generally be executed by the server 105. Accordingly, the training device of the face anti-counterfeiting recognition model or the face anti-counterfeiting recognition device provided in the embodiment of the present application can generally be set in the server 105. The training method of the face anti-counterfeiting recognition model or the face anti-counterfeiting recognition method provided in the embodiment of the present application can also be executed by a server or server cluster that is different from the server 105 and can communicate with the first terminal device 101, the second terminal device 102, the third terminal device 103 and / or the server 105. Correspondingly, the training device of the face anti-counterfeiting recognition model or the face anti-counterfeiting recognition device provided in the embodiment of the present application can also be set in a server or server cluster that is different from the server 105 and can communicate with the first terminal device 101, the second terminal device 102, the third terminal device 103 and / or the server 105.
[0081] It should be understood that Figure 1 The number of terminal devices, networks and servers in the embodiment is only . According to the implementation requirements, there can be any number of terminal devices, networks and servers.
[0082] Figure 2 A flow chart of a method for training a face anti-counterfeiting recognition model according to an embodiment of the present application is shown.
[0083] like Figure 2 As shown, the training method of the face anti-counterfeiting recognition model includes operations S201~S203.
[0084] In operation S201, in response to a training instruction, a face anti-counterfeiting recognition training set is obtained, wherein the face anti-counterfeiting recognition training set includes a plurality of face anti-counterfeiting training images and a category label set, and the category label set includes a real face type label and a plurality of attack type labels;
[0085] In operation S202, the category tag set is processed using a pre-trained language model to obtain a context vector set, wherein the context vector set includes context prompt vectors corresponding to different types of tags;
[0086] In operation S203, the context vector set and the category label set are processed by the parameter prompt generation network to generate a text prompt set, wherein the text prompt set includes text prompt information corresponding to different types of labels;
[0087] In operation S204, for each face anti-counterfeiting training image, the face anti-counterfeiting training image and the text prompt set are processed by using an encoder network to generate image features and multiple text features respectively, wherein the initial anti-counterfeiting recognition model includes a pre-trained language model, a parameter prompt generation network and an encoder network;
[0088] In operation S205, sample similarity information between the image feature and the plurality of text features is calculated to generate a target loss value according to the plurality of sample similarity information;
[0089] In operation S206, the network parameters of the parameter prompt generation network are iteratively adjusted according to the target loss value, thereby obtaining a trained face anti-counterfeiting recognition model.
[0090] According to an embodiment of the present application, the training instruction may be input by a staff member on an electronic device such as a mobile phone or a computer, and the electronic device automatically generates the training instruction in response to the operation.
[0091] According to an embodiment of the present application, the pre-trained language model may be a text encoder of CLIP, which may be represented by M.
[0092] According to an embodiment of the present application, the category label set can be used indicates that K The label set includes a set of real face type labels and multiple known attack type labels (e.g., print attack type labels, replay attack type labels). and unknown attack type labels ,in The image set constructed by face anti-counterfeiting training images can be expressed as ,in represents the i-th face anti-counterfeiting training image, for Tags, is an element in the category label set, N s is the number of face anti-counterfeiting training images in the image collection.
[0093] According to the embodiment of the present application, a pre-trained language model is used to process a category label set to obtain a context vector set, and a parameter prompt generation network is used to process the context vector set and the category label set to generate a text prompt set. For each face anti-counterfeiting training image, an encoder network is used to process the face anti-counterfeiting training image and the text prompt set to generate image features and multiple text features, respectively. Thereafter, sample similarity information between the image features and the multiple text features is calculated to generate a target loss value based on the multiple sample similarity information, thereby iteratively adjusting the network parameters of the parameter prompt generation network based on the target loss value, thereby obtaining a trained face anti-counterfeiting recognition model.
[0094] According to an embodiment of the present application, a context vector set is obtained by processing a category label set using a pre-trained language model, and a context vector set and a category label set are processed using a parameter prompt generation network to generate a text prompt set. For each face anti-counterfeiting training image, an encoder network is used to process the face anti-counterfeiting training image and the text prompt set to generate image features and multiple text features, respectively. Thereafter, sample similarity information between the image features and the multiple text features is calculated to generate a target loss value based on the multiple sample similarity information, thereby iteratively updating according to the target loss value to obtain a face anti-counterfeiting recognition model. The face anti-counterfeiting recognition model generated by the pre-trained language model and the parameter prompt generation network in the present application can effectively improve the recognition accuracy of different attack types, while improving the recognition efficiency.
[0095] Figure 3 A flowchart of a method for training a face anti-counterfeiting recognition model according to another embodiment of the present application is shown.
[0096] like Figure 3 As shown, the pre-trained language model is used to process the category label set to obtain a context vector set, including:
[0097] For any type of label, use the pre-trained language model to process the attack type and obtain multiple context vectors;
[0098] Generate a context hint vector of the type label based on the multiple context vectors;
[0099] A context vector set is generated according to a plurality of context prompt vectors and a plurality of category vectors, wherein the plurality of category vectors represent different category labels.
[0100] According to the embodiment of the present application, two common attack types are selected as known attacks (i.e., print attack type labels and replay attack type labels), plus the category of real faces and unknown attack type labels, and the total number of categories k is 4. The corresponding class name set It is designed as {real face type label, print attack type label, replay attack type label, unknown attack type label}.
[0101] According to an embodiment of the present application, a pre-trained language model is used to process the attack type to obtain multiple context vectors. , given The k-th category label in (k∈{1,2,...,K}), which generates a contextual hint vector of the type label based on multiple context vectors , It consists of the token embedding of the prefix context sequence and the category name, as shown in formula (1):
[0102] (1)
[0103] Where L is the number of context tokens, (i∈{1,2,...,L}) represents the category label The i-th context vector of . The same type of samples (real faces or attack types) can vary in specific image appearance, depending on the acquisition device, lighting conditions, and acquisition background. In addition, the same type of attack usually has many variants that differ in some minor physical properties. For example, the exact implementation of a printing attack can be a photo attack printed on plain paper, a photo attack printed on coated paper, a photo attack with a local area cropped out, and a curved printed photo.
[0104] According to an embodiment of the present application, it is assumed that the category vector express Input vector. Based on multiple contextual hint vectors and multiple category vectors , generating a set of context vectors as shown in formula (2).
[0105] (2)
[0106] According to an embodiment of the present application, a parameter hint generation network includes a parameter predictor and a hint generator.
[0107] According to the embodiments of the present application, Figure 3 As shown, the parameter prompt generation network is used to process the context vector set and the category label set to generate a text prompt set, including:
[0108] Processing the context vector set using a parameter predictor to generate multiple category prior vectors;
[0109] A prompt generator is used to process multiple category prior vectors and category label sets to generate a text prompt set.
[0110] According to the embodiment of the present application, both the parameter predictor and the prompt generator are designed as lightweight networks for efficient training and can be simply implemented as two fully connected layers. In order to ensure the diversity of the generated text prompt information and retain the semantic meaning, the prompt generator needs to inject the category prior information into the input vector (i.e., the category vector )middle.
[0111] According to an embodiment of the present application, in order to generalize the prompts to these two variants in facial anti-spoofing, the prompt generator generates diverse text prompt information based on different input vectors of each attack type.
[0112] According to an embodiment of the present application, a context vector set is processed using a parameter predictor to generate multiple category prior vectors, including:
[0113] For any contextual cue vector, the contextual cue vector is processed by a parameter predictor to generate a Gaussian distribution set of the contextual cue vector, wherein the Gaussian distribution set includes a Gaussian distribution value, a mean and a variance of the Gaussian distribution value, and the mean and the variance represent category prior information;
[0114] A category prior vector of the contextual cue vector is generated according to the category prior information and the category vector.
[0115] According to an embodiment of the present application, a context hint vector is processed by a parameter predictor to generate a Gaussian distribution set of context hint vectors. Assume , Representation Class Gaussian distribution value of The mean and variance of . , It is generated by a learnable parameter predictor P, which takes the contextual cue vector as input. The output vector of the parameter predictor is ∈ Respectively represent category prior information and .
[0116] According to an embodiment of the present application, from the Gaussian distribution value Randomly sample from and Encoding to category vector In the above example, we generate the category prior vector for the contextual hint vector .
[0117] According to the embodiments of the present application, Figure 3 As shown, the prompt generator is used to process multiple category prior vectors and category label sets to generate a text prompt set, including:
[0118] Using the prompt generator to process multiple category prior vectors, multiple text sign information is obtained;
[0119] For each piece of text mark information, text prompt information is generated according to the text mark information and a type label corresponding to the text mark information.
[0120] According to an embodiment of the present application, a prompt generator is used to process multiple category prior vectors , and obtain multiple text token information (Generated Tokens). According to the text token information and the type label corresponding to the text token information {real face type label, print attack type label, replay attack type label, unknown attack type label}, generate text prompt information (Generated Prompts).
[0121] According to an embodiment of the present application, the encoder network includes an image encoder and a text encoder.
[0122] According to the embodiments of the present application, Figure 3 As shown in the figure, the encoder network is used to process the face anti-counterfeiting training image and text prompt set to generate image features and multiple text features, including:
[0123] Use the image encoder to process the face anti-counterfeiting training image to obtain image features;
[0124] The text prompt set is processed using a text encoder to obtain multiple text features.
[0125] According to the embodiments of the present application, in the training of the face anti-counterfeiting recognition model, unknown attack types usually appear in unseen fields. In order to improve the generalization ability of the face anti-counterfeiting recognition model, the present application trains the model to detect unknown attack types, rather than arbitrarily judging the unknown attack types as one of the known categories and causing performance degradation.
[0126] According to an embodiment of the present application, specifically, the present application adds an unknown attack type label to a category label set. Therefore, the number of categories in the category label set is expanded to K + 1, i.e., {real face type label, print attack type label, replay attack type label, unknown attack type label}. The optimization of the prompt generator and the parameter predictor is limited by the unknown perceptual learning specification, which includes known and unknown distinction specifications. The known and unknown distinction specifications are simply implemented by cross entropy loss. It is then necessary to pass the face anti-counterfeiting training image and the text prompt set to the image encoder I and the text encoder E, respectively. Thereby obtaining image features and multiple text features.
[0127] According to an embodiment of the present application, the attack type label includes a known type label and an unknown type label.
[0128] According to the embodiments of the present application, Figure 3 As shown, the sample similarity information between the image feature and the multiple text features is calculated to generate a target loss value according to the multiple sample similarity information, including:
[0129] For each text feature, a similarity vector and sample similarity information are generated based on the image features and text features;
[0130] Generate a known type loss value according to the similarity vector and the target type label, wherein the target type label includes a real face type label and a known type label;
[0131] Generate an unknown type loss value based on the similarity vector and the unknown type label;
[0132] Generate a target loss value based on the known type loss value and the unknown type loss value.
[0133] According to an embodiment of the present application, the set of known type tags is , the set of unknown type tags is .
[0134] According to the embodiment of the present application, according to the image features and text features , generate similarity vector and sample similarity information , as shown in formula (3):
[0135] (3)
[0136] where k∈{1, 2, ..., K + 1}, T is the transpose, Represents the similarity vector The kth element of . The similarity vector d is used as the logits of the known and unknown discriminant regularization. The known discriminant regularization restricts the class with the highest predicted probability in the similarity vector to the class of the sample. Thus, according to the similarity vector and the target type label, the known type loss value is generated. , as shown in formula (4):
[0137] (4)
[0138] in is a binary indicator, if for The i-th class of = 1; otherwise = 0. Meanwhile, the unknown discriminant regularization restricts the unknown labels with the second highest prediction probability in the similarity vector.
[0139] Specifically, the output dimension corresponding to the sample class needs to be deleted from the similarity vector d, and a masked K-dimensional similarity vector is obtained. Since the input sample does not belong to Any class in , and indeed All classes in are unknown, and the unknown discrimination regularization can be designed to convert the masked similarity vector Restricted to unknown tags ( The Kth class of ) gives the highest prediction probability, thereby generating the unknown type loss value based on the similarity vector and the unknown type label , as shown in formula (5):
[0140] (5)
[0141] in, or Represents the similarity vector between the image feature and the kth or jth category vector respectively.
[0142] According to an embodiment of the present application, during the training process, the parameters of the prompt generator and the parameter predictor are optimized to minimize The overall loss of is the target loss value.
[0143] Figure 4 A flow chart of a face anti-counterfeiting recognition method according to an embodiment of the present application is shown.
[0144] like Figure 4 As shown, the face anti-counterfeiting recognition method includes operations S401 to S404.
[0145] In operation S401, a face image to be identified and a category set are obtained, wherein the category set includes a real face type and multiple attack types;
[0146] In operation S402, the face image to be recognized and the category set are input into the face anti-counterfeiting recognition model, and the predicted similarity information corresponding to different types is output;
[0147] In operation S403, a plurality of prediction similarity information is normalized to obtain a plurality of prediction probabilities;
[0148] In operation S404, the type corresponding to the maximum value among the plurality of predicted probabilities is determined as the anti-counterfeiting identification type corresponding to the face image to be identified.
[0149] According to an embodiment of the present application, during use of the face anti-counterfeiting recognition model, the face image to be recognized and the category set are input into the model, thereby obtaining multiple predicted similarity information corresponding to each type of the face image to be recognized.
[0150] According to an embodiment of the present application, a normalized softmax operation is performed on the predicted similarity information under each type to obtain the predicted probability of the attack type. In the recognition process, face anti-spoofing is regarded as a binary classification problem. Multiple predicted probabilities of the attack type are added together as the final predicted probability of the deceptive face category. Finally, the type corresponding to the maximum value among the multiple predicted probabilities is determined as the anti-counterfeiting recognition type corresponding to the face image to be recognized.
[0151] According to an embodiment of the present application, a context vector set is obtained by processing a category label set using a pre-trained language model, and a context vector set and a category label set are processed using a parameter prompt generation network to generate a text prompt set. For each face anti-counterfeiting training image, an encoder network is used to process the face anti-counterfeiting training image and the text prompt set to generate image features and multiple text features, respectively. Thereafter, sample similarity information between the image features and the multiple text features is calculated to generate a target loss value based on the multiple sample similarity information, thereby iteratively updating according to the target loss value to obtain a face anti-counterfeiting recognition model. The face anti-counterfeiting recognition model generated by the pre-trained language model and the parameter prompt generation network in the present application can effectively improve the recognition accuracy of different attack types, while improving the recognition efficiency.
[0152] Figure 5 A block diagram of a training device for a face anti-counterfeiting recognition model according to an embodiment of the present application is shown.
[0153] like Figure 5 As shown, the training device 500 for the face anti-counterfeiting recognition model includes a first acquisition module 510, a first processing module 520, a second processing module 530, a third processing module 540, a calculation module 550, and a training module 560.
[0154] A first acquisition module 510 is used to acquire a face anti-counterfeiting recognition training set in response to a training instruction, wherein the face anti-counterfeiting recognition training set includes a plurality of face anti-counterfeiting training images and a category label set, and the category label set includes a real face type label and a plurality of attack type labels;
[0155] A first processing module 520 is used to process the category label set using a pre-trained language model to obtain a context vector set, wherein the context vector set includes context prompt vectors corresponding to different types of labels;
[0156] A second processing module 530 is used to generate a text prompt set by processing the context vector set and the category label set using the parameter prompt generation network, wherein the text prompt set includes text prompt information corresponding to different types of labels;
[0157] The third processing module 540 is used to process the face anti-counterfeiting training image and the text prompt set using the encoder network for each face anti-counterfeiting training image, and generate image features and multiple text features respectively, wherein the initial anti-counterfeiting recognition model includes a pre-trained language model, a parameter prompt generation network and an encoder network;
[0158] A calculation module 550, used to calculate sample similarity information between an image feature and a plurality of text features, so as to generate a target loss value according to the plurality of sample similarity information;
[0159] The training module 560 is used to iteratively adjust the network parameters of the parameter prompt generation network according to the target loss value, so as to obtain a trained face anti-counterfeiting recognition model.
[0160] According to an embodiment of the present application, a context vector set is obtained by processing a category label set using a pre-trained language model, and a context vector set and a category label set are processed using a parameter prompt generation network to generate a text prompt set. For each face anti-counterfeiting training image, an encoder network is used to process the face anti-counterfeiting training image and the text prompt set to generate image features and multiple text features, respectively. Thereafter, sample similarity information between the image features and the multiple text features is calculated to generate a target loss value based on the multiple sample similarity information, thereby iteratively updating according to the target loss value to obtain a face anti-counterfeiting recognition model. The face anti-counterfeiting recognition model generated by the pre-trained language model and the parameter prompt generation network in the present application can effectively improve the recognition accuracy of different attack types, while improving the recognition efficiency.
[0161] According to an embodiment of the present application, the attack type label includes a print attack type label, a replay attack type label, and an unknown attack type label.
[0162] According to an embodiment of the present application, the first processing module 520 includes:
[0163] A first processing unit is used to process the attack type using a pre-trained language model for any type of label to obtain multiple context vectors;
[0164] A first generating unit, configured to generate a context prompt vector of a type label according to a plurality of context vectors;
[0165] The second generating unit is used to generate a context vector set according to the multiple context prompt vectors and the multiple category vectors, wherein the multiple category vectors represent different category labels.
[0166] According to an embodiment of the present application, a parameter hint generation network includes a parameter predictor and a hint generator.
[0167] According to an embodiment of the present application, the second processing module 530 includes:
[0168] A second processing unit, configured to process the context vector set using a parameter predictor to generate a plurality of category prior vectors;
[0169] The third processing unit is used to process multiple category prior vectors and category label sets using the prompt generator to generate a text prompt set.
[0170] According to an embodiment of the present application, the second processing unit includes:
[0171] A first generating subunit is used for processing the context prompt vector using a parameter predictor for any context prompt vector to generate a Gaussian distribution set of the context prompt vector, wherein the Gaussian distribution set includes a Gaussian distribution value, a mean and a variance of the Gaussian distribution value, and the mean and the variance represent category prior information;
[0172] The second generating subunit is used to generate a category priori vector of the context prompt vector according to the category priori information and the category vector.
[0173] According to an embodiment of the present application, the third processing unit includes:
[0174] A third generating subunit is used for processing a plurality of category prior vectors by using a prompt generator to obtain a plurality of text mark information;
[0175] The fourth generating subunit is used to generate text prompt information for each text mark information according to the text mark information and the type label corresponding to the text mark information.
[0176] According to an embodiment of the present application, the encoder network includes an image encoder and a text encoder.
[0177] According to an embodiment of the present application, the third processing module 540 includes:
[0178] A fourth processing unit, used for processing the face anti-counterfeiting training image by using an image encoder to obtain image features;
[0179] The fifth processing unit is used to process the text prompt set using a text encoder to obtain a plurality of text features.
[0180] According to an embodiment of the present application, the attack type label includes a known type label and an unknown type label.
[0181] According to an embodiment of the present application, the calculation module 550 includes:
[0182] A third generating unit is used to generate a similarity vector and sample similarity information for each text feature according to the image feature and the text feature;
[0183] A fourth generating unit, configured to generate a known type loss value according to the similarity vector and the target type label, wherein the target type label includes a real face type label and a known type label;
[0184] A fifth generating unit, used for generating an unknown type loss value according to the similarity vector and the unknown type label;
[0185] The sixth generating unit is used to generate a target loss value according to a known type loss value and an unknown type loss value.
[0186] Figure 6 A block diagram of a face anti-counterfeiting recognition device according to an embodiment of the present application is shown.
[0187] like Figure 6 As shown, the face anti-counterfeiting recognition device 600 includes a second acquisition module 610, an obtaining module 620, a normalization module 630, and a determination module 640.
[0188] A second acquisition module 610 is used to acquire a face image to be identified and a category set, wherein the category set includes a real face type and multiple attack types;
[0189] Obtaining module 620, for inputting the face image to be identified and the category set into the face anti-counterfeiting recognition model, and outputting predicted similarity information corresponding to different types;
[0190] A normalization module 630 is used to perform normalization processing on multiple prediction similarity information to obtain multiple prediction probabilities;
[0191] The determination module 640 is used to determine the type corresponding to the maximum value among the multiple predicted probabilities as the anti-counterfeiting identification type corresponding to the face image to be identified.
[0192] According to an embodiment of the present application, a context vector set is obtained by processing a category label set using a pre-trained language model, and a context vector set and a category label set are processed using a parameter prompt generation network to generate a text prompt set. For each face anti-counterfeiting training image, an encoder network is used to process the face anti-counterfeiting training image and the text prompt set to generate image features and multiple text features, respectively. Thereafter, sample similarity information between the image features and the multiple text features is calculated to generate a target loss value based on the multiple sample similarity information, thereby iteratively updating according to the target loss value to obtain a face anti-counterfeiting recognition model. The face anti-counterfeiting recognition model generated by the pre-trained language model and the parameter prompt generation network in the present application can effectively improve the recognition accuracy of different attack types, while improving the recognition efficiency.
[0193] According to the embodiments of the present application, any one or more of the modules, submodules, units, and subunits, or at least part of the functions of any one of them can be implemented in one module. According to the embodiments of the present application, any one or more of the modules, submodules, units, and subunits can be split into multiple modules for implementation. According to the embodiments of the present application, any one or more of the modules, submodules, units, and subunits can be at least partially implemented as hardware circuits, such as field programmable gate arrays (FPGAs), programmable logic arrays (PLAs), systems on chips, systems on substrates, systems on packages, application specific integrated circuits (ASICs), or can be implemented by hardware or firmware in any other reasonable way of integrating or packaging the circuit, or in any one of the three implementation methods of software, hardware, and firmware, or in any appropriate combination of any of them. Alternatively, according to the embodiments of the present application, one or more of the modules, submodules, units, and subunits can be at least partially implemented as computer program modules, and when the computer program modules are run, the corresponding functions can be executed.
[0194] For example, any of the first acquisition module 510, the first processing module 520, the second processing module 530, the third processing module 540, the calculation module 550, the training module 560, or the second acquisition module 610, the acquisition module 620, the normalization module 630, and the determination module 640 can be combined in one module / unit / sub-unit for implementation, or any one of the modules / units / sub-units can be split into multiple modules / units / sub-units. Alternatively, at least part of the functions of one or more of these modules / units / sub-units can be combined with at least part of the functions of other modules / units / sub-units and implemented in one module / unit / sub-unit. According to an embodiment of the present application, at least one of the first acquisition module 510, the first processing module 520, the second processing module 530, the third processing module 540, the calculation module 550, the training module 560, or the second acquisition module 610, the obtaining module 620, the normalization module 630, and the determination module 640 can be at least partially implemented as a hardware circuit, such as a field programmable gate array (FPGA), a programmable logic array (PLA), a system on a chip, a system on a substrate, a system on a package, an application-specific integrated circuit (ASIC), or can be implemented by hardware or firmware such as any other reasonable way of integrating or packaging the circuit, or can be implemented in any one of the three implementation methods of software, hardware, and firmware, or in an appropriate combination of any of them. Alternatively, the first acquisition module 510, the first processing module 520, the second processing module 530, the third processing module 540, the calculation module 550, the training module 560, or at least one of the second acquisition module 610, the obtaining module 620, the normalization module 630, and the determination module 640 can be at least partially implemented as a computer program module, which can perform corresponding functions when the computer program module is executed.
[0195] It should be noted that the training device or the face anti-counterfeiting recognition device part of the face anti-counterfeiting recognition model in the embodiments of the present application corresponds to the training method or the face anti-counterfeiting recognition method part of the face anti-counterfeiting recognition model in the embodiments of the present application. The description of the training device or the face anti-counterfeiting recognition device part of the face anti-counterfeiting recognition model specifically refers to the training method or the face anti-counterfeiting recognition method part of the face anti-counterfeiting recognition model, and will not be repeated here.
[0196] Figure 7 A block diagram of an electronic device suitable for implementing the method described above according to an embodiment of the present application is shown. Figure 7 The electronic device shown is merely an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.
[0197] like Figure 7As shown, the electronic device 700 according to an embodiment of the present application includes a processor 701, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 702 or a program loaded from a storage part 708 to a random access memory (RAM) 703. The processor 701 may include, for example, a general-purpose microprocessor (such as a CPU), an instruction set processor and / or a related chipset and / or a special-purpose microprocessor (for example, an application-specific integrated circuit (ASIC)), etc. The processor 701 may also include an onboard memory for caching purposes. The processor 701 may include a single processing unit or multiple processing units for performing different actions of the method flow according to an embodiment of the present application.
[0198] In RAM 703, various programs and data required for the operation of electronic device 700 are stored. Processor 701, ROM 702 and RAM 703 are connected to each other via bus 704. Processor 701 performs various operations of the method flow according to the embodiment of the present application by executing the program in ROM 702 and / or RAM 703. It should be noted that the program can also be stored in one or more memories other than ROM 702 and RAM 703. Processor 701 can also perform various operations of the method flow according to the embodiment of the present application by executing the program stored in the one or more memories.
[0199] According to an embodiment of the present application, the electronic device 700 may further include an input / output (I / O) interface 705, which is also connected to the bus 704. The electronic device 700 may further include one or more of the following components connected to the input / output (I / O) interface 705: an input portion 706 including a keyboard, a mouse, etc.; an output portion 707 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage portion 708 including a hard disk, etc.; and a communication portion 709 including a network interface card such as a LAN card, a modem, etc. The communication portion 709 performs communication processing via a network such as the Internet. A drive 710 is also connected to the input / output (I / O) interface 705 as needed. A removable medium 711, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 710 as needed, so that a computer program read therefrom is installed into the storage portion 708 as needed.
[0200] According to an embodiment of the present application, the method flow according to the embodiment of the present application can be implemented as a computer software program. For example, an embodiment of the present application includes a computer program product, which includes a computer program carried on a computer-readable storage medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 709, and / or installed from the removable medium 711. When the computer program is executed by the processor 701, the above-mentioned functions defined in the system of the embodiment of the present application are executed. According to an embodiment of the present application, the system, equipment, device, module, unit, etc. described above can be implemented by a computer program module.
[0201] The present application also provides a computer-readable storage medium, which may be included in the device / apparatus / system described in the above embodiments; or may exist independently without being assembled into the device / apparatus / system. The above computer-readable storage medium carries one or more programs, and when the above one or more programs are executed, the method according to the embodiment of the present application is implemented.
[0202] According to an embodiment of the present application, the computer-readable storage medium may be a non-volatile computer-readable storage medium. For example, it may include, but is not limited to: a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof. In the present application, a computer-readable storage medium may be any tangible medium containing or storing a program that may be used by or in combination with an instruction execution system, apparatus, or device.
[0203] For example, according to an embodiment of the present application, the computer-readable storage medium may include the ROM 702 and / or the RAM 703 described above and / or one or more memories other than the ROM 702 and the RAM 703 .
[0204] An embodiment of the present application also includes a computer program product, which includes a computer program, which contains program code for executing the method provided by the embodiment of the present application. When the computer program product runs on an electronic device, the program code is used to enable the electronic device to implement the method provided by the embodiment of the present application.
[0205] When the computer program is executed by the processor 701, the above functions defined in the system / device of the embodiment of the present application are executed. According to the embodiment of the present application, the system, device, module, unit, etc. described above can be implemented by a computer program module.
[0206] In one embodiment, the computer program may rely on tangible storage media such as optical storage devices, magnetic storage devices, etc. In another embodiment, the computer program may also be transmitted and distributed in the form of signals on a network medium, and downloaded and installed through the communication part 709, and / or installed from the removable medium 711. The program code contained in the computer program may be transmitted using any appropriate network medium, including but not limited to: wireless, wired, etc., or any suitable combination of the above.
[0207] According to an embodiment of the present application, the program code for executing the computer program provided by the embodiment of the present application can be written in any combination of one or more programming languages, and specifically, these computing programs can be implemented using high-level process and / or object-oriented programming languages, and / or assembly / machine languages. Programming languages include, but are not limited to, such as Java, C++, python, "C" language or similar programming languages. The program code can be executed entirely on the user computing device, partially on the user device, partially on the remote computing device, or completely on the remote computing device or server. In the case of a remote computing device, the remote computing device can be connected to the user computing device through any type of network, including a local area network (LAN) or a wide area network (WAN), or can be connected to an external computing device (e.g., using an Internet service provider to connect through the Internet).
[0208] The flowcharts and block diagrams in the accompanying drawings illustrate the possible architecture, functions and operations of the systems, methods and computer program products according to various embodiments of the present application. In this regard, each box in the flowchart or block diagram may represent a module, a program segment, or a part of a code, and the above-mentioned module, program segment, or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box may also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they may sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flowchart, and the combination of the boxes in the block diagram or flowchart, can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions. It will be appreciated by those skilled in the art that the features recorded in the various embodiments of the present application can be combined and / or combined in a variety of ways, even if such a combination or combination is not clearly recorded in the present application. In particular, without departing from the spirit and teachings of the present application, the features described in the various embodiments of the present application may be combined and / or combined in a variety of ways. All of these combinations and / or combinations fall within the scope of the present application.
[0209] The embodiments of the present application are described above. However, these embodiments are only for the purpose of illustration, and are not intended to limit the scope of the present application. Although each embodiment is described above, this does not mean that the measures in each embodiment cannot be used in combination advantageously. Without departing from the scope of the present application, those skilled in the art may make a variety of substitutions and modifications, which should all fall within the scope of the present application.
Claims
1. A training method for a face anti-counterfeiting recognition model, characterized in that: include: In response to the training instruction, a face anti-counterfeiting recognition training set is obtained, wherein the face anti-counterfeiting recognition training set includes a plurality of face anti-counterfeiting training images and a category label set, the category label set includes a real face type label and a plurality of attack type labels, and the attack type labels include a known type label and an unknown type label; Processing the category label set using a pre-trained language model to obtain a context vector set, wherein the context vector set includes context prompt vectors corresponding to different types of labels; Processing the context vector set and the category label set using a parameter prompt generation network to generate a text prompt set, wherein the text prompt set includes text prompt information corresponding to different types of labels; For each of the face anti-counterfeiting training images, the face anti-counterfeiting training image and the text prompt set are processed by an encoder network to generate image features and multiple text features respectively, wherein the initial anti-counterfeiting recognition model includes the pre-trained language model, the parameter prompt generation network and the encoder network; Calculating sample similarity information between the image feature and the plurality of text features to generate a target loss value according to the plurality of sample similarity information; Iteratively adjusting the network parameters of the parameter prompt generation network according to the target loss value, thereby obtaining a trained face anti-counterfeiting recognition model; Wherein, the parameter prompt generation network includes a parameter predictor and a prompt generator; The process of using a parameter prompt generation network to process the context vector set and the category label set to generate a text prompt set includes: Processing the context vector set using the parameter predictor to generate a plurality of category prior vectors; Processing a plurality of the category prior vectors and the category label set using the prompt generator to generate the text prompt set; The parameter predictor is used to process the context vector set to generate multiple category prior vectors, including: For any context hint vector, use the parameter predictor to process the context hint vector to generate a Gaussian distribution set of the context hint vector, wherein the Gaussian distribution set includes Gaussian distribution values, means and variances of the Gaussian distribution values, and the means and variances represent category prior information; Generating the category prior vector of the context prompt vector according to the category prior information and the category vector; The step of processing the plurality of category prior vectors and the category label set by the prompt generator to generate the text prompt set includes: Processing a plurality of the category prior vectors using the prompt generator to obtain a plurality of text mark information; For each piece of text mark information, the text prompt information is generated according to the text mark information and a type label corresponding to the text mark information.
2. The method according to claim 1, characterized in that The attack type labels include print attack type labels, replay attack type labels and unknown attack type labels; The pre-trained language model is used to process the category label set to obtain a context vector set, including: For any type of label, use the pre-trained language model to process the attack type to obtain multiple context vectors; Generating the context hint vector of the type tag according to the plurality of context vectors; The context vector set is generated according to a plurality of the context prompt vectors and a plurality of category vectors, wherein the plurality of category vectors represent different category labels.
3. The method according to claim 1, characterized in that The encoder network includes an image encoder and a text encoder; The encoder network is used to process the face anti-counterfeiting training image and the text prompt set to generate image features and multiple text features, respectively, including: Processing the face anti-counterfeiting training image using the image encoder to obtain image features; The text prompt set is processed by the text encoder to obtain a plurality of text features.
4. The method according to claim 1 or 3, characterized in that: Calculating sample similarity information between the image feature and the plurality of text features to generate a target loss value according to the plurality of sample similarity information includes: For each of the text features, generating a similarity vector and sample similarity information according to the image features and the text features; Generate a known type loss value according to the similarity vector and the target type label, wherein the target type label includes the real face type label and the known type label; Generate an unknown type loss value according to the similarity vector and the unknown type label; The target loss value is generated according to the known type loss value and the unknown type loss value.
5. A face anti-counterfeiting recognition method, characterized in that: include: Obtaining a face image to be identified and a category set, wherein the category set includes a real face type and multiple attack types; Inputting the face image to be identified and the category set into a face anti-counterfeiting recognition model, and outputting predicted similarity information corresponding to different types, wherein the face anti-counterfeiting recognition model is trained by the method described in any one of claims 1 to 4; Normalizing the plurality of prediction similarity information to obtain a plurality of prediction probabilities; The type corresponding to the maximum value among the multiple predicted probabilities is determined as the anti-counterfeiting identification type corresponding to the face image to be identified.
6. A training device for a face anti-counterfeiting recognition model, characterized in that: include: A first acquisition module is used to acquire a face anti-counterfeiting recognition training set in response to a training instruction, wherein the face anti-counterfeiting recognition training set includes a plurality of face anti-counterfeiting training images and a category label set, the category label set includes a real face type label and a plurality of attack type labels, and the attack type label includes a known type label and an unknown type label; A first processing module, configured to process the category label set using a pre-trained language model to obtain a context vector set, wherein the context vector set includes context prompt vectors corresponding to different types of labels; A second processing module is used to process the context vector set and the category label set using a parameter prompt generation network to generate a text prompt set, wherein the text prompt set includes text prompt information corresponding to different types of labels; a third processing module, for processing the face anti-counterfeiting training image and the text prompt set using an encoder network for each of the face anti-counterfeiting training images, and generating image features and a plurality of text features respectively, wherein the initial anti-counterfeiting recognition model includes the pre-trained language model, the parameter prompt generation network and the encoder network; A calculation module, used for calculating sample similarity information between the image feature and the plurality of text features, so as to generate a target loss value according to the plurality of sample similarity information; A training module, used for iteratively adjusting the network parameters of the parameter prompt generation network according to the target loss value, so as to obtain a trained face anti-counterfeiting recognition model; Wherein, the parameter prompt generation network includes a parameter predictor and a prompt generator; Wherein, the second processing module includes: A second processing unit, configured to process the context vector set using a parameter predictor to generate a plurality of category prior vectors; A third processing unit is used to process the plurality of category prior vectors and the category label set using the prompt generator to generate a text prompt set; Wherein, the second processing unit includes: A first generating subunit is used for processing the context prompt vector using a parameter predictor for any context prompt vector to generate a Gaussian distribution set of the context prompt vector, wherein the Gaussian distribution set includes a Gaussian distribution value, a mean and a variance of the Gaussian distribution value, and the mean and the variance represent category prior information; A second generating subunit, configured to generate a category prior vector of the context prompt vector according to the category prior information and the category vector; Wherein, the third processing unit includes: A third generating subunit is used for processing a plurality of category prior vectors by using a prompt generator to obtain a plurality of text mark information; The fourth generating subunit is used to generate text prompt information for each text mark information according to the text mark information and the type label corresponding to the text mark information.
7. A face anti-counterfeiting recognition device, characterized in that: include: A second acquisition module is used to acquire a face image to be identified and a category set, wherein the category set includes a real face type and multiple attack types; An obtaining module, used for inputting the face image to be identified and the category set into a face anti-counterfeiting recognition model, and outputting predicted similarity information corresponding to different types, wherein the face anti-counterfeiting recognition model is trained by the method according to any one of claims 1 to 4; A normalization module, used for normalizing the plurality of prediction similarity information to obtain a plurality of prediction probabilities; A determination module is used to determine the type corresponding to the maximum value among the multiple predicted probabilities as the anti-counterfeiting identification type corresponding to the face image to be identified.
