FeatureTransfer: Unsupervised Domain Adaptation for Cross-Domain Deepfake Detection

Recently, various Deepfake detection methods have been proposed, and most of them are based on convolutional neural networks (CNNs). (ese detection methods suffer from overfitting on the source dataset and do not perform well on cross-domain datasets which have different distributions from the source dataset. To address these limitations, a new method named FeatureTransfer is proposed in this paper, which is a two-stage Deepfake detection method combining with transfer learning. Firstly, (e CNN model pretrained on a third-party large-scale Deepfake dataset can be used to extract the more transferable feature vectors of Deepfake videos in the source and target domains. Secondly, these feature vectors are fed into the domain-adversarial neural network based on backpropagation (BP-DANN) for unsupervised domain adaptive training, where the videos in the source domain have real or fake labels, while the videos in the target domain are unlabelled. (e experimental results indicate that the proposed method FeatureTransfer can effectively solve the overfitting problem in Deepfake detection and greatly improve the performance of cross-dataset evaluation.


Introduction
Recently, the Deepfake video generation technology has attracted much attention, especially the popular Deepfake application called "ZAO". e application requires the user to provide a clear personal face image and complete facial feature verification, but the image collection protocol is not user-friendly. e majority of users express anxiety about the security of face information. In addition, the Deepfake technology could also be used to create fake news, posing threats to user privacy and social security [1][2][3][4][5][6]. us, it is critical to detect the Deepfake images or videos for face forensics. As we know, Deepfake detection, a branch of face forensics, is a binary classification task. e goal of face forensics is to detect whether a face in image or video has been created or manipulated.
e Deepfake video detection method mainly uses deep learning technology, which is usually composed of two parts: face detection and classification. As for face detection [7][8][9], MTCNN (multitask convolutional neural network) [7] and dlib [8] are mostly used as face detectors. As for the classification part, some researchers detect the Deepfake videos with the visible artifacts in the videos. For example, Matern et al. [10] found the inconsistent color of the left and right eyes and the geometric deformations of teeth in Deepfake videos. Li et al. [11] found that the people in Deepfake videos blink less frequently. Yang et al. [12] detected videos Deepfake through the cue of inconsistent head poses. Li et al. [13] exposed Deepfake videos by detecting face warping artifacts. ese methods are effective for detecting some early Deepfake videos. However, with the development of Deepfake video generation technology, the visible artifacts used by these methods can be significantly reduced, degrading the performance of some artifacts-based methods. erefore, some other cues in Deepfake videos need to be found for detection. Zhang et al. [14] found that the upsample or transposed convolution used by the Deepfake technology inevitably results in a checkerboard effect on the generated face. Based on this, they proposed that CNN can be used to learn the checkerboard effect characteristics to detect Deepfake videos by directly inputting the face images extracted from video frames, such as MesoNet [15] and XceptionNet [16]. Unlike the spatial cues mentioned above, the temporal flickering, i.e., inconsistent temporal changes in videos, can be taken as the temporal cues in Deepfake videos. To make full use of both spatial and temporal cues in Deepfake videos, Guera et al. [17] and Chen et al. [18] combined CNN and recurrent neural networks (RNNs) to detect Deepfake videos. Unfortunately, Li et al. [19] found that most of the Deepfake detection methods trained and tested on specific datasets can achieve satisfactory performance, but their performances are significantly reduced when the methods are tested on cross-domain datasets, indicating that these methods are overfitting on a specific dataset. To improve the generalization ability of the methods on cross-domain datasets, multitask learning approaches [20][21][22] were introduced for Deepfake detection. Specifically, Nguyen et al. [20] developed a multitask learning approach to simultaneously perform classification, reconstruction, and segmentation of manipulated facial images. Cozzolino et al. [21] proposed the "ForensicTransfer" by combining classification and reconstruction, while Li et al. [22] proposed the "Face X-Ray" to detect Deepfake videos based on blending boundaries by combining classification and segmentation. However, those methods still need to improve the performance of the cross-dataset evaluation because they tend to train the classifier on a single small-scale dataset (i.e., FaceForensics++ [16] dataset), which is difficult to be generalized to other unseen datasets generated by using unseen Deepfake manipulation methods.
To make the Deepfake video detection method more robust on cross-domain datasets, this paper proposes a new method called FeatureTransfer, which is based on unsupervised domain adaptation. Extensive experiments demonstrate that the proposed method FeatureTransfer can improve the Deepfake detection performance of cross-dataset evaluation. e contributions of this work are summarized as follows: (1) e unsupervised domain adaptation is first used to detect Deepfake videos in this work. A two-stage training pipeline called FeatureTransfer is designed for Deepfake detection. (2) e feature extractor in preprocessing stage is pretrained on a large-scale Deepfake dataset DFDC-P [23] to extract more transferable feature vectors. e remainder of this paper is organized as follows. In Section 2, the related works are presented. In Section 3, our proposed method is described in detail. In Section 4, we provide comprehensive experimental results and analysis, as well as ablation studies. Finally, concluding remarks are drawn in Section 5.

Related Work
While the main focus of our work lies in the field of Deepfake detection, FeatureTransfer also intersects with the field of transfer learning, especially unsupervised domain adaptation. In the section, we clearly review previous Deepfake detection methods and transfer learning methods.

Deepfake Detection.
To detect the Deepfake images or videos, most of the previous works are based on deep learning methods, which can be categorized into two detection methods: CNN-based methods [10,13,15,16,[20][21][22] and RCNN-based methods [11,17,18]. e CNN-based methods extract face images from video frames and input them into the CNN for training and prediction to obtain the image-level result. ese methods only use spatial information of a single frame in Deepfake videos. In addition, Qian et al. [24] detected Deepfake videos by mining clues in the frequency domain instead of the RGB domain. By contrast, the RCNN-based methods need a sequence of video frames for training and prediction to obtain the videolevel result. ese methods use both CNN and RNN, and they are called RCNN. erefore, the RCNN-based methods can make full use of spatial and temporal information of Deepfake videos. Moreover, some Deepfake detection methods [12,25] are based on traditional machine learning methods, Yang et al. [12] and Ciftci et al. [25] used SVM (support vector machine) as a classifier by extracting handcrafted features, such as biological signals. Finally, the methods mentioned above are summarized in Table 1.

Transfer Learning and Domain Adaptation.
Transfer learning is an important branch of deep learning, which uses the knowledge of the source domain to assist the model in learning the knowledge of the target domain faster and better. Recently, transfer learning has been widely used in the field of forensics [21,26,27]. For example, loading the pretrained weight of ImageNet to the model before the model is trained is a simple transfer learning. Cozzolino et al. [21] trained the ForensicTransfer on the samples from the source domain and then performed fine-tuning with a small number of samples from the target domain to improve the performance of the ForensicTransfer on the target domain.
As a key field in transfer learning, domain adaptation aims to make the distribution of the source domain and the target domain in the feature space as close as possible. Meanwhile, the target model trained in the source domain can be transferred to the target domain to obtain good performance. Most works exploiting deep domain adaptation are based on discrepancy measurement. For instance, correlation alignment (CORAL) [28] and maximum mean discrepancy (MMD) [29] are used to reduce the distribution divergence between domains. Some works are based on discrepancy measurement domain-adversarial learning, such as domain-adversarial neural network (DANN) [30], multiadversarial domain adaptation (MADA) [31], and transfer learning with dynamic adversarial adaptation network (DAAN) [32].
FeatureTransfer is a CNN-based method. In this work, a third-party Deepfake dataset is first used to train the CNN to extract the feature vectors of the face images. en, the domain-adversarial neural network based on backpropagation (BP-DANN) is exploited for feature transfer training, which can improve the performance of Deepfake on cross-domain datasets.

Proposed Method
In this section, we introduce the details of the proposed method FeatureTransfer. Unlike the end-to-end adversarial training method NANN, FeatureTransfer exploits a two-stage adversarial training pipeline. As shown in Figure 1, the Fea-tureTransfer is composed of two parts: (a) the preprocessing stage, including face detection and feature vector extraction, and (b) BP-DANN unsupervised domain adaptive module.

Motivation.
Most of the methods studying cross-dataset evaluation mainly trained the model on the FaceForensics++ [16] dataset or other small-scale datasets and then tested it on other datasets. Unfortunately, the methods used to generate Deepfake videos on different datasets are often different, which may lead to great gaps in the generated videos. As a result, it is difficult to train a model with good detection ability for all or most of the Deepfake datasets on a specific small-scale Deepfake dataset. In addition, many forensics methods are data-driven, so it is important to find a large-scale training model of the Deepfake dataset which contains a variety of Deepfake generation methods. Fortunately, a large-scale Deepfake dataset DFDC-F [23], including 23654 real videos and 104500 fake videos, meets our data-driven requirements. e fake videos in the DFDC-F dataset were created by different methods, including Deepfake Autoencoder (DFAE) [33], MM/NN face swap [34], NTH [35], and FSGAN [36]. us, the feature extractor CNN pretrained on the DFDC-F dataset can be used to extract more transferable feature vectors, which will be fed into BP-DANN for unsupervised domain adaptive training.

Problem Definition.
In the unsupervised domain adaptation for Deepfake detection, it is assumed that the source distribution is D s � (x, y)|x ∈ X s , y ∈ Y s , where X s and Y s are the input and label space of the source domain, respectively. Meanwhile, the target distribution is D t � (x, y)|x ∈ X t , y ∈ Y t , where X t and Y t are the input and label space of the target domain. However, the input samples in the source domain are labelled but unlabelled in the target domain. D s and D t have the same label space so that Y s � Y t � 0, 1 { }, where "0" represents the real image or video and "1" represents the fake image or video. Moreover, each input x, the feature vector extracted from CNN in the preprocessing stage, has a domain label is work aims to extract the more generalized feature vectors from the pretrained CNN in the preprocessing stage and design a deep neural network that enables learning of transferable features f � G f (x) and adaptive classifier y � G y (f) to reduce the gap between the two domains, such that the target risk E (x,y)∼D t [G y (G f (x)) ≠ y] can be bounded by minimizing the source risk and the crossdomain discrepancy.

Preprocessing Stage.
In the preprocessing stage, the face detection network MTCNN is first used to obtain the face region of the video frame, and the region is expanded by 1.2 times to crop the face image and save it. en, the CNN (i.e., se_resnext101_32 × 4 d [37]) is pretrained on the third-party large-scale Deepfake dataset (i.e., DFDC-F [23]). Finally, the face images are fed into the CNN to extract the feature vectors with 2048 dimensions. e extracted feature vectors are saved so that they can be quickly loaded to the BP-DANN for unsupervised domain adaptive training.

Domain-Adversarial Network.
e DANN can learn domain-invariant features through end-to-end adversarial training. e learning procedure is a two-player game: the first player is the domain discriminator G d that is trained to distinguish the source domain from the target domain; the second player is the feature extractor G f which extracts domain-invariant features that can confuse the domain discriminator. In the adversarial training for the two players, the parameter θ f of feature extractor G f is learned by maximizing the loss of the domain discriminator G d , while the parameter θ d of domain discriminator G d is learned by minimizing the loss of the domain discriminator. In addition, the loss of label classifier G y is also minimized. e overall loss function of DANN can be formalized as  [13] CNN Self-supervised MesoNet [15] CNN RGB XceptionNet [16] CNN RGB Nguyen et al. [20] CNN Multitask ForensicTransfer [21] CNN Multitask Face X-Ray [22] CNN Multitask Qian et al. [24] CNN Frequency Li et al. [11] CNN + LSTM Handcrafted Guera et al. [17] CNN + LSTM RGB Chen et al. [18] CNN + LSTM RGB Yang et al. [12] SVM Handcrafted FakeCatcher [25] SVM Handcrafted where n s and n t are the number of samples in the source domain and the target domain, respectively, d i ∈ 0, 1 { } is the domain label of x i , L y is the loss for label prediction while L d is the loss for domain discriminator, and λ is a hyperparameter to trade-off the label classifier and the domain discriminator in the optimization problem. Based on equation (2) and equation (3), the optimization problem is to find the optimal parameters θ f , θ y , and θ d that deliver a saddle point of equation (1) after the training converges. Figure 1, the network architecture of the proposed BP-DANN consists of three parts: feature extractor G f , label classifier G y , and domain discriminator G d . ese three parts are built by BP structure. G f is composed of two fully connected layers, i.e., L f (N 0 , N 1 ) and L f (N 1 , N 2 ). e input and output dimensions of L f (N 0 , N 1 ) are N 0 and N 1 , where N 0 is 2048 and N 1 is 512. N 2 in L f (N 1 , N 2 ) is set as 64. G y is composed of a dropout layer with probability (p) of 0.5 and a fully connected layer L y (N 2 , 2). G d is composed of two fully connected layers, i.e., L d (N 2 , N 2 ) and L d (N 2 , 2). To obtain the more appropriate values of N 1 , N 2 , and p, the grid search is used for traversal search in this work.

Dataset.
In this section, the datasets related to the experiment are first introduced. en, the details of the experiment implementation are given, and the experimental results are finally analyzed.
e DeepfakeTIMIT (DF-TIMIT) [38] dataset contains 640 Deepfake videos generated with a GAN-based method [39] and based on VidTIMIT [40] dataset. e videos are divided into two equal subsets: lower quality (LQ) and higher quality (HQ). In our experiment, we add 320 real videos of 32 related subjects in VidTIMIT, and the LQ subset is used for test.
e FaceForensics++ (FF) [16] dataset contains 1000 pristine (P) videos and 4000 fake videos generated by using the four most advanced facial manipulation methods, including DeepFakes (DF), Face2Face (F2F), FaceSwap (FS), and NeuralTextures (NT). is dataset covers three versions of compression qualities: Raw, c23, and c40. In our experiment, the FF-DF and FF-FS subsets with a compression quality of c23 are taken.
e DeepFakeDetection (DFD) [41] contains 363 real videos and 3068 Deepfake videos released by Google. Similar to FF, this dataset also covers three versions of compression qualities, including Raw, c23, and c40. In our experiment, c23 is taken.
e Celeb-DF [19] includes 408 real videos and 795 synthesized videos generated by using an improved version of the Deepfake algorithm.
e DFDC [23] dataset contains two versions: DFDC-Preview (DFDC-P) [42] and DFDC-Final (DFDC-F) [23]. e DFDC-P includes 1131 real videos and 4113 fake videos. e DFDC-F was released for the Deepfake Detection Challenge, and it includes 23654 real videos and 104500 fake videos. In our experiment, DFDC-F is taken to pretrain the CNN (i.e., se_resnext101_32 × 4 d), and DFDC-P is used for test. As mentioned above, 30 frames are extracted from each video at equal intervals. en, the face region of each frame is detected and saved as a face image. To balance the real and fake face images in DFDC-F, 30 frames from each fake video are extracted, but 150 frames from each real video are extracted. e numbers of face images in each dataset are listed in Table 2.

Implementation Details.
Unlike the end-to-end adversarial learning training in DANN, a two-stage training strategy is adopted for FeatureTransfer.
In the first stage, a large-scale Deepfake dataset DFDC-F is used to train the CNN (i.e., se_resnext101_32 × 4 d). e CNN was initialized with pretrained weights on ImageNet, such that it can be used to extract more transferable feature vectors. e batch size is set to 128, and the total training epoch is 10. e Adam optimizer is used, where the initial learning rate is set to 2 × 10 −3 and weight decay of 4 × 10 −5 . After training, the CNN is used to extract the feature vectors of images, and the feature vectors are saved according to different datasets.
In the second stage, the feature vectors are loaded, and the BP-DANN is then trained. During the unsupervised domain adaptive adversarial training, the feature vectors of FF-DF (train set) are selected as the source domain, while the feature vectors of other test datasets are selected as the target domain. It should be noted that, due to a large number of images in the DFD, DFDC-P, and Celeb-DF datasets, only 10% of the images (the number of real and fake images is the same) in each dataset are used as the target domain for unsupervised adversarial training, and all images in each dataset are then tested after training. As for FF-FS and DF-TIMIT datasets, all images in the datasets are used as the target domain for unsupervised adversarial training, where the batch size is set to 128 and the total training epoch is 50. Instead of SGD used in DANN, the Adam optimizer with an initial learning rate of 1 × 10 −4 is used. To suppress noisy signals from the domain classifier at the early stages of the training procedure, the hyperparameter λ in equation (1) is changed from 0 to 1 gradually based on the following equation: where p is the training progress linearly changing from 0 to 1 and c is set to 10.

Results and Analysis.
e proposed method is compared with previous Deepfake detection methods, including Xception [16], FSSpotter [18], Face X-Ray [22], and se_resnext101_32 × 4 d [37]. e cross-domain Deepfake detection results are exhibited in terms of AUC (area under the curve) and ERR (equal error rate) on recently released datasets, such as DF-TIMIT, FF-FS (test set), DFD, DFDC-P, and Celeb-DF. e pretrained weight (all c23. p) provided by the author is loaded into Xception, and the model is then directly used to test on other datasets without retraining. Similarly, the se_resnext101_32 × 4 d is trained on DFDC-F, and the trained model is then directly used to test on other datasets without retraining. Due to the lack of open-source code for FSSpotter and Face X-Ray, the experimental results in the corresponding papers are directly used for comparison. e result with the clip length (T) of 1 in FSSpotter trained on FF-DF dataset is chosen as the image-level result.
e Face X-Ray in the paper is trained on FF and BI [22] datasets. Table 3 listed the cross-domain performance of all compared methods on different datasets. It can be seen that FeatureTransfer achieves the best performance on DFDC-P (seen dataset) and Celeb-DF (unseen dataset) compared to other methods in terms of AUC and ERR. Also, Feature-Transfer obtains a comparable result in FF-FS (unseen facial manipulations), DFD (unseen dataset), and DF-TIMIT (unseen dataset). In addition, Xception obtains the best performance on DF-TIMIT (unseen dataset) and FF-FS (seen dataset), while Face X-Ray obtains the best performance on DFD (unseen dataset) in terms of AUC and ERR. e performance of FSSpotter is relatively general, which could be caused by the fact that FSSpotter was only trained on the FF-DF dataset. However, the AUC result of the proposed method is only 2.24% lower than that of Xception on DF-TIMIT and 2.24% lower than that of Face X-Ray on DFD. Compared with se_resnext101_32 × 4 d, FeatureTransfer achieves a performance improvement ranged from 1% to 8% in terms of AUC on different datasets, especially 8% on the Celeb-DF. Compared with Xception, se_resnext101_32 × 4 d obtains better performance on more datasets, and this is why se_resnext101_32 × 4 d is used as the feature extractor of FeatureTransfer. In general, the results indicate that Featur-eTransfer achieves better or comparable performance on cross-dataset evaluation, which mainly benefits from the more transferable feature vectors extracted from the deeper CNN called se_resnext101_32 × 4 d that was pretrained on a large-scale dataset DFDC-F. Moreover, using unsupervised domain adaptation can also improve the performance of the unlabelled Deepfake datasets in target domain.

Ablation Studies.
To confirm the effectiveness of the proposed method, we explore the effect of different level evaluation and the effect of different training strategies in this section.

Effect of Different Level Evaluation.
To verify the effectiveness and better generalization of the proposed method on different levels of evaluation, the results of image level and video level are compared. To get the video-level result, the prediction score for video is the predicted probability that the video is fake, which is calculated by averaging the scores of face images extracted from frames of a video. It can be seen from the image-level and video-level results shown Security and Communication Networks 5 in Figure 2 that the video-level results are significantly improved on each dataset in terms of AUC (%).  Figure 3, in terms of AUC (%), the image-level results of FeatureTransfer using the two-stage training strategy are significantly improved on each dataset compared with DANN using the end-to-end training strategy.

Conclusions
In this work, FeatureTransfer, a two-stage Deepfake detection method based on unsupervised domain adaptation, is proposed. e feature vectors extracted from CNN are used for adversarial transfer learning in BP-DANN, which contributes to better performance than the end-to-end adversarial learning. Moreover, the feature extractor CNN pretrained on a large-scale Deepfake dataset can be used to extract more transferable feature vectors, which greatly reduce the gap between the source domain and the target domain during unsupervised domain adaptive training. e experimental results indicate that the proposed method achieves better and comparable performance for cross-domain Deepfake detection compared with previous methods. Note. e "FSS," "X-Ray," "Se_Res," and "FT" are the short forms of "FSSpotter," "Face X-Ray," "se_resnext101_32 × 4 d," and "FeatureTransfer," respectively.     Train  Test  Valid  Test  LQ  Real  21600  4200  4200  4200  9600  10890  12240  33897  2839521  Fake  21600  4200  4200  4200  9600  91740  23850  123412  2885045 However, there are still some limitations in our work. It is not an end-to-end detection method, and it needs a largescale Deepfake dataset to pretrain the CNN to extract more transferable features, which takes a lot of time. us, in future work, we will devote ourselves to studying an end-toend domain adaptive Deepfake detection method that does not require pretrained feature extractors.

Data Availability
e data used to support the findings of this study are available from the corresponding author upon request.

Conflicts of Interest
e authors declare that they have no conflicts of interest regarding the publication of this paper.