Skip to content

Official implementation of the paper ``DeepFeatureX Net: Deep Features eXtractors based Network for discriminating synthetic from real images'', accepted for publication at the ICPR 2024 conference.

License

Notifications You must be signed in to change notification settings

opontorno/block-based_deepfake-detection

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DeepFeatureX Net: Deep Features eXtractors based Network for discriminating synthetic from real images

Abstract

Deepfakes, synthetic images generated by deep learning algorithms, represent one of the biggest challenges in the field of Digital Forensics. The scientific community is working to develop approaches that can discriminate the origin of digital images (real or AI-generated). However, these methodologies face the challenge of generalization, that is, the ability to discern the nature of an image even if it is generated by an architecture not seen during training. This usually leads to a drop in performance. In this context, we propose a novel approach based on three blocks called Base Models, each of which is responsible for extracting the discriminative features of a specific image class (Diffusion Model-generated, GAN-generated, or real) as it is trained by exploiting deliberately unbalanced datasets. The features extracted from each block are then concatenated and processed to discriminate the origin of the input image. Experimental results showed that this approach not only demonstrates good robust capabilities to JPEG compression but also outperforms state-of-the-art methods in several generalization tests.

Alt text

For more information, here the link to the paper:

Project Structure

This section outlines the recommended folder structure for the project. The working directory is where all the images for training and testing the models, as well as the model weights, are stored. The project is organized as follows:

working_dir/
├── datasets/                        # Training and testing datasets
├── testing_robustness/              # Data for testing model robustness
├── testing_generalization/          # Data for testing model generalization
├── guidance.csv                     # CSV file for data processing guidance
└── models/                          # Models and related files for the unbalancing approach

This structure is recommended but not mandatory. You can specify alternative paths as needed. To use the suggested structure:

  1. Create a file named wd.py inside src/dfx/
  2. Add the following line to wd.py:
working_dir = '<your_working_directory_path>'
  1. Replace <your_working_directory_path> with your actual working directory path.

Installation

  1. Clone the repository:
    git clone git@github.com:opontorno/block-based_deepfake-detection.git
    cd <repository_name>
    
  2. Install the dfx package and dependencies:
    pip install -e .
    pip install -r requirements.txt
    

Train the models

Data preparation

  1. Organize your data following this structure:
  Datasets/
  ├── gan_generated/
  │   ├── AttGAN/
  │   ├── BigGAN/
  │   ├── CycleGAN/
  │   ├── GauGAN/
  │   └── .../
  ├── dm_generated/
  │   ├── DALL-E 2/
  │   ├── DALL-E MINI/
  │   ├── Glide/
  │   ├── Latent Diffusion/
  │   └── .../
  └── real/
      └── real/
  1. Create a guidance CSV file:
python scripts/prep/make_guidance.csv --datasets_dir <your_data_dir> --saving_dir <your_save_path> --guidance_dir <your_guidance_path>

Train Base Models

Train the three base models:

python scripts/training/training_base-model.py --datasets_dir <your_data_dir> --main_class <main> --saving_path <your_save_path>

Replace <main> with one of: 'dm_generated', 'gan_generated', or 'real'.

Train Complete Model

Train the complete model:

python scripts/training/training_complete-model.py --datasets_dir <your_data_dir> --main_class <main> --saving_path <your_save_path>

Inference

Test the complete model specifying the backbone type and, if any, the model_path:

python scripts/testing/testing_complete-models.py --backbone <backbone_type> --model_path <your_model_path> --test_raw True --datasets_dir <your_data_dir> --main_class <main> --saving_path <your_save_path>

Dataset

The dataset comprises a total of $72,334$ images, distributed as shown in the Table. The image sizes vary considerably, ranging from 216x216 pixels up to 1024x1024 pixels, thus offering a wide spectrum of resolutions for analysis. For each generative architecture, special attention was paid to the internal balancing of the corresponding subset of images. This balancing was pursued in terms of both semantic content and size in order to minimise potential bias and ensure a fair representation of the different types of visual input. All images are in PNG format.

Nature Architecture Type # Images Total Different Sizes
GAN AttGAN FO 6005 256 × 256
BigGAN O 2600 256 × 256
CycleGAN FO 1047 256 × 256; 512 × 512
GauGAN O 4000 256 × 256; 512 × 512
GDWCT O 3367 37.572 216 × 216
ProGAN O 1000 256 × 256; 512 × 512
StarGAN F 6848 256 × 256
StyleGAN O 4705 256 × 256; 512 × 512
StyleGAN2 FO 7000 256 × 256; 512 × 512; 1024 × 1024
StyleGAN3 F 1000 256 × 256; 512 × 512; 1024 × 1024
DM DALL-E 2 FO 3421 512 × 512; 1024 × 1024
DALL-E MINI O 1000 256 × 256
Glide O 2000 15.421 256 × 256; 512 × 512
Latent Diffusion FO 4000 256 × 256; 512 × 512
Stable Diffusion FO 5000 256 × 256; 512 × 512
Nature Sources Type # Images Total Different Sizes
REAL CelebA F 5135 178 × 218
FFHQ F 4981 19341 1024 × 1024
Others O 9225 256 × 256; 512 × 512; 1024 × 1024

The dataset is available at the following link: link [DATASET AVAILABLE AS SOON AS THE PAPER IS PUBLISHED]

Citation

@inproceedings{pontorno2025deepfeaturex,
  title={DeepFeatureX Net: Deep Features eXtractors based Network for discriminating synthetic from real images},
  author={Pontorno, Orazio and Guarnera, Luca and Battiato, Sebastiano},
  booktitle={International Conference on Pattern Recognition},
  pages={177--193},
  year={2025},
  organization={Springer}
}

About

Official implementation of the paper ``DeepFeatureX Net: Deep Features eXtractors based Network for discriminating synthetic from real images'', accepted for publication at the ICPR 2024 conference.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Languages