Skip to content
Proyectos

Acerca de

Detecta cualquier deepfake: Segment Anything se une a la detección y localización de falsificaciones faciales.

Otros proyectos

Cómo se miden estas cifras

Crecimiento de estrellas medido

in 24h
0
in 7 days
0
in 15 days
0
in 1 month
Recopilando historial

Cambios netos en períodos que se solapan, no totales diarios. Los datos no disponibles se dejan en blanco. Las estrellas indican interés, no calidad.

README.md

Original

Detect Any Deepfakes (DADF)

Detect Any Deepfakes: Segment Anything Meets Face Forgery Detection and Localization

Yingxin Lai1, Zhiming Luo1, Zitong Yu1,2*

1 Xiamen University    2 Great Bay University

Paper arXiv Base License



📖 Introduction

This repository is the official implementation of Detect Any Deepfakes (CCBR 2023).

We propose DADF, a novel framework that adapts the Segment Anything Model (SAM) for the task of face forgery detection and localization. By incorporating low-level forgery traces into the SAM architecture, our model achieves state-of-the-art performance in pixel-level forgery localization while maintaining the versatility to be applied to other segmentation tasks (e.g., camouflage, shadow detection).

🛠️ Environment

To ensure reproducibility, we recommend using a clean Conda environment.

1. Installation

# Create environment
conda create -n dadf python=3.8 -y
conda activate dadf

# Install PyTorch (Adjust CUDA version based on your driver)
pip install torch==1.13.0+cu117 torchvision==0.14.0+cu117 --extra-index-url [https://download.pytorch.org/whl/cu117](https://download.pytorch.org/whl/cu117)

# Install Dependencies
pip install -r requirements.txt

2. Download SAM Weights

Please download the pre-trained weights and put them into the pretrained/ directory.

📂 Data Preparation

Please organize your datasets under the ./load/ directory.

Task Dataset Source Link
Deepfake FaceForensics++ Official Github
Detect & Locate Official Github
Camouflage COD10K Official Github
CAMO Google Drive
Shadow ISTD Official Github
Medical Kvasir (Polyp) Official Website

⚡ Quick Start

  1. Download the dataset and put it in ./load.
  2. Download the pre-trained SAM (Segment Anything) and put it in ./pretrained.
  3. Training:
# run.sh
CUDA_VISIBLE_DEVICES=0,1,2,3 \
python -m torch.distributed.launch --nnodes=1 --nproc_per_node=4 --master_port=29501 \
train.py --config configs/demo.yaml

⚠️ Note: The SAM model consumes significant memory. We use 4 x A100 graphics cards for training. If you encounter memory issues, please try using graphics cards with larger VRAM or reduce the batch size.

🚀 Usage

1. Training

We support distributed training (DDP). Adjust nproc_per_node based on your GPU availability.

# Example: Train on 4 GPUs
CUDA_VISIBLE_DEVICES=0,1,2,3 \
python -m torch.distributed.launch --nnodes=1 --nproc_per_node=4 --master_port=29500 \
train.py --config configs/dadf_vit_h.yaml

Note: If you encounter OOM (Out of Memory) errors with ViT-H, try reducing the batch size in the config or switching to ViT-B/L backbones.

2. Testing

Evaluate the model performance and generate localization maps.

python test.py --config configs/dadf_vit_h.yaml --model checkpoints/dadf_best.pth

📝 Citation

If you find this code or paper useful, please cite our work:

@article{lai2023detect,
  title={Detect Any Deepfakes: Segment Anything Meets Face Forgery Detection and Localization},
  author={Lai, Yingxin and Luo, Zhiming and Yu, Zitong},
  journal={Chinese Conference on Biometric Recognition (CCBR)},
  year={2023}
}

🤝 Acknowledgements

This project is built upon SAM-Adapter. We thank the authors for their excellent codebase.

Explorar proyectos relacionados

Cargando…