Forgery-aware Adaptive Transformer for Generalizable Synthetic Image Detection

Huan Liu, Zichang Tan, Chuangchuang Tan, Yunchao Wei, Yao Zhao, Jingdong Wang · DOI

Abstract

Detecting AI-generated images remains a critical challenge due to the "generalization gap," where models trained on specific generative architectures fail to identify forgeries from others. This paper introduces FatFormer (Forgery-aware Adaptive Transformer), a novel framework that enhances generalization by integrating a Forgery-aware Adapter (FAA) and Language-Guided Alignment (LGA). By leveraging both spatial and frequency domain features alongside text-guided supervision, FatFormer achieves state-of-the-art performance, reaching 98.4% accuracy on unseen GANs and 95.0% on unseen diffusion models, even with limited training data.

Introduction

The rapid advancement of generative AI, including Generative Adversarial Networks (GANs) and Diffusion Models, has blurred the line between real and synthetic imagery, posing significant security and privacy risks. While numerous detection methods have been proposed, they often suffer from a significant generalization gap: a detector optimized for GAN-generated images frequently fails when encountering content from newer Diffusion models like DALL-E or Midjourney.

Current state-of-the-art approaches, such as UniFD, typically utilize "frozen" pre-trained backbones (e.g., CLIP) with a simple classifier. However, this rigid paradigm prevents the model from adapting to the subtle, low-level artifacts and frequency-domain "fingerprints" characteristic of AI forgeries. FatFormer addresses this by introducing a flexible, adaptive architecture designed to capture these elusive forgery cues while maintaining the broad knowledge of pre-trained models.

Methods

FatFormer moves away from the frozen backbone approach by incorporating two primary innovations: the Forgery-aware Adapter (FAA) and Language-Guided Alignment (LGA).

  1. Forgery-aware Adapter (FAA): Instead of keeping the image encoder static, FAA modules are inserted between the stages of a Vision Transformer (ViT). These adapters analyze the image in two domains:
  2. Image Domain: A lightweight CNN captures low-level visual artifacts such as unnatural blurring or color mismatches.
  3. Frequency Domain: Utilizing the Discrete Wavelet Transform (DWT), the model examines high-frequency patterns. Unlike standard Fourier transforms, DWT preserves spatial information, enabling the model to localize frequency anomalies within the image.
  4. Language-Guided Alignment (LGA): FatFormer uses text prompts (e.g., "this photo is real" vs. "this photo is fake") to supervise the learning process via contrastive learning.
  5. A Patch-Based Enhancer makes text prompts context-aware based on image content.
  6. A Text-Guided Interactor aligns local image patches with global text embeddings, directing the image encoder's focus toward semantic areas where forgeries are most likely to occur.
FatFormer Architecture Overview

Experimental Setup

To evaluate generalization, a "train on one, test on many" protocol was adopted. The model was trained exclusively on 4-class ProGAN data (cars, cats, chairs, horses). Evaluation was then conducted across a wide range of unseen architectures, including GANs (StyleGAN, StyleGAN2, BigGAN, CycleGAN, StarGAN, GauGAN, and Deepfake) and Diffusion Models (PNDM, Guided Diffusion, DALL-E, VQ-Diffusion, LDM, and Glide).

Results and Discussion

FatFormer demonstrates superior generalization capabilities compared to existing methods. It achieves an average accuracy of 98.4% on unseen GANs, outperforming the previous state-of-the-art (UniFD) by nearly 10%. On unseen diffusion models, it reaches 95.0% average accuracy, a significant improvement over UniFD's 85.4%.

Performance on Unseen GANs

Key insights from the results include:

  • Frequency Analysis: The integration of DWT allows the model to detect high-frequency statistical anomalies that AI generators often fail to replicate.
  • Feature Adaptation: Nudging pre-trained features via adapters allows the model to retain general knowledge while becoming highly specialized at spotting forgeries.
  • Language as a Spotlight: Contrastive learning with text prompts acts as a "spotlight," focusing the model's attention on foreground objects where generative artifacts are most prominent, rather than getting distracted by background noise.

Furthermore, FatFormer exhibits high robustness against common image degradations like JPEG compression and Gaussian blurring, maintaining 90.7% accuracy under blurring where competitors significantly falter.

Conclusion

FatFormer represents a significant advancement in generalizable synthetic image detection. By combining adaptive image encoding with language-guided supervision, it bridges the gap between different generative models. While it shows exceptional performance, some challenges remain, such as lower accuracy on specific configurations like "Guided Diffusion" (76.1%). Future work will explore better pretext tasks and investigate the shared "DNA" between different generative architectures to build even more universal detection systems.

Summary updated

BibTeX
@inproceedings{liu2023forgery,
  author = {Huan Liu and Zichang Tan and Chuangchuang Tan and Yunchao Wei and Yao Zhao and Jingdong Wang},
  title = {{Forgery-aware Adaptive Transformer for Generalizable Synthetic Image Detection}},
  booktitle = {IEEE/CVF Conference on Computer Vision and Pattern Recognition},
  year = {2023},
  doi = {10.1109/cvpr52733.2024.01024},
}
Figure