Home

Awesome

Preserving Fairness Generalization in Deepfake Detection

Li Lin, Xinan He, Yan Ju, Xin Wang, Feng Ding, and Shu Hu


This repository is the official implementation of our paper "Preserving Fairness Generalization in Deepfake Detection", which has been accepted by CVPR 2024.

1. Installation

You can run the following script to configure the necessary environment:

cd Fairness-Generalization
conda create -n FairnessDeepfake python=3.9.0
conda activate FairnessDeepfake
pip install -r requirements.txt

2. Dataset Preparation

We share the FF++, Celeb-DF, DFD, DFDC with demographic annotations from paper, which be downloaded through this link.

You can also get those re-annotated four datasets with prediction uncertainty scores through our AI-Face-FairnessBench.

Or you can download these datasets from their official website and process them by following the below steps:

3. Load Pretrained Weights

Before running the training code, make sure you load the pre-trained weights. We provide pre-trained weights under ./training/pretrained. You can also download Xception model trained on ImageNet (through this link) or use your own pretrained Xception.

4. Train

To run the training code, you should first go to the ./training/ folder, then you can train our detector with loss flattening strategy by running train.py, or without loss flattening strategy by running train_noSAM.py:

cd training

python train.py 

You can adjust the parameters in train.py to specify the parameters, e.g., training dataset, batchsize, learnig rate, etc.

--lr: learning rate, default is 0.0005.

--gpu: gpu ids for training.

--fake_datapath: /path/to/faketrain.csv, fakeval.csv

--real_datapath: /path/to/realtrain.csv, realval.csv

--batchsize: batch size, default is 16.

--dataname: training dataset name: ff++.

--model: detector name: fair_df_detector.

5. Test

📝 Note

Change --inter_attribute and --single_attribute for different testing dataset:

### ff++, dfdc
--inter_attribute male,asian-male,white-male,black-male,others-nonmale,asian-nonmale,white-nonmale,black-nonmale,others \
--single_attribute male-nonmale-asian-white-black-others \

### celebdf, dfd
--inter_attribute male,white-male,black-male,others-nonmale,white-nonmale,black-nonmale,others \
--single_attribute male-nonmale-white-black-others \

📦 Provided Backbones

File namePaper
Xceptionxception.pyXception: Deep learning with depthwise separable convolutions
ResNet50resnet50.pyDeep Residual Learning for Image Recognition
EfficientNet-B3efficientnetb3.pyEfficientnet: Rethinking model scaling for convolutional neural networks
EfficientNet-B4efficientnetb4.pyEfficientnet: Rethinking model scaling for convolutional neural networks

Citation

Please kindly consider citing our papers in your publications.

@inproceedings{Li2024preserving,
    title={Preserving Fairness Generalization in Deepfake Detection},
    author={Li Lin, Xinan He, Yan Ju, Xin Wang, Feng Ding, Shu Hu},
    booktitle={Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR)},
    year={2024},
}