Epistemic Uncertainty for Generated Image Detection

Jun Nie, Yonggang Zhang, Tongliang Liu, Yiu-ming Cheung, Bo Han, Xinmei Tian

Introduction

The rapid advancement of generative models has turned AI-generated image detection into a constant cat-and-mouse game. Most current deepfake detectors are trained as binary classifiers on specific datasets of real and fake images. While effective on known generators, they frequently fail to generalize to images produced by the latest, unseen generative models—a classic problem of distribution shift.

Rather than chasing the moving target of what "fake" looks like, this research proposes focusing on the established distribution of "real" images. The authors introduce a novel framework that leverages epistemic uncertainty from large-scale foundational models as a universal detector. Because these models are "experts" exclusively on natural images, AI-generated content triggers a measurable "lack of knowledge" that reveals its synthetic origin.

Methodology: Weight Perturbation (WePe)

The core of the proposed method is Weight Perturbation (WePe). The researchers exploit the fact that epistemic uncertainty—uncertainty in a model's parameters—is high for out-of-distribution (OOD) data that the model hasn't seen during training.

To efficiently quantify this uncertainty without the computational burden of training multiple model ensembles, the framework operates as follows:

  1. Foundational Model as Expert: The framework utilizes DINOv2, a large-scale vision model pre-trained exclusively on massive amounts of natural images, acting as the feature extractor.
  2. Weight Perturbation: To estimate uncertainty, the weights of the pre-trained model are slightly jittered or perturbed.
  3. Feature Stability vs. Shift: For a natural image, the extracted features remain highly stable even after the model's weights are perturbed. Conversely, for an AI-generated image (which is OOD), the features shift significantly.
  4. Detection Metric: The system calculates the cosine similarity between features extracted from the original model and the perturbed model. A low similarity score indicates a high feature shift, flagging the image as AI-generated.
Visualizing the distribution shift: Natural images cluster tightly, while AI-generated images exhibit significant feature shifts.

The authors also introduce a supervised variant, WePe*, which uses a small calibration set and a LoRA-based fine-tuning objective to further "sharpen" the uncertainty gap between real and fake images.

Key Findings and Insights

The framework was rigorously evaluated across diverse benchmarks, including ImageNet (testing against generators like ADM, StyleGAN XL, and Projected GAN), LSUN-BEDROOM, GenImage, and DRCT-2M.

Uncertainty as a Universal Proxy

The primary insight is that the distribution shift between natural and generated images manifests distinctly in the epistemic uncertainty space. The detector does not need to learn the specific artifacts of a generator; it only needs to recognize that an image does not fit the natural data distribution.

Correlation with FID

The study reveals a strong correlation between detection performance and the Fréchet Inception Distance (FID) of the generative model. As generative models produce images that are more "distanced" from natural distributions (higher FID), WePe becomes increasingly effective at spotting them.

Correlation between detection performance (AUROC) and generative model FID scores.

Layer Sensitivity and Performance

Interestingly, not all layers contribute equally to detection. Perturbing the first 19 blocks of a 24-block Vision Transformer (ViT) yields the best results, whereas perturbing the final, high-level semantic layers can degrade performance by corrupting the model's core understanding of the image.

In training-free settings, WePe outperformed existing baselines like RIGID and AEROBLADE, achieving an average AUROC of 87.99% on ImageNet without any prior training on generated images. The fine-tuned version, WePe*, achieved a state-of-the-art average AUROC of 95.57%, surpassing specialized supervised models. Furthermore, WePe proved remarkably resilient to common image degradations, maintaining high performance even under JPEG compression, Gaussian blur, and noise.

Limitations and Future Work

While highly effective, the authors note a few limitations:

  • The Convergence Risk: As generative models approach "perfection" and their output distributions perfectly match natural images, the uncertainty gap will inevitably narrow, potentially reducing the method's efficacy.
  • Computational Cost: Although more efficient than full ensembles, WePe still requires at least two forward passes (one clean, one perturbed). Future research could explore parallelization or single-pass approximations.
  • Multi-modal Models: Initial tests on multi-modal models (like BLIP) showed lower performance, likely because they prioritize high-level semantic information over the subtle distributional cues WePe relies on. Adapting this approach for multi-modal foundational models remains a promising avenue for future work.

Summary updated

BibTeX
@inproceedings{nie2025epistemic,
  author = {Jun Nie and Yonggang Zhang and Tongliang Liu and Yiu-ming Cheung and Bo Han and Xinmei Tian},
  title = {{Epistemic Uncertainty for Generated Image Detection}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2025},
  url = {https://openreview.net/forum?id=5SqbLPaBww},
}
Figure