DeepFeatureX Net: Deep Features eXtractors based Network for discriminating synthetic from real images
Orazio Pontorno Luca Guarnera Sebastiano Battiato











O. Pontorno et al.



Department of Mathematics and Computer Science, University of Catania, Italy

orazio.pontorno@phd.unict.it, {luca.guarnera,sebastiano.battiato}@unict.it

DeepFeatureX Net: Deep Features eXtractors based Network for discriminating synthetic from real images
    Orazio Pontorno0009-0009-0381-9971 Luca Guarnera0000-0001-8315-351X Sebastiano Battiato0000-0001-6127-2470
    April 29, 2024
==============================================================================================================






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. Code, models and dataset are available at <https://github.com/opontorno/block-based_deepfake-detection>.









§ INTRODUCTION

Generative models have achieved a high degree of fidelity in content generation, producing increasingly realistic and convincing results. Thanks to the vast amount of data available today and the continuous development of complex architectures, such as Generative Adversarial Networks (GANs) <cit.> and Diffusion Models (DMs) <cit.>, these models are able to produce images, text, sound and video with an astonishing quality that can hardly be distinguished from those created by human beings. This ability to generate high-fidelity content has opened up new opportunities in a wide range of fields, from art and entertainment to scientific research and multimedia content production. However, along with their powerful creative capabilities, generative models also have several negative aspects. One of the main problems is the possibility of abuse, as such models can be used to generate fake or convincingly manipulated content, fuelling the spread of misinformation and fraud <cit.>. Moreover, they can raise ethical concerns regarding intellectual property and privacy <cit.>, especially when they are used to create content based on personal data without the consent of the involved people. The proper and preventive detection of AI-generated content therefore becomes a critical priority to combat the spread of deepfakes and maintain the integrity of online information.

The scientific community is striving to find increasingly new and effective techniques and methods that can discern the nature (real or generated) of digital images. These techniques can be based on analysis and processing of statistics extracted from images (e.g. analytical traces) or on deep learning engines. 

Among other we recall the analysis of image frequencies, 

such as the Discrete Cosine Transform (DCT) and the Fourier Transform to map image pixels from the spatial domain to the frequency domain,

facilitating greater interpretability in the task of deepfake recognition <cit.>. Deep learning-based methodologies involve the construction of neural models 

achieving in general better results than the previous techniques <cit.>, but at the expense of a lower generalization. 

In this paper we propose a deep learning based architecture that exploits three backbones, called “Base Models” (BM) 
trained and specialized to specific classification tasks with special emphasis to DM generated data, GAN generated data, and real ones. 






The fundamental concept is based on utilising the inherent capabilities of the basic models, each of which is dedicated to extracting discriminating features specific to a generating architecture left behind during the image generation process. This approach aims at enhancing the final model by making it more resilient and robust to JPEG compression attacks, commonly employed by social networks, and more effective in the generalisation of the acquired knowledge. Focusing on specific distinctive features associated with different image generation technologies allows the model to develop a deeper and more focused understanding of the peculiarities of each image category, thus improving its ability to distinguish between genuine and synthetic images in real and variable contexts.

With this work we face the difficulty, often encountered in the state-of-the-art, of generalizing the recognition capabilities acquired in the training phase both to images generated by AIs not belonging to the dataset used in that phase and to synthetic images of generating architectures other than those taken into consideration.

The main contributions of this paper are:

    
  * A new approach for extracting main features from digital images using Base Models.
    
  * A model capable of retaining its discriminative ability even at JPEG compression attacks.


The paper follows the following structure: Section <ref> provides an overview of the main deepfake detection methods currently present in the state-of-the-art; in Section <ref>, a detailed description of the dataset of images used to conduct the experiments is provided; subsequently, in Section <ref>, the architecture proposed in this study and the stages of the training method are presented in detail; the experimental results obtained during the testing phase are reported in a Section <ref>; finally, the paper concludes with a concluding section where the main findings are summarized and the future directions of research are outlined.




§ RELATED WORKS

Most deepfake detection methods are based on intrinsic trace analysis to classify real content from synthetic ones. 
The Expectation-Maximization algorithm was used in <cit.> to capture the correlation between pixels, resulting in a discriminative trace able to distinguish deepfake images from pristine ones. McCloskey et al. <cit.> showed that generative models create synthetic content with color channel curve statistics different from the real data, resulting in another discriminative trace. In the frequency domain <cit.>, researchers highlighted the possibility of identifying abnormal traces left during generative models, mainly analyzing features extracted from DCT <cit.>. 
Liu et al. <cit.> proposed a method called Spatial-Phase Shallow Learning (SPSL) that combines spatial imaging and phase spectrum to capture artifacts from up-sampling on synthetic data, improving deepfake detection. Corvi et al. <cit.> analyzed a large number of images generated by different families of generative models (GAN, DM, and VQ-GAN (Vector Quantized Generative Adversarial Networks)) in the Fourier domain to discover the most discriminative features between real and synthetic images. The experiments showed that regular anomalous patterns are available in each category of involved architecture. 
Another category of detectors are deep neural network-based approaches. Wang et al. <cit.> used a ResNet-50 model trained with images generated by ProGAN <cit.> to differentiate real from synthesized images. Their study demonstrated the model's ability to generalize beyond ProGAN-generated Deepfakes. Wang et al. <cit.> introduced FakeSpotter, a new approach that relies on monitoring the behaviors of neurons (counting which and how many activate on the input image) within a dedicated CNN to identify Deepfake-generated faces. 
Many researchers have focused their research on trying to investigate how possible it is to detect images created by diffusion models. Corvi et al. <cit.> were among the first to address this issue, exploring the difficulties in distinguishing images generated by diffusion models from real ones and evaluating the suitability of current detectors.
Sha et al. <cit.> proposed DE-FAKE, a machine learning classifier designed for detecting diffusion model-generated images across four prominent text-to-image architectures. 
The authors then proposed a pioneering study on the detection and attribution of fake images generated by diffusion models, demonstrating the feasibility of distinguishing such images from real ones and attributing them to the source models, and also discovering the influence of prompts on the authenticity of images.
Recently, Guarnera et al.<cit.> proposed a method based on the attribution of images generated by generative adversarial networks (GANs) and diffusion models (DMs) through a multi-level hierarchical strategy. At each level, a distinct and specific task is addressed: the first level (more generic), allows discerning between real and AI-generated images (either created by GAN or DM architectures); the second level determines whether the images come from GAN or DM technologies; and the third level addresses the attribution of the specific model used to generate the images.


The limitations of these methods mainly concern the presence of experimental results performed only under ideal conditions and, consequently, the almost total absence of generalization tests: the classification performance of most state-of-the-art methods drops drastically when testing images generated by architectures never considered during the training procedure. 





§ DATASET DETAILS













































The dataset comprises a total of 72,334 images, distributed as follows: 19,334 real images collected from CelebA <cit.>, FFHQ <cit.>, and other sources <cit.>, 37,572 images generated by the GAN architectures GauGAN <cit.>, BigGAN <cit.>, ProGAN <cit.>, StarGAN <cit.>, AttGAN <cit.>, GDWCT <cit.>, CycleGAN <cit.>, StyleGAN <cit.>, StyleGAN2 <cit.>, StyleGAN3 <cit.>, and 15,423 images produced by the DM architectures DALL-E MINI [https://github.com/borisdayma/dalle-mini.github.com/borisdayma/dalle-mini], DALL-E 2 <cit.>, Latent Diffusion <cit.>, Stable Diffusion [https://github.com/CompVis/stable-diffusiongithub.com/CompVis/stable-diffusion] (Figure <ref> (a) shows some examples of used images). All images are in PNG format.

Initially the dataset was divided into three parts: a first 40% was used for training and validation of the Base Models (refer to Section <ref>); another 40% was used for training and validation of the complete models (refer to Section <ref>); finally the remaining 20% was used as testing dataset for both phases. 

Since our only goal is to discern the nature of the images, regardless of semantics, resolution, and size, the images were collected with as much variety of these parameters as possible. 
The objective is to underscore the dataset's varied composition, incorporating images from different sources, each marked by unique tasks and approaches to image creation. 




§ PROPOSED METHOD

The model proposed in this paper consists of exploiting three CNN backbones as feature extractors, which are then concatenated and processed to solve the classification task. The key idea of the model lies in the training of the three backbones, each of which is trained using a specially unbalanced dataset of images (as detailed below). The purpose of this procedure is to force each backbone to focus on finding the discriminative features, left by each type of generative model during the generation phase, contained in the images belonging to a specific class (real, GAN-generated, DM-generated). We give the name of `Base Model' to backbones trained on a highly unbalanced dataset and later used as feature pullers in the complete model. Figure <ref> shows the entire pipeline of the proposed method.





 §.§ Training of Base Models
 
As mentioned above, each of the three Base Models was trained using a subset of the training data set. In particular, from the original image are extracted three subsets that are somewhat unbalanced with respect to each of the classes following a 90:10 ratio. In this training phase, a pre-trained Convolutional Neural Network (CNN) standard is adapted by performing a binary classification between the predominant class and the one named `others', composed of some images taken randomly by the other two remaining classes. Figure <ref> (a) summarizes the overall process. 
Once the training is completed, the three Base Models are first frozen, the last linear layer (delegated to the binary classification) removed so that the characteristics maps of the last convolution layer are returned as output.
Our hypothesis, verified during the test phase, is that, following this training procedure, the backbones focus on the search for the main characteristics of the predominant class in order to be able to recognize their presence/absence, during inference. In conducting the experiments, the following CNNs were used as backbone: DenseNet 121, DenseNet 161, DenseNet 169, DenseNet 201 <cit.>, EfficientNet b0, EfficientNet b4 <cit.>, ResNet 18, ResNet 34, ResNet 50, ResNet 101, ResNet 152 <cit.>, ResNeXt 101 <cit.>, ViT b16, ViT b32 <cit.>. All backbones have been pretrained on the Imagenet <cit.> dataset. All experiments were conducted on GPU NVIDIA RTX a6000. The parameters of each model
were selected by choosing those that obtained the minimum loss value during model validation. 

Table <ref> shows the accuracy, recall, precision, and F1 score values obtained by evaluating all backbones on testing images. From the results we can observe how this training led to maximizing the recall value, this indicates that the classification model is able to correctly identify all the positive examples of the interest class (the unbalanced one). In other words, the model tends to minimize false negatives; that is, there are no cases where the model wrongly classified a positive example as negative. This confirms our initial hypothesis that, following the training procedure described above, Base Models are able to capture the discriminative features of each generating architecture.





 §.§ Overall architecture
 
The final model uses the three Base Models trained as described in Section <ref> as feature extractors, at this stage they will no longer be trained as the weights have been frozen. Each base model receives the same digital image as input and is tasked with identifying and extracting the discriminative features of each class. These are then concatenated to obtain a three-channel tensor, which is then processed through a custom CNN, consisting of a sequence of 5 convolutions 1D with respectively kernel size of 7, 5, 3, 3, 3, all with padding 1 and stride 1; This was followed by a Global Average Pooling operation and a three-node linear output classifier. Figure <ref> (b) presents both the entire pipeline and a graphical representation of the model.

For the training phase of the complete models we used the Cross Entropy Loss weighed with respect to the frequency of each class in the dataset (Equation <ref>). This choice was necessary to avoid that the models were too influenced by the imbalance present in the dataset of used images. 


    Weighted Cross Entropy Loss = -1/N∑_i=1^N∑_c ∈𝒞 w_c y_i,clog(ŷ_i,c)


where N s the number of samples, 𝒞={GAN, DM, REAL} is the set of classes, y_i,c is the ground truth label for sample i and c, ŷ_i,c is the predicted probability for sample i and class c, and w_c is the weight for class c. In particular:


    w_c = 1/#images of class c    ∀ c ∈𝒞.





§ EXPERIMENTAL RESULTS

Two types of experiments were conducted: Inference and robustness tests to assess the effectiveness and robustness of the classification models, and comparison with the state-of-the-art in the generalization test.



 §.§ Inference and robustness tests
 
In this first testing phase, we tested the proposed architecture by varying the backbone of the Base Model in order to choose the best model. For this testing phase, 20% of the images of the original dataset (Sec. <ref>) were used. Furthermore, in order to make the accuracy metric more meaningful, both validation and testing datasets were balanced so as to have the same number of images for each class (DM-generated, GAN-generated, real).




Initially, the models were tested using just raw images. Subsequently, the test images were compressed into JPEG format using different Quality Factors (QF): 90, 80, 70, 60, 50. On these new compressed image sets, we again tested the models by analysing their robustness to JPEG compression.
Figure <ref> shows the main differences between images with and without JPEG compression. It can be observed that as QF is decreased, low frequencies are removed and JPEG blocks are visible. This operation could lead to the removal of those (potentially) discriminative features identified by the various classifiers.

Table <ref> shows the performance of both tests in the three-class classification. From the results obtained, we can see that, regardless of the backbone used in the Base Model, in general this approach succeeds in achieving accuracy values in excess of 85%. In particular, the use of a model belonging to the DenseNet family as a backbone gives a boost to the overall performance of the models.



To gain a better understanding of the model's ability to distinguish between real and AI-generated images (from GAN or DM) we recalculated the previous performance values in binary classification: the calculation was performed considering the predicted classes GAN and DM as deepfakes and keeping the predictions of the real class unchanged, then the metrics were recalculated. Table <ref> shows the metrics obtained from the recalculation. Looking at the new values, we can see how performance has increased in terms of accuracy in both the inference test and, above all, the JPEG compression robustness test. 

From the obtained results, DenseNet 161 represents the backbone of the Basic Model as it leads to the best classification results and demonstrates good robustness to JPEG compression: despite the fact that the model was trained using only raw images, the accuracy and F1 score values tend not to decrease drastically as the compression QF decreases.






 §.§ Comparison with S.O.T.A. in generalization

In this section, we examine the generalization capacity of our approach. The selected final model uses DenseNet 121 as the backbone of the Base Model, chosen for its excellent performance found in the tests described in Section <ref>.

Initially, we conducted an analysis of the baselines: the models used as the backbone of the Base Models were trained in the same conditions of our method and subsequently evaluated in terms of generalization. This process allowed us to compare the effectiveness of our model with the use of standard architectures. Next, we compared our model with state-of-the-art models trained on similar tasks, namely the distinction between AI-generated images and real images.

In order to assess the generalisation capability of the models, we used different test sets. These test sets were divided into two categories: images generated by generative models previously observed during the training phase, but with different semantic variations and initial conditions, factors that often complicate classification, and images generated by models not included in the training phase. In addition, we conducted further tests distinguishing between images generated exclusively by GANs technologies, images generated exclusively by DMs technologies and images generated by both technologies. 
We use the notation whereby we define: 𝒯_*^i the dataset containing images generated by models already considered in the training phase; 𝒯_*^o the dataset containing images generated by architectures not considered in the training phase; 𝒯_*^i/o contains images generated by both type of architectures during the training phase; 𝒯_G^* the dataset containing only images generated by GANs as fakes; 𝒯_D^* the dataset containing only images generated by DMs as fakes; 𝒯_D/G^* contains images generated by both GANs and DMs architectures. Explicitly:

    
  * 𝒯_G^i contains a fake image sample of 2000 divided equally between images generated by GauGAN <cit.>, BigGAN <cit.>, ProGAN <cit.>, and CycleGAN <cit.>.
    
  * 𝒯_G^o contains a fake image sample of 2000 divided equally between images generated by Generative Adversarial Transformers (GANformer) <cit.>, Denoising DiffusionGANs <cit.>, DiffusionGANs <cit.>, ProjectedGANs <cit.>, and Taming Transformers <cit.>.
    
  * 𝒯_G^i/o contains a fake image sample of 2000 divided equally between images generated by the same generative models of 𝒯_G^i and 𝒯_G^o.
    
  * 𝒯_D^i contains a fake image sample of 2000 divided equally between images generated by Diffusion and images taken randomly from the COCOFake dataset <cit.>, generated by Stable Diffusion [https://github.com/CompVis/stable-diffusiongithub.com/CompVis/stable-diffusion].
    
  * 𝒯_D^o contains a fake image sample of 2000 divided equally between images generated by Vector Quantized Diffusion Model (VQ Diffusion) <cit.>, Denoising Diffusion Probabilistic Model (DDPM) <cit.>, and images taken randomly from the COCOGlide dataset, generated by Glide <cit.>.
    
  * 𝒯_D^i/o contains a fake image sample of 2000 divided equally between images generated by the same generative models of 𝒯_D^i and 𝒯_D^o.
    
  * 𝒯_D/G^i contains a fake image sample of 2000 divided equally between images generated by the same generative models of 𝒯_D^i and 𝒯_G^i.
    
  * 𝒯_D/G^o contains a fake image sample of 2000 divided equally between images generated by the same generative models of 𝒯_D^o and 𝒯_G^o.
    
  * 𝒯_D/G^i/o contains a fake image sample of 2000 divided equally between images generated by all the same previous generative models.


We also specify that each of the datasets listed above contains a sample of 2000 real images taken randomly in equal numbers from the datasets We also specify that each of the datasets listed above contains a sample of 2000 real images taken randomly in equal numbers from the AFHQ <cit.>, Imagenet <cit.> and COCO <cit.> datasets.

Table <ref> shows the percentage values of the accuracies obtained by the various models in the different contexts 𝒯. When reading the results, it is important to consider that all images in the test sets are compressed in JPEG format, which, taking into account that our model was trained using only raw images, may have lowered its performance as demonstrated in Section <ref>.
The state-of-the-art approaches used for comparison are <cit.>.
This choice is due to the fact that almost all these methods were trained using generative architectures considered in our experiments. 
Wang et al. <cit.> and Gandhi et al. <cit.> used only images generated by GAN models and represent some of the best approaches in literature able to solve well the deepfake detection task (in the specific domain of GAN generated images). Despite this, experimental results reported in Table <ref> show that these approaches are able to achieve similar classification results compared to methods trained considering images generated by also DM engines. However, these results show little ability to generalize. Our approach is able to generalize better, outperforming such state-of-the-art methods with classification accuracy over 10%, in any context. Arshed et al. <cit.> and Guarnera et al. <cit.> used one specific architecture to extract features for images generated by GAN and DM engines. The main limitation compared to our approach regards the strategy for feature extraction, since we used three specific models to better extract the most discriminative characteristics of the input data for each involved image category (GAN-generated, DM-generated, real).



In summary, from the obtained results (Table <ref>), our approach succeeds on average in generalizing better in most of the performed tests. Although baselines perform well in generalization when the dataset is composed of deepfake images generated by a single technology, they encounter difficulties when the dataset contains images from multiple generating architectures, both seen and unseen (column 𝒯_G/D^i/o). 
Then, the proposed model outperforms all other state-of-the-art methods, confirming the good generalization ability in different contexts.





§ CONCLUSION AND FUTURE WORKS

The challenge of generalization emerges as a major obstacle in the context of deepfake detection. The ability to accurately distinguish between AI-generated and real images is crucial to monitor the ongoing development of generative models. In this article we proposed a new approach that can ensure robustness to JPEG attacks, typically used by social networks, and contributed to a small step forward in solving the problem of generalization of detectors. The use of three different blocks specialized in the extraction of discriminative features of a specific images category (GAN-generated, DM-generated, real) allows our approach to develop a deeper understanding of intrinsic characteristic between real and synthetic images. This approach aims to provide a solid basis for the accurate identification of images even in the presence of variations and complexity introduced by different image generation techniques. This is the starting point for our future research: we want to strengthen the capabilities of the three discriminative feature extractors, analyze their outputs spatially and model new high-performance and structure-independent architectures.




  §.§.§ Acknowledgements
 Orazio Pontorno is a PhD candidate enrolled in the National PhD in Artificial Intelligence, XXXIX cycle, course on Health and life sciences, organized by Università Campus Bio-Medico di Roma.
This research is supported by Azione IV.4 - “Dottorati e contratti di ricerca su  tematiche dell’innovazione" del nuovo Asse IV del PON Ricerca e Innovazione 2014-2020 “Istruzione e ricerca  per il recupero - REACT-EU”- CUP: E65F21002580005.







splncs04.bst





