Table of Contents
Fetching ...

Towards Generalizable AI-Generated Image Detection via Image-Adaptive Prompt Learning

Yiheng Li, Zichang Tan, Zhen Lei, Xu Zhou, Yang Yang

TL;DR

This work tackles the generalization gap in AI-generated image detection by replacing fixed, training-time prompts with Image-Adaptive Prompt Learning (IAPL). It introduces a Conditional Information Learner and Test-Time Token Tuning to generate image-specific prompts that adapt to unseen generators, while preserving a frozen CLIP backbone through fixed adapters and tokens. Across two large benchmarks, UniversalFakeDetect and GenImage, IAPL achieves state-of-the-art performance, validating its robustness to domain shifts and diverse forgery cues. The approach offers a practical pathway for deployable, generalizable AI-generated image detectors with efficient inference and targeted prompt adaptation.

Abstract

In AI-generated image detection, current cutting-edge methods typically adapt pre-trained foundation models through partial-parameter fine-tuning. However, these approaches often struggle to generalize to forgeries from unseen generators, as the fine-tuned models capture only limited patterns from training data and fail to reflect the evolving traits of new ones. To overcome this limitation, we propose Image-Adaptive Prompt Learning (IAPL), a novel paradigm that dynamically adjusts the prompts fed into the encoder according to each testing image, rather than fixing them after training. This design significantly enhances robustness and adaptability to diverse forged images. The dynamic prompts integrate conditional information with test-time adaptive tokens through a lightweight learnable scaling factor. The conditional information is produced by a Conditional Information Learner, which leverages CNN-based feature extractors to model both forgery-specific and general conditions. The test-time adaptive tokens are optimized during inference on a single sample by enforcing prediction consistency across multiple views, ensuring that the parameters align with the current image. For the final decision, the optimal input with the highest prediction confidence is selected. Extensive experiments show that IAPL achieves state-of-the-art performance, with mean accuracies of 95.61% and 96.7% on the widely used UniversalFakeDetect and GenImage datasets, respectively. Codes and weights will be released on https://github.com/liyih/IAPL.

Towards Generalizable AI-Generated Image Detection via Image-Adaptive Prompt Learning

TL;DR

This work tackles the generalization gap in AI-generated image detection by replacing fixed, training-time prompts with Image-Adaptive Prompt Learning (IAPL). It introduces a Conditional Information Learner and Test-Time Token Tuning to generate image-specific prompts that adapt to unseen generators, while preserving a frozen CLIP backbone through fixed adapters and tokens. Across two large benchmarks, UniversalFakeDetect and GenImage, IAPL achieves state-of-the-art performance, validating its robustness to domain shifts and diverse forgery cues. The approach offers a practical pathway for deployable, generalizable AI-generated image detectors with efficient inference and targeted prompt adaptation.

Abstract

In AI-generated image detection, current cutting-edge methods typically adapt pre-trained foundation models through partial-parameter fine-tuning. However, these approaches often struggle to generalize to forgeries from unseen generators, as the fine-tuned models capture only limited patterns from training data and fail to reflect the evolving traits of new ones. To overcome this limitation, we propose Image-Adaptive Prompt Learning (IAPL), a novel paradigm that dynamically adjusts the prompts fed into the encoder according to each testing image, rather than fixing them after training. This design significantly enhances robustness and adaptability to diverse forged images. The dynamic prompts integrate conditional information with test-time adaptive tokens through a lightweight learnable scaling factor. The conditional information is produced by a Conditional Information Learner, which leverages CNN-based feature extractors to model both forgery-specific and general conditions. The test-time adaptive tokens are optimized during inference on a single sample by enforcing prediction consistency across multiple views, ensuring that the parameters align with the current image. For the final decision, the optimal input with the highest prediction confidence is selected. Extensive experiments show that IAPL achieves state-of-the-art performance, with mean accuracies of 95.61% and 96.7% on the widely used UniversalFakeDetect and GenImage datasets, respectively. Codes and weights will be released on https://github.com/liyih/IAPL.

Paper Structure

This paper contains 16 sections, 6 equations, 5 figures, 9 tables.

Figures (5)

  • Figure 1: Comparison of the adaptability of prompts between our and existing methods when facing a testing image. (a) In the training process, the parameters of learnable prompts are optimized via a training set that includes limited generative methods. During inference, existing methods (b) keep the learned prompts fixed. In contrast, our method (c) dynamically adjusts the learned prompts based on test images from unseen sources, thereby enhancing generalization to novel test images.
  • Figure 2: T-SNE visualization between real, seen fake and unseen fake images on UniversalFakeDetect dataset. Compared to C2P-CLIP and Fatformer, our approach yields features of unseen fake images that are more similar to those of seen fake images and more distinct from real images. As shown by the black dashed area, our method produces a more distinct boundary between the features of unseen fake and real images. For FatFormer, we use the augmented image features from Text-Guided Interactor.
  • Figure 3: Overview of the detection pipeline in our method. The trainable parameters added to the original CLIP ViT in our image encoder fall into three categories: MLP-based adapters, learnable tokens, and image-adaptive prompts. MLP-based adapters go into $N_a$ encoder blocks at regular intervals. Learnable tokens are used from the $2^{nd}$ to the $N_t$-th encoder blocks. Image-adaptive prompts, learned via their dedicated module, are applied as the first block's input. After training, MLP-based adapters and learnable tokens are fixed, while image-adaptive prompts are adjusted based on the image during inference.
  • Figure 4: The overall architecture of Image-Adaptive Prompt Learning. It consists of Test-Time Token Tuning and Conditional Information Learner. The former dynamically adjusts test-time adaptive tokens based on the input image, while the latter extracts conditional information from the texture-rich region, providing forgery-specific and general guidance for prompt generation.
  • Figure 5: Comparison of Grad-CAM beteween without (w/o) and with (w/) IAPL. Brighter colors represent the salient region.