DeepFeatureX Net: Deep Features eXtractors based Network for discriminating synthetic from real images
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.
For more information, here the link to the paper:
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:
- Create a file named
wd.py
insidesrc/dfx/
- Add the following line to
wd.py
:
working_dir = '<your_working_directory_path>'
- Replace
<your_working_directory_path>
with your actual working directory path.
- Clone the repository:
git clone git@github.com:opontorno/block-based_deepfake-detection.git cd <repository_name>
- Install the
dfx
package and dependencies:pip install -e . pip install -r requirements.txt
- 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/
- 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 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 the complete model:
python scripts/training/training_complete-model.py --datasets_dir <your_data_dir> --main_class <main> --saving_path <your_save_path>
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>
The dataset comprises a total of
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]
@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}
}