Generalized face forgery detection method based on domain-invariant features
Through the combination of the feature distribution difference minimization network and the optimal classifier distance minimization network, the simulation divides the virtual domain and iteratively optimizes it, solving the problem of the detection performance of the existing face forgery detection method declining between different domains, and achieving better Generalization ability and detection effect.
Patent Information
- Application Number
- CN202210276512.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-03-21
- Publication Date
- 2024-09-20
- Estimated Expiration
- 2042-03-21
AI Technical Summary
When existing face forgery detection methods come from different face forgery technologies in the training set and test set, the detection performance drops significantly, and it is difficult to effectively utilize multiple known source domain data sets to eliminate data distribution deviations to improve the generalization ability of the model.
A generalized face forgery detection method based on domain-invariant features is adopted, and the feature distribution difference minimization network FDDM and the optimal classifier distance minimization network OCDM are used to simulate the division of the virtual source domain and the virtual target domain, learn domain sharing features and adjust Classifier distance, iterative optimization to improve model generalization performance.
It significantly improves the generalization performance of the model in unknown target domains, is superior to existing face forgery detection methods, and can detect face forgery images more effectively.
Smart Images

Figure CN114692741B
Abstract
Description
Technical Field
[0001] The invention relates to the technical field of multimedia, and in particular to a generalized face forgery detection method based on domain invariant features. Background Art
[0002] With the continuous development of information technology, images, videos, audio, etc. have become the main carriers of information dissemination. However, with the development of deep learning, it has become easier to forge images and videos. People only need to use some advanced deep learning tools such as adversarial generative networks to easily create forged pictures or videos that are difficult to identify with the naked eye. Since facial information is very important, a series of forged face images have emerged, which serve the purpose of deceiving others and spreading rumors. Therefore, how to effectively detect forged face images has become a hot research direction in the field of image forensics.
[0003] The face forgery detection task can be regarded as a binary classification task, that is, to determine whether the image is a face forgery image by extracting the tampering traces in the input image. Benefiting from the development of deep learning, most of the current face forgery detection methods are based on deep learning methods. These methods usually use feature transformation networks to extract tampering traces in the input image, and then use a classifier to obtain a binary classification result, that is, whether the input face is a forged face. When the training set and the test set are both from the same face forgery technology, these methods can achieve good detection results. However, when the training set and the test set are generated by different face forgery technologies, different face forgery technologies may leave different tampering traces, so the performance of these face forgery detection methods has dropped significantly to varying degrees. Recently, some work has also appeared to solve the generalization problem of face forgery detection. These methods that combine the ideas of domain transfer or domain generalization have improved the generalization performance of the model to a certain extent, but there is still a lot of room for improvement. Therefore, how to better utilize the datasets of multiple known source domains and eliminate the deviations between their data distributions to learn common discriminant features to further improve the generalization ability of the model is still a great challenge. Summary of the invention
[0004] The purpose of the present invention is to overcome the shortcomings and deficiencies of the prior art, and propose a generalized face forgery detection method based on domain-invariant features. The method architecture includes a feature distribution difference minimization network FDDM and an optimal classifier distance minimization network OCDM. First, multiple known source domain data sets are simulated and divided into virtual source domains and virtual target domains, and then FDDM is used to minimize the feature distribution difference between the virtual source domain and the virtual target domain to learn domain shared features, and then the domain shared feature space is adjusted through OCDM to reduce the optimal classifier distance between the virtual source domain and the virtual target domain. By continuously iteratively randomly dividing the virtual source domain and the virtual target domain, and using FDDM and OCDM, it is possible to learn a suitable domain-invariant representation and greatly improve the generalization performance of the model on an unknown target domain.
[0005] To achieve the above object, the technical solution provided by the present invention is: a generalized face forgery detection method based on domain-invariant features, comprising the following steps:
[0006] 1) Build a training image set
[0007] A large number of forged face images and corresponding normal face images generated by different forged face methods are obtained, all of which are scaled to the same size and divided into different source domain data sets according to the different forged face generation methods; these different source domain data sets are summarized to obtain a training image set;
[0008] 2) Using the training image set constructed in step 1) to train the constructed face forgery detection network for domain-invariant feature representation learning, and obtaining the weight parameters of the face forgery detection network for domain-invariant feature representation learning; wherein the face forgery detection network includes a feature distribution difference minimization network FDDM and an optimal classifier distance minimization network OCDM; firstly, multiple source domain data sets in the constructed training image set are simulated and divided into virtual source domains and virtual target domains, and then FDDM learns shared domain-shared features from the divided virtual source domains and virtual target domains in a decoupled manner, and OCDM further adjusts the learned domain-shared features to convert them into domain-invariant features, and through continuous iterative random division of the virtual source domain and the virtual target domain, and using FDDM and OCDM, a suitable domain-invariant feature representation is obtained to perform generalized face forgery detection;
[0009] 3) Apply the face forgery detection network learned by domain-invariant feature representation constructed in step 2) and the weight parameters of the face forgery detection network learned by optimal domain-invariant feature representation to give a prediction result for the input image to be tested, that is, whether the input image is a face forgery image.
[0010] Further, in step 1), a large number of forged face images and corresponding normal face images generated by different face forging methods are scaled to a size of H×W, where H and W are the length and width of the image, respectively; and these forged face images and corresponding normal face images are divided into different source domain data sets according to the different generated face forging methods. For the M source domain data sets S={S i |i=1,2,...M}, where S i Represents the i-th source domain dataset, which contains Num i images.
[0011] Further, the step 2) comprises the following steps:
[0012] 2.1) The M source domain datasets S in the constructed training image set are simulated and divided into virtual source domains S v and the virtual target domain T v ;
[0013] 2.2) Constructing a feature distribution difference minimization network FDDM in a face forgery detection network for domain invariant feature representation learning. The feature distribution difference minimization network FDDM includes a feature extractor g e , Decoder Feature selection s , class discriminator d ψ , classifier C and M domain discriminators d μ i ,i∈{1,2,...,M};feature extractor g e and decoder Both are composed of multiple convolutional modules stacked together. The difference is that the feature extractor g e Each convolutional module is followed by a maximum pooling layer, and the decoder Each convolutional module is followed by an upsampling layer; feature selection g s It is a one-step feature division operation and does not contain a specific network structure; the class discriminator d ψ and domain discriminator d μ i The network structures of are the same, they are all composed of multiple convolutional modules stacked together; the classifier C is composed of multiple convolutional modules, an average pooling layer and a fully connected layer;
[0014] For the virtual source domain S v and the virtual target domain T v The jth input image x is obtained randomly j , feature Z_ex j is obtained through the feature extractor g e From the input image x jThe extracted features are converted into features Z_ex j Input to decoder To obtain the reconstructed image, and by minimizing the mean square error loss L between the input image and the reconstructed image rec Constrain it so that the feature extractor extracts complete information of the input image:
[0015]
[0016] Where N represents the number of samples selected from the virtual source domain and the virtual target domain this time; feature Z_ex j Through feature selection g s Divided into features Z_ir j and the characteristic Z_ds j ; Feature Z_ds j It is used as the input of the classifier C to predict the label of the input image and minimize the cross entropy loss L between the predicted result of the input image and the label of the input image. cls To constrain feature Z_ds j Representative class related features:
[0017]
[0018] In the formula, y j represents the label of the jth input image; and the feature Z_ir j As the class discriminator d ψ The input is also used to predict the label of the input image, and by minimizing the negative cross entropy loss L between the predicted result of the input image and the label of the input image cdis To constrain the feature Z_ir j Representative class-independent features:
[0019]
[0020] Then, the feature Z_ir is transformed into j and the characteristic Z_ds j Both are used as inputs to the class discriminator to predict the label of the input image and minimize the cross entropy loss L between the predicted result of the input image and the label of the input image ent To train the class discriminator d ψ The feature Z_ir j and the characteristic Z_ds j The two are decoupled from each other:
[0021]
[0022] In the formula, represents the indicator function, k represents the classification category, that is, the prediction task is a binary classification task, and the domain discriminator dμ i Without considering the virtual source domain and the virtual target domain, we directly minimize the feature Z_ds of each domain from the source domain dataset. j The distribution difference makes the feature Z_ds j is the domain shared feature shared by M source domain datasets; for the i-th domain discriminator d μ i , used to discriminate the feature Z_ds j Whether it belongs to the i-th source domain dataset, its corresponding loss function L dis i It is expressed as:
[0023]
[0024] In the formula, Z_ds j i represents the features of the jth input image from the ith domain, and correspondingly, Z_ds j r represents the features of the jth input image from the rth domain, and r≠i; combined with the loss function of the M domain discriminators, the feature Z_ds from the i-th domain is j i The feature distribution difference with the remaining M-1 source domain data sets is the smallest; the loss function L of the M discriminators dis It is expressed as:
[0025]
[0026] The loss function L of the overall optimization objective of FDDM FDDM for:
[0027] L FDDM =L rec +L cdis +L cls +L dis (7)
[0028] 2.3) Constructing the optimal classifier distance minimization network OCDM in the face forgery detection network of domain invariant feature representation learning. The optimal classifier distance minimization network OCDM is composed of the feature extractor g e , feature selector g s and classifier h, where the feature extractor g e , feature selector g s They all come from the feature distribution difference minimization network FDDM. The classifier h consists of multiple convolutional modules, an average pooling layer and a fully connected layer; the OCDM network adjusts the optimal virtual source domain classifier through a two-stage update method and the optimal virtual target domain classifier The distance between them is used to adjust the learned domain-shared features to obtain domain-invariant features;
[0029] In the first stage, for the virtual source domain S v The jth input image is obtained randomly Use it as the input of OCDM to predict the label of the input image and minimize the cross entropy loss L between the predicted result of the input image and the label of the input image Meta-train :
[0030]
[0031] In the formula, l represents the cross entropy loss function, Φ(g e ,h) represents the feature extractor g in OCDM e and the weight parameters of the classifier h, and For the input image Corresponding labels; OCDM relative to the loss function L Meta-train The gradient of The feature extractor g in OCDM is transformed by this gradient e And the weight parameters of classifier h are updated as Where α represents the step size of this update;
[0032] In the second stage, for the virtual source domain T v The jth input image is obtained randomly It is used as the input of the first stage updated OCDM to predict the label of the input image and minimize the cross entropy loss L between the predicted result of the input image and the label of the input image Meta-test :
[0033]
[0034] In the formula, For the input image The corresponding label;
[0035] The loss function L of the overall optimization objective of OCDM OCDM for:
[0036]
[0037] In the formula, β represents the ratio parameter to balance the ratio of the loss functions of the two stages of OCDM;
[0038] 2.4) Initialize the weight parameters of each part in the feature distribution difference minimization network FDDM and the optimal classifier distance minimization network OCDM in the face forgery detection network for domain invariant feature representation learning, including the feature extractor g e The weight parameter Decoder The weight parameter Class Discriminator d ψ and M domain discriminators d μ i The weight parameter and The weight parameter W of classifier C and classifier h C and W h ; Initialize the number of iterations e = 1;
[0039] 2.5) Randomly divide the M source domain datasets S in the constructed training image set into virtual source domains S v and the virtual target domain T v ; Initialize the number of iterations t = 1;
[0040] 2.6) Fixed class discriminator d in FDDM ψ and M domain discriminators d μ i The weight parameter of the virtual source domain S v and the virtual target domain T v Randomly select N samples to form training pairs and calculate the loss function L of the overall optimization objective of FDDM FDDM ; According to the calculated loss function L of the overall optimization objective of FDDM FDDM To calculate the feature extractor g in FDDM respectively e , Decoder And the gradient of classifier C and back-propagate to update the weight parameters of each part:
[0041]
[0042]
[0043]
[0044] In formulas (11), (12) and (13), η is a given learning rate, and Represent the feature extractor g e , Decoder and the gradient of the classifier C;
[0045] 2.7) Fix the feature extractor g in FDDM e The weight parameter of the virtual source domain S v and the virtual target domain T v Randomly select N samples to form training pairs and calculate the loss function L of formula (4) ent And the M domain discriminators d of formula (5) μi The loss function L dis i ; According to the loss function L ent Calculate the class discriminator d in FDDM ψ The gradient of the classifier d is back-propagated to update the class discriminator ψ The weight parameters are:
[0046]
[0047] In the formula, is the class discriminator d ψ The gradient of; because there are M domain discriminators d μ i , that is, the weight parameters of each domain discriminator need to be updated separately, the i-th domain discriminator d μ i The weight parameter update process is expressed as:
[0048]
[0049] In the formula, is the i-th domain discriminator d μ i The gradient of
[0050] 2.8) From the virtual source domain S v and the virtual target domain T v Randomly select N samples to form training pairs and calculate the loss function L of the overall optimization objective of OCDM OCDM ; According to the calculated loss function L of the overall optimization objective of OCDM OCDM To calculate the feature extractor g in OCDM respectively e And the gradient of the classifier h and back-propagate to update the weight parameters of each part:
[0051]
[0052]
[0053] In formulas (16) and (17), and Represent the feature extractor g e and the gradient of the classifier h;
[0054] 2.9) Update the number of iterations t = t + 1, and determine whether the iteration condition is met in and They are virtual source domains S v and the virtual target domain T vThe total number of samples, N is the number of samples in each iteration; if the conditions are met, go to step 2.6); otherwise, go to step 2.10);
[0055] 2.10) Update the number of iterations e=e+1, and determine whether the iteration condition satisfies e≤E, where E represents the number of training epochs; if so, go to step 2.5); otherwise, save the weight parameters of the face forgery detection network learned by the optimal domain-invariant feature representation at this time and exit the iteration.
[0056] Compared with the prior art, the present invention has the following advantages and beneficial effects:
[0057] 1. The present invention proposes a feature distribution difference minimization network FDDM which minimizes the feature distribution differences from various source domains through the idea of joint decoupling and generative adversarial training, thereby extracting domain-shared features shared by multiple source domains.
[0058] 2. The present invention proposes an optimal classifier distance minimization network OCDM which further adjusts the given feature space through the idea of meta-learning, so that an ideal classifier can be learned on this feature space, which is both the optimal virtual source domain classifier and the optimal virtual target domain classifier.
[0059] 3. By combining FDDM and OCDM, the present invention can learn a suitable domain-invariant feature representation from multiple source domain datasets, which can effectively improve the generalization performance of the model in unknown target domains and is superior to a series of existing face forgery detection methods. BRIEF DESCRIPTION OF THE DRAWINGS
[0060] Figure 1 Schematic diagram of the method of the present invention.
[0061] Figure 2 The network structure diagram of the feature distribution difference minimization network FDDM.
[0062] Figure 3 The network architecture diagram of the optimal classifier distance minimization network OCDM. DETAILED DESCRIPTION
[0063] The present invention is further described in detail below in conjunction with embodiments and drawings, but the embodiments of the present invention are not limited thereto.
[0064] See also Figure 1 As shown, this embodiment provides a generalized face forgery detection method based on domain-invariant features, which specifically includes the following main technical steps:
[0065] 1) Build a training image set
[0066] This example uses FaceForensics++, the largest face forgery benchmark dataset, as the experimental dataset. The FaceForensics++ dataset contains datasets generated by four different face forgery methods, namely FaceSwap, Deepfakes, Face2Face, and NeuralTextures. Each dataset generated by a different face forgery method contains 1,000 forged videos and 1,000 real videos. For each video, we extract 30 frames of images at equal intervals and automatically crop the face area of each frame using the OpenCV Dlib tool, ensuring that at least 90% of the face area is effectively cropped, thereby obtaining a large number of face forgery images generated by different face forgery methods and corresponding normal face images.
[0067] For the large number of forged face images and corresponding normal face images generated by different forged face methods, they are all scaled to 128×128 size. And these forged face images and corresponding normal face images are divided into different data sets according to the different generated forged face methods, and 4 different data sets can be obtained. Among these four different data sets, 3 are randomly selected as source domain data sets, and one is used as an unknown target domain data set. For the 3 source domain data sets S={S i |i=1,2,3}, where S i Represents the i-th source domain dataset, which contains Num i images.
[0068] 2) Using the training image set constructed in step 1) to train the constructed domain-invariant feature representation learning face forgery detection network includes the following steps:
[0069] 2.1) The M source domain datasets S in the constructed training image set are simulated and divided into virtual source domains S v and the virtual target domain T v In the embodiment, M is 3, and among the 3 source domain data sets, 2 source domains are used as virtual source domains, and 1 source domain is used as a virtual target domain.
[0070] 2.2) Constructing a feature distribution difference minimization network FDDM in a face forgery detection network for domain invariant feature representation learning. The feature distribution difference minimization network FDDM includes a feature extractor g e , Decoder Feature selection s , class discriminator d ψ , classifier C and M domain discriminators d μ i (i∈{1,2,...,M}), the specific network architecture is as follows Figure 2As shown. Feature extractor g e and decoder Both are composed of three stacked convolutional modules. The difference is that the feature extractor g e Each convolutional module is followed by a maximum pooling layer, and the decoder Each convolutional module is followed by an upsampling layer. Feature selection g s It is a one-step feature division operation and does not contain a specific network structure. ψ and domain discriminator d μ i The network structures of (i∈{1,2,...,M}) are the same, they are all composed of 4 stacked convolutional modules. Classifier C is composed of 3 convolutional modules, an average pooling layer and a fully connected layer.
[0071] For the virtual source domain S v and the virtual target domain T v The jth input image x is obtained randomly j , feature Z_ex j is obtained through the feature extractor g e From the input image x j The extracted features are converted into features Z_ex j Input to decoder To obtain the reconstructed image, and by minimizing the mean square error loss L between the input image and the reconstructed image rec Constraining it allows the feature extractor to extract complete information of the input image:
[0072]
[0073] Where N represents the number of samples selected from the virtual source domain and the virtual target domain. j Through feature selection g s Divided into features Z_ir j and the characteristic Z_ds j . Feature Z_ds j It is used as the input of the classifier C to predict the label of the input image and minimize the cross entropy loss L between the predicted result of the input image and the label of the input image. cls To constrain feature Z_ds j Representative class related features:
[0074]
[0075] Where N represents the number of samples selected from the virtual source domain and the virtual target domain, and y j represents the label of the jth input image. And the feature Z_ir j As the class discriminator dψ The input is also used to predict the label of the input image, and by minimizing the negative cross entropy loss L between the predicted result of the input image and the label of the input image cdis To constrain the feature Z_ir j Representative class-independent features:
[0076]
[0077] In the formula, N represents the number of samples selected from the virtual source domain and the virtual target domain. Then, the feature Z_ir is transformed into j and the characteristic Z_ds j Both are used as inputs to the class discriminator to predict the label of the input image and minimize the cross entropy loss L between the predicted result of the input image and the label of the input image ent To train the class discriminator d ψ The feature Z_ir j and the characteristic Z_ds j The two are decoupled from each other:
[0078]
[0079] In the formula, represents the indicator function, k represents the classification category, that is, the prediction task is a binary classification task, y j Represents the jth th The label of the input image. Domain discriminator d μ i (i∈{1,2,...,M}) does not consider the virtual source domain and the virtual target domain, but directly minimizes the feature Z_ds of each domain from the source domain dataset j The distribution difference makes the feature Z_ds j is the domain-shared feature shared by M source domain datasets. For the i-th domain discriminator d μ i , used to discriminate the feature Z_ds j Whether it belongs to the i-th source domain dataset, its corresponding loss function L dis i It is expressed as:
[0080]
[0081] In the formula, Z_ds j i represents the features of the jth input image from the ith domain, and correspondingly, Z_ds j r represents the feature of the jth input image from the rth domain, and r≠i. Combining the loss function of the M domain discriminators, the feature Z_ds from the i-th domain is ji The feature distribution difference with the remaining M-1 source domain datasets is the smallest. The loss function L of the M discriminators dis It is expressed as:
[0082]
[0083] The loss function of the overall optimization objective of FDDM is:
[0084] L FDDM =L rec +L cdis +L cls +L dis (7)
[0085] 2.3) Constructing the optimal classifier distance minimization network OCDM in the face forgery detection network of domain invariant feature representation learning. The optimal classifier distance minimization network OCDM is composed of the feature extractor g e , feature selector g s and classifier h. The specific network architecture is as follows Figure 3 As shown, the feature extractor g e , feature selector g s All of them come from the feature distribution difference minimization network FDDM. The classifier h consists of 3 convolutional modules, an average pooling layer and a fully connected layer. OCDM adjusts the optimal virtual source domain classifier through a two-stage update method and the optimal virtual target domain classifier The distance between them is used to adjust the learned domain-shared features to obtain domain-invariant features.
[0086] In the first stage, for the virtual source domain S v The jth input image is obtained randomly Use it as the input of OCDM to predict the label of the input image and minimize the cross entropy loss L between the predicted result of the input image and the label of the input image Meta-train :
[0087]
[0088] In the formula, l represents the cross entropy loss function, Φ(g e ,h) represents the feature extractor g in OCDM e and the weight parameters of the classifier h, and For the input image Corresponding labels. OCDM relative to the loss function L Meta-train The gradient of The feature extractor g in OCDM is transformed by this gradient e And the weight parameters of classifier h are updated as Wherein α represents the step size of this update, which is set to 0.0001 in the embodiment.
[0089] In the second stage, for the virtual source domain T v The jth input image is obtained randomly It is used as the input of the first stage updated OCDM to predict the label of the input image and minimize the cross entropy loss L between the predicted result of the input image and the label of the input image Meta-test :
[0090]
[0091] In the formula, For the input image The corresponding label.
[0092] The loss function of the overall optimization objective of OCDM is:
[0093]
[0094] In the formula, Φ(g e ,h) represents the feature extractor g in OCDM e and the weight parameter of the classifier h, β represents the ratio parameter to balance the ratio of the loss function of the two stages of OCDM. In the embodiment, β is set to 1. Represents OCDM relative to the loss function L Meta-train gradient.
[0095] 2.4) Initialize the weight parameters of each part in the feature distribution difference minimization network FDDM and the optimal classifier distance minimization network OCDM in the face forgery detection network for domain invariant feature representation learning, including the feature extractor g e The weight parameter Decoder The weight parameter Class Discriminator d ψ and M domain discriminators d μ i The weight parameter of (i∈{1,2,...,M}) and The weight parameter W of classifier C and classifier h C and W h . Initialize the number of iterations e=1.
[0096] 2.5) Randomly divide the M source domain datasets S in the constructed training image set into virtual source domains S v and the virtual target domain T v . Initialize the number of iterations to t=1.
[0097] 2.6) Fixed class discriminator d in FDDM ψ and 3 domain discriminators d μ i The weight parameter of (i∈{1,2,3}). From the virtual source domain S v and the virtual target domain T v N samples are randomly selected to form training pairs. In this embodiment, N is set to 96, and the loss function L of the overall optimization objective of FDDM is calculated. FDDM According to the calculated loss function L of the overall optimization objective of FDDM FDDM To calculate the feature extractor g in FDDM respectively e , Decoder And the gradient of classifier C and back-propagate to update the weight parameters of each part:
[0098]
[0099]
[0100]
[0101] In formulas (11), (12) and (13), η is a given learning rate, which is set to 0.0001 in the embodiment. and Represent the feature extractor g e , Decoder and the gradient of the classifier C.
[0102] 2.7) Fix the feature extractor g in FDDM e The weight parameter of the virtual source domain S v and the virtual target domain T v Randomly select N samples to form training pairs and calculate the loss function L of formula (4) ent and the M discriminators d of formula (5) μ i The loss function L for (i∈{1,2,...,M}) dis i (i∈{1,2,...,M}). According to the loss function L ent Calculate the class discriminator d in FDDM ψ The gradient of the classifier d is back-propagated to update the class discriminator ψ The weight parameters are:
[0103]
[0104] In the formula, η is the given learning rate, is the class discriminator d ψ The gradient of . Because there are M discriminators dμ i (i∈{1,2,...,M}), that is, the weight parameters of each domain discriminator need to be updated separately, and the i-th domain discriminator d μ i The weight parameter update process is expressed as:
[0105]
[0106] In the formula, η is the given learning rate, is the i-th domain discriminator d μ i gradient.
[0107] 2.8) From the virtual source domain S v and the virtual target domain T v Randomly select N samples to form training pairs and calculate the loss function L of the overall optimization objective of OCDM OCDM According to the calculated loss function L of the overall optimization objective of OCDM OCDM To calculate the feature extractor g in OCDM respectively e And the gradient of the classifier h and back-propagate to update the weight parameters of each part:
[0108]
[0109]
[0110] In formulas (16) and (17), η is a given learning rate, and Represent the feature extractor g e and the gradient of the classifier h.
[0111] 2.9) Update the number of iterations t = t + 1, and determine whether the iteration condition is met in and They are virtual source domains S v and the virtual target domain T v The total number of samples, N is the number of samples in each iteration. If the conditions are met, go to step 2.6). Otherwise, go to step 2.10).
[0112] 2.10) Update the number of iterations e=e+1, and determine whether the iteration condition satisfies e≤E, where E represents the number of epochs of training, which is set to 200 in the embodiment. If satisfied, go to step 2.5). Otherwise, save the weight parameters of the face forgery detection network learned by the optimal domain invariant feature representation at this time and exit the iteration.
[0113] 3) Select the unknown target domain dataset in step 1) as the test set. For the input image of the test set to be tested, apply the weight parameters of the face forgery detection network learned by domain-invariant feature representation constructed in step 2) and the optimal face forgery detection network learned by domain-invariant feature representation to give a prediction result, that is, whether the input image is a face forgery image.
[0114] The above embodiments are preferred implementation modes of the present invention, but the implementation modes of the present invention are not limited to the above embodiments. Any other changes, modifications, substitutions, combinations, and simplifications that do not deviate from the spirit and principles of the present invention should be equivalent replacement methods and are included in the protection scope of the present invention.
Claims
1. A generalized face forgery detection method based on domain-invariant features, characterized in that: The following steps are involved: 1) Build a training image set A large number of forged face images and corresponding normal face images generated by different forged face methods are obtained, all of which are scaled to the same size and divided into different source domain data sets according to the different forged face generation methods; these different source domain data sets are summarized to obtain the training image set, as follows: For a large number of forged face images and corresponding normal face images generated by different forged face methods, they are all scaled to a size of H×W, where H and W are the length and width of the image respectively; and these forged face images and corresponding normal face images are divided into different source domain data sets according to the different generated face forgery methods. For the M source domain data sets S={S i |i=1,2,...,M}, where S i Represents the i-th source domain dataset, which contains Num i images; 2) Using the training image set constructed in step 1) to train the constructed domain-invariant feature representation learning face forgery detection network, and obtaining the optimal weight parameters of the domain-invariant feature representation learning face forgery detection network; wherein the face forgery detection network includes a feature distribution difference minimization network FDDM and an optimal classifier distance minimization network OCDM; firstly, multiple source domain data sets in the constructed training image set are simulated and divided into virtual source domains and virtual target domains, and then FDDM learns shared domain-shared features from the divided virtual source domains and virtual target domains in a decoupled manner, and OCDM further adjusts the learned domain-shared features to convert them into domain-invariant features, and through continuous iterative random division of the virtual source domain and the virtual target domain, and using FDDM and OCDM, a suitable domain-invariant feature representation is obtained to perform generalized face forgery detection; comprising the following steps: 2.1) The M source domain datasets S in the constructed training image set are simulated and divided into virtual source domains S v and the virtual target domain T v ; 2.2) Constructing a feature distribution difference minimization network FDDM in a face forgery detection network for domain invariant feature representation learning. The feature distribution difference minimization network FDDM includes a feature extractor g e , Decoder Feature selector g s , class discriminator d ψ , classifier C and M domain discriminators d μ i ,i∈{1,2,...,M};feature extractor g e and decoder Both are composed of multiple convolutional modules stacked together. The difference is that the feature extractor g e Each convolutional module is followed by a maximum pooling layer, and the decoder Each convolutional module is followed by an upsampling layer; the feature selector g s It is a one-step feature division operation and does not contain a specific network structure; the class discriminator d ψ and domain discriminator d μ i The network structures of are the same, they are all composed of multiple convolutional modules stacked together; the classifier C is composed of multiple convolutional modules, an average pooling layer and a fully connected layer; For the virtual source domain S v and the virtual target domain T v The jth input image x is obtained randomly j , feature Z_ex j is obtained through the feature extractor g e From the input image x j The extracted features are converted into features Z_ex j Input to decoder To obtain the reconstructed image, and by minimizing the mean square error loss L between the input image and the reconstructed image rec Constrain it so that the feature extractor extracts complete information of the input image: Where N represents the number of samples selected from the virtual source domain and the virtual target domain this time; feature Z_ex j Through the feature selector g s Divided into features Z_ir j and the characteristic Z_ds j ; Feature Z_ds j It is used as the input of the classifier C to predict the label of the input image and minimize the cross entropy loss L between the predicted result of the input image and the label of the input image. cls To constrain feature Z_ds j Representative class related features: In the formula, y j represents the label of the jth input image; and the feature Z_ir j As the class discriminator d ψ The input is also used to predict the label of the input image, and by minimizing the negative cross entropy loss L between the predicted result of the input image and the label of the input image cdis To constrain the feature Z_ir j Representative class-independent features: Then, the feature Z_ir is transformed into j and the characteristic Z_ds j Both are used as inputs to the class discriminator to predict the label of the input image and minimize the cross entropy loss L between the predicted result of the input image and the label of the input image ent To train the class discriminator d ψ The feature Z_ir j and the characteristic Z_ds j The two are decoupled from each other: In the formula, represents the indicator function, k represents the classification category, that is, the prediction task is a binary classification task, and the domain discriminator d μ i Without considering the virtual source domain and the virtual target domain, we directly minimize the feature Z_ds of each domain from the source domain dataset. j The distribution difference makes the feature Z_ds j is the domain shared feature shared by M source domain datasets; for the i-th domain discriminator d μ i , used to discriminate the feature Z_ds j Whether it belongs to the i-th source domain dataset, its corresponding loss function L dis i It is expressed as: In the formula, Z_ds j i represents the features of the jth input image from the ith domain, and correspondingly, Z_ds j r represents the features of the jth input image from the rth domain, and r≠i; combined with the loss function of the M domain discriminators, the feature Z_ds from the i-th domain is j i The feature distribution difference with the remaining M-1 source domain data sets is the smallest; the loss function L of the M discriminators dis It is expressed as: The loss function L of the overall optimization objective of FDDM FDDM for: L FDDM =L rec +L cdis +L cls +L dis (7) 2.3) Constructing the optimal classifier distance minimization network OCDM in the face forgery detection network of domain invariant feature representation learning. The optimal classifier distance minimization network OCDM is composed of the feature extractor g e , feature selector g s and classifier h, where the feature extractor g e , feature selector g s They all come from the feature distribution difference minimization network FDDM. The classifier h consists of multiple convolutional modules, an average pooling layer and a fully connected layer; the OCDM network adjusts the optimal virtual source domain classifier through a two-stage update method and the optimal virtual target domain classifier The distance between them is used to adjust the learned domain-shared features to obtain domain-invariant features; In the first stage, for the virtual source domain S v The jth input image is obtained randomly Use it as the input of OCDM to predict the label of the input image and minimize the cross entropy loss L between the predicted result of the input image and the label of the input image Meta-train : In the formula, l represents the cross entropy loss function, Φ(g e ,h) represents the feature extractor g in OCDM e and the weight parameters of the classifier h, and For the input image Corresponding labels; OCDM relative to the loss function L Meta-train The gradient of The feature extractor g in OCDM is transformed by this gradient e And the weight parameters of classifier h are updated as Where α represents the step size of this update; In the second stage, for the virtual source domain T v The jth input image is obtained randomly It is used as the input of the first stage updated OCDM to predict the label of the input image and minimize the cross entropy loss L between the predicted result of the input image and the label of the input image Meta-test : In the formula, For the input image The corresponding label; The loss function L of the overall optimization objective of OCDM OCDM for: In the formula, β represents the ratio parameter to balance the ratio of the loss functions of the two stages of OCDM; 2.4) Initialize the weight parameters of each part in the feature distribution difference minimization network FDDM and the optimal classifier distance minimization network OCDM in the face forgery detection network for domain invariant feature representation learning, including the feature extractor g e The weight parameter Decoder The weight parameter Class Discriminator d ψ and M domain discriminators d μ i The weight parameter and The weight parameter W of classifier C and classifier h C and W h ; Initialize the number of iterations e = 1; 2.5) Randomly divide the M source domain datasets S in the constructed training image set into virtual source domains S v and the virtual target domain T v ; Initialize the number of iterations t = 1; 2.6) Fixed class discriminator d in FDDM ψ and M domain discriminators d μ i The weight parameter of the virtual source domain S v and the virtual target domain T v Randomly select N samples to form training pairs and calculate the loss function L of the overall optimization objective of FDDM FDDM ; According to the calculated loss function L of the overall optimization objective of FDDM FDDM To calculate the feature extractor g in FDDM respectively e , Decoder And the gradient of classifier C and back-propagate to update the weight parameters of each part: In formulas (11), (12) and (13), η is a given learning rate, and Represent the feature extractor g e , Decoder and the gradient of the classifier C; 2.7) Fix the feature extractor g in FDDM e The weight parameter of the virtual source domain S v and the virtual target domain T v Randomly select N samples to form training pairs and calculate the loss function L of formula (4) ent And the M domain discriminators d of formula (5) μ i The loss function L dis i ; According to the loss function L ent Calculate the class discriminator d in FDDM ψ The gradient of the classifier d is back-propagated to update the class discriminator ψ The weight parameters are: In the formula, is the class discriminator d ψ The gradient of; because there are M domain discriminators d μ i , that is, the weight parameters of each domain discriminator need to be updated separately, the i-th domain discriminator d μ i The weight parameter update process is expressed as: In the formula, is the i-th domain discriminator d μ i The gradient of 2.8) From the virtual source domain S v and the virtual target domain T v Randomly select N samples to form training pairs and calculate the loss function L of the overall optimization objective of OCDM OCDM ; According to the calculated loss function L of the overall optimization objective of OCDM OCDM To calculate the feature extractor g in OCDM respectively e And the gradient of the classifier h and back-propagate to update the weight parameters of each part: In formulas (16) and (17), and Represent the feature extractor g e and the gradient of the classifier h; 2.9) Update the number of iterations t = t + 1, and determine whether the iteration condition is met in and They are virtual source domains S v and the virtual target domain T v The total number of samples, N is the number of samples in each iteration; if the conditions are met, go to step 2.6); otherwise, go to step 2.10); 2.10) Update the number of iterations e=e+1, and determine whether the iteration condition satisfies e≤E, where E represents the number of training epochs; if so, go to step 2.5); otherwise, save the weight parameters of the face forgery detection network learned by the optimal domain-invariant feature representation at this time and exit the iteration; 3) Apply the face forgery detection network learned by domain-invariant feature representation constructed in step 2) and the weight parameters of the face forgery detection network learned by optimal domain-invariant feature representation to give a prediction result for the input image to be tested, that is, whether the input image is a face forgery image.
