:page_facing_up: End-to-End Reconstruction-Classification Learning for Face Forgery Detection
:boy: Junyi Cao, Chao Ma, Taiping Yao, Shen Chen, Shouhong Ding, Xiaokang Yang
Please consider citing our paper if you find it interesting or helpful to your research.
@InProceedings{Cao_2022_CVPR,
author = {Cao, Junyi and Ma, Chao and Yao, Taiping and Chen, Shen and Ding, Shouhong and Yang, Xiaokang},
title = {End-to-End Reconstruction-Classification Learning for Face Forgery Detection},
booktitle = {Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR)},
month = {June},
year = {2022},
pages = {4113-4122}
}
This repository is an implementation for End-to-End Reconstruction-Classification Learning for Face Forgery Detection presented in CVPR 2022. In the paper, we propose a novel REConstruction-Classification lEarning framework called RECCE to detect face forgeries. The code is based on Pytorch. Please follow the instructions below to get started.
Briefly, we train a reconstruction network over genuine images only and use the output of the latent feature by the encoder to perform binary classification. Due to the discrepancy in the data distribution between genuine and forged faces, the reconstruction differences of forged faces are obvious and also indicate the probably forged regions.
Please ensure that you have already installed the following packages.
config/
. You can adjust the parameters in the yaml files to specify a training process. More information is presented in config/README.md.torch.distributed
package to train the models, for more information, please refer to PyTorch Distributed Overview.CUDA_VISIBLE_DEVICES=0 python -m torch.distributed.launch --nproc_per_node=1 --master_port 12345 train.py --config path/to/config.yaml
--config
: Specify the path of the config file. python test.py --config path/to/config.yaml
--config
: Specify the path of the config file.inference.py
to help you do inference using custom data. python inference.py --bin path/to/model.bin --image_folder path/to/image_folder --device $DEVICE --image_size $IMAGE_SIZE
--bin
: Specify the path of the model bin generated by the training script of this project.--image_folder
: Specify the directory of custom facial images. The script accepts images end with .jpg
or .png
.--device
: Specify the device to run the experiment, e.g., cpu
, cuda:0
.--image_size
: Specify the spatial size of input images.path: path/to/image1.jpg | fake probability: 0.1296 | prediction: real
path: path/to/image2.jpg | fake probability: 0.9146 | prediction: fake
python inference.py -h
in your console for more information about available arguments.