Abstract
The rapid evolution of AI image generators poses a significant challenge for detection systems, which often overfit to specific training distributions. We present Image-Adaptive Prompt Learning (IAPL), a framework that enhances cross-generator generalization by dynamically adjusting vision-language model prompts during inference. By tailoring detection parameters to the unique characteristics of each test image, IAPL achieves state-of-the-art performance on major benchmarks, effectively identifying fakes from previously unseen generative models.
Introduction
The proliferation of hyper-realistic synthetic imagery from GANs and Diffusion models has created urgent security and misinformation risks. While current detectors leverage pre-trained foundation models like CLIP, they typically suffer from a "domain shift" vulnerability. Once trained, these models remain static, often failing to generalize to the artifacts of novel generators not present in their training sets. This paper addresses this limitation by introducing a mechanism for on-the-fly adaptation to the specific characteristics of individual test images.
Methodology: Image-Adaptive Prompt Learning (IAPL)
The core of our approach is the transition from static to dynamic detection. IAPL is built upon a frozen CLIP Vision Transformer (ViT) backbone, augmented with lightweight, task-specific components.
Architectural Components
- Fixed Learned Parameters: We integrate MLP-based adapters and learnable tokens into the CLIP encoder. These are optimized during training to provide a robust detection foundation but remain frozen during standard inference.
- Conditional Information Learner (CIL): To capture low-level forgery cues, this module identifies the most texture-rich image patch using Discrete Cosine Transform (DCT) scores. It applies high-pass filters and CNN-based extraction to isolate frequency-domain artifacts that complement CLIP’s high-level semantic features.
- Test-Time Token Tuning (TTT): This is the pivotal innovation. During inference, the model generates multiple augmented views of the test image. It then optimizes a set of adaptive tokens by minimizing prediction entropy across these views, forcing the model to reach a consistent and confident classification for that specific image.
Experimental Evaluation
We evaluated IAPL on two large-scale benchmarks designed to test cross-generator generalization:
- UniversalFakeDetect: Models were trained solely on ProGAN images and tested against 19 diverse datasets, including StyleGAN and various diffusion models.
- GenImage: Models were trained on Stable Diffusion v1.4 and tested against eight subsets, including Midjourney and ADM.
Key Results and Discussion
IAPL achieves state-of-the-art results across both benchmarks. On UniversalFakeDetect, it reached a mean Accuracy (mAcc) of 95.61%, significantly outperforming previous methods like C2P-CLIP. On GenImage, it achieved 96.7% overall accuracy.
As shown in the t-SNE visualizations, IAPL (Ours) demonstrates superior separation between real images and fakes from unseen generators compared to existing methods like FatFormer and C2P-CLIP. This suggests that the image-adaptive prompts successfully align the model's feature space with the unique artifacts of novel generative domains.
Conclusion
Image-Adaptive Prompt Learning represents a significant step toward robust AI-generated image detection. By shifting the focus from static fine-tuning to dynamic, test-time adaptation, IAPL overcomes the limitations of domain-specific overfitting. While the iterative nature of Test-Time Token Tuning introduces additional computational overhead during inference, the substantial gains in generalization accuracy make it a compelling approach for high-stakes detection scenarios.
Summary updated