Improving Synthetic Image Detection Towards Generalization: An Image Transformation Perspective

Ouxiang Li, Jiayin Cai, Yanbin Hao, Xiaolong Jiang, Yao Hu, Fuli Feng

Abstract

Synthetic Image Detection (SID) faces a critical challenge in generalization: detectors trained on one generative model often fail when encountering images from another. This paper introduces SAFE (Simple Preserved and Augmented FEatures), a lightweight detector designed to overcome this hurdle by refining the training paradigm. By prioritizing artifact preservation through strategic cropping and local masking, SAFE achieves a 4.5% accuracy improvement and establishes a new state-of-the-art across 26 generative models, including the latest Diffusion Transformers.

The Generalization Challenge

As generative models like Stable Diffusion and Midjourney evolve, the "cat-and-mouse" game of synthetic image detection intensifies. The primary obstacle is the lack of generalization. The authors identify two major biases in existing training methods that hinder performance on unseen models:

  1. Weakened Artifacts: Standard pre-processing typically involves resizing images to a uniform size. This process acts as a low-pass filter, smoothing out the high-frequency pixel correlations (artifacts) that distinguish AI-generated images from real ones.
  2. Overfitted Artifacts: Basic data augmentations, such as simple horizontal flips, often lead models to overfit to specific semantic content (colors or subjects) rather than learning the underlying structural signatures of the generative process.

The SAFE Methodology

To address these biases, the authors propose the SAFE pipeline, which utilizes three core image transformations to highlight and preserve AI-generated fingerprints.

Artifact Preservation: Crop vs. Resize

Instead of destructive resizing, SAFE employs RandomCrop during training and CenterCrop during testing. This ensures that original pixel values remain intact, allowing the model to detect the subtle local correlations introduced by up-sampling layers.

Visualizing the extraction of high-frequency artifacts from real and fake images.

Invariant Augmentation and Local Awareness

To prevent semantic overfitting, SAFE introduces ColorJitter and RandomRotation, forcing the model to ignore irrelevant features. Furthermore, a RandomMask strategy hides patches of the image during training, compelling the detector to find evidence of "fakeness" in small, local regions rather than relying on global image composition.

Feature Selection

For signal extraction, SAFE utilizes the Discrete Wavelet Transform (DWT), specifically focusing on the HH (high-high) band. This mathematical approach isolates the high-frequency components where AI fingerprints are most prominent.

Experimental Results and Generalization

SAFE was evaluated against a comprehensive benchmark of 26 generative models. Training was primarily conducted on the 4-class ProGAN dataset, while evaluation spanned diverse sets including ForenSynths, Self-Synthesis, and a newly introduced benchmark, DiTFake, which features high-quality images from Diffusion Transformers like Flux.1 and Stable Diffusion 3.

Performance and Efficiency

SAFE achieved a new state-of-the-art, outperforming previous leaders by 4.5% in accuracy and 2.9% in Average Precision (AP). Notably, SAFE is highly efficient, utilizing only 1.44M parameters—a fraction of the size of competitors like FatFormer (577M parameters).

Comparison of logit distributions between the baseline and SAFE across seen (ProGAN) and unseen (StyleGAN2, Midjourney) models.

As shown in the logit distributions, SAFE provides significantly better separation between real and fake images, particularly for unseen generators like Midjourney, where the baseline often struggles.

Conclusion

SAFE demonstrates that the way data is presented to a model is as critical as the architecture itself. By shifting from global resizing to local artifact preservation, SAFE provides a robust and efficient solution for synthetic image detection. While JPEG compression remains a challenge due to its tendency to discard high-frequency data, SAFE represents a significant step forward in building generalizable AI safety tools.

Summary updated

BibTeX
@inproceedings{li2024improving,
  author = {Ouxiang Li and Jiayin Cai and Yanbin Hao and Xiaolong Jiang and Yao Hu and Fuli Feng},
  title = {{Improving Synthetic Image Detection Towards Generalization: An Image Transformation Perspective}},
  booktitle = {ACM SIGKDD Conference on Knowledge Discovery and Data Mining},
  year = {2024},
}
Figure