Epistemic Uncertainty for Generated Image Detection

Jun Nie, Yonggang Zhang, Tongliang Liu, Yiu‐ming Cheung, Bo Han, Xinmei Tian · DOI

Abstract

We introduce a novel framework for AI-generated image detection through epistemic uncertainty, aiming to address critical security concerns in the era of generative models. Our key insight stems from the observation that distributional discrepancies between training and testing data manifest distinctively in the epistemic uncertainty space of machine learning models. In this context, the distribution shift between natural and generated images leads to elevated epistemic uncertainty in models trained on natural images when evaluating generated ones. Hence, we exploit this phenomenon by using epistemic uncertainty as a proxy for detecting generated images. This converts the challenge of generated image detection into the problem of uncertainty estimation, underscoring the generalization performance of the model used for uncertainty estimation. Fortunately, advanced large-scale vision models pre-trained on extensive natural images have shown excellent generalization performance for various scenarios. Thus, we utilize these pre-trained models to estimate the epistemic uncertainty of images and flag those with high uncertainty as generated. Extensive experiments demonstrate the efficacy of our method.

Introduction: Beyond the Cat-and-Mouse Game

As generative models like Midjourney and Stable Diffusion evolve, the visual "artifacts" that once betrayed them—such as anatomical errors or unnatural textures—are rapidly vanishing. Traditional detection methods typically treat this as a binary classification task, training models on massive datasets of real and fake images. However, these classifiers often suffer from poor generalization; a model trained to detect GAN-generated images frequently fails when encountering a novel Diffusion architecture.

Natural vs. AI-generated images and their corresponding feature distributions.

This research proposes a shift in perspective. Instead of training a detector to recognize specific "fake" patterns, we leverage Epistemic Uncertainty—the inherent confusion a model feels when encountering data outside its training distribution. By asking "Does this image look like the natural world I know?" rather than "Does this look like a specific fake?", we can create a more robust and generalizable detector.

Methodology: Weight Perturbation (WePe)

The core insight is that large-scale vision models (like DINOv2) trained on vast natural image datasets represent "natural" images as In-Distribution (ID) data. AI-generated images, despite their visual realism, remain Out-of-Distribution (OOD) relative to the model's training.

To quantify this without the high cost of model ensembles, we introduce Weight Perturbation (WePe). The process involves three steps:

  1. Perturb: Inject a small amount of Gaussian noise into the weights of a pre-trained foundation model.
  2. Compare: Pass an image through both the original and the perturbed model.
  3. Measure: Calculate the cosine similarity between the resulting feature vectors.

For natural images, the model resides in a "flat minimum" of the loss landscape, meaning its outputs are stable even when weights are slightly altered. Conversely, AI-generated images land in high-curvature regions where small weight changes lead to significant feature shifts.

Distribution of cosine similarity for natural and AI-generated images under weight perturbation.

As shown in the similarity distributions, natural images consistently exhibit high cosine similarity (low uncertainty), while AI-generated images show a broader, lower-similarity distribution (high uncertainty), creating a clear signal for detection.

Key Results and Robustness

The researchers evaluated WePe across four major benchmarks (ImageNet, LSUN-BEDROOM, GenImage, and DRCT-2M), covering GANs, Autoregressive models, and Diffusion variants.

  • Superior Generalization: On ImageNet, a fine-tuned version (WePe) achieved an average AUROC of 95.57%* across nine different generators, significantly outperforming previous state-of-the-art methods like NPR (86.00%).
  • Training-Free Efficacy: Even without any fine-tuning, the vanilla WePe method achieved an 87.99% AUROC, demonstrating that uncertainty is an inherent and powerful property of foundation models.
  • Attack Resistance: Because WePe relies on fundamental distributional shifts rather than fragile pixel-level artifacts, it remains remarkably robust against common image manipulations like JPEG compression, blurring, and noise.

Discussion and Limitations

While highly effective, the method faces a potential "convergence risk." As generative models become mathematically indistinguishable from natural image distributions, the epistemic uncertainty gap may narrow. Furthermore, while more efficient than model ensembles, WePe requires two forward passes per image, introducing a slight computational overhead compared to single-pass classifiers.

Conclusion

By reframing AI-generated image detection as an uncertainty estimation problem, WePe offers a path out of the traditional classification cycle. Leveraging the knowledge embedded in large-scale pre-trained models allows for detection that is both more generalizable and more robust to the rapid evolution of generative AI.

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