8000 GitHub - axsulit/RECCE: [CVPR2022] End-to-End Reconstruction-Classification Learning for Face Forgery Detection
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
/ RECCE Public
forked from VISION-SJTU/RECCE

[CVPR2022] End-to-End Reconstruction-Classification Learning for Face Forgery Detection

License

Notifications You must be signed in to change notification settings

axsulit/RECCE

 
 

Repository files navigation

RECCE: Deepfake Detection Model

This repository contains the implementation of a deepfake detection model that can work with multiple datasets.

Setup with Rye

  1. Install Rye if you haven't already:
curl -sSf https://rye-up.com/get | bash
  1. Initialize the project and install dependencies:
rye sync
  1. Activate the virtual environment:
.venv/bin/activate

Dataset Structure

All datasets should follow this structure:

dataset_root/
    train/
        real/
            image1.jpg
            image2.jpg
            ...
        fake/
            image1.jpg
            image2.jpg
            ...
    val/
        real/
            ...
        fake/
            ...
    test/
        real/
            ...
        fake/
            ...

Configuration Files

1. Dataset Configuration

For each dataset, you need to modify the root values in config/dataset/ to your actual dataset path. Here's an example for Celeb-DF:

# config/dataset/celeb_df.yml
train_cfg:
  root: "../../final_dataset/01_celebdf_unaltered"  # Path to dataset root

test_cfg:
  root: "../../final_dataset/01_celebdf_unaltered"

2. Model Configuration

Modify the following in config/Recce.yml for the model settings:

# config/model/recce.yml
name: CelebDF
file: "./config/dataset/celeb_df.yml"  # Path to dataset config

Running the Model

Training

python train.py --config config/train/recce.yml 

Testing

  1. Make sure you have a trained model checkpoint (.pth file)

  2. Run the test script:

python test.py --config config/train/recce.yml --ckpt path/to/your/checkpoint.pth
  1. For inference on custom images:
python inference.py --bin path/to/model.bin --image_folder path/to/image_folder --device cuda:0 --image_size 256

Testing Options

  • --config: Path to the config file
  • --ckpt: Path to the model checkpoint
  • --device: Device to run on (cuda:0, cpu)
  • --image_size: Input image size (default: 256)

Expected Output

The test script will output metrics like accuracy, AUC, and AP scores. For inference, you'll see:

path: path/to/image1.jpg           | fake probability: 0.1296      | prediction: real
path: path/to/image2.jpg           | fake probability: 0.9146      | prediction: fake

Troubleshooting

  1. If you get CUDA errors:

    • Make sure you have the correct CUDA version installed
    • Check if your GPU is available: nvidia-smi
    • Try using CPU by setting --device cpu
  2. If you get memory errors:

    • Reduce the batch size in your config file
    • Use a smaller image size
    • Try using CPU if GPU memory is insufficient
  3. If you get import errors:

    • Make sure you're in the virtual environment: .venv/bin/activate
    • Try reinstalling dependencies: rye sync

About

[CVPR2022] End-to-End Reconstruction-Classification Learning for Face Forgery Detection

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%
0