Table of Contents
Fetching ...

Your AI-Generated Image Detector Can Secretly Achieve SOTA Accuracy, If Calibrated

Muli Yang, Gabriel James Goenawan, Henan Wang, Huaiyuan Qin, Chenghao Xu, Yanhua Yang, Fen Fang, Ying Sun, Joo-Hwee Lim, Hongyuan Zhu

TL;DR

This work tackles the problem of AI-generated image detectors misclassifying unseen fakes as real under test-time distribution shift. It introduces a principled post-hoc calibration that adds a single scalar offset $\alpha$ to the model logits, derived from Bayesian decision theory and estimable from a small target validation set or even unlabeled data with KDE-based approaches. By realigning the decision boundary without retraining the backbone, the method yields robust improvements across diverse detectors and generators on benchmarks like AIGCDetectBenchmark and GenImage, and under perturbations such as JPEG. The approach offers a lightweight, adaptable solution for open-world AI-generated image detection, highlighting the importance of test-time calibration to counteract prior and input-shift biases in practical deployments.

Abstract

Despite being trained on balanced datasets, existing AI-generated image detectors often exhibit systematic bias at test time, frequently misclassifying fake images as real. We hypothesize that this behavior stems from distributional shift in fake samples and implicit priors learned during training. Specifically, models tend to overfit to superficial artifacts that do not generalize well across different generation methods, leading to a misaligned decision threshold when faced with test-time distribution shift. To address this, we propose a theoretically grounded post-hoc calibration framework based on Bayesian decision theory. In particular, we introduce a learnable scalar correction to the model's logits, optimized on a small validation set from the target distribution while keeping the backbone frozen. This parametric adjustment compensates for distributional shift in model output, realigning the decision boundary even without requiring ground-truth labels. Experiments on challenging benchmarks show that our approach significantly improves robustness without retraining, offering a lightweight and principled solution for reliable and adaptive AI-generated image detection in the open world. Code is available at https://github.com/muliyangm/AIGI-Det-Calib.

Your AI-Generated Image Detector Can Secretly Achieve SOTA Accuracy, If Calibrated

TL;DR

This work tackles the problem of AI-generated image detectors misclassifying unseen fakes as real under test-time distribution shift. It introduces a principled post-hoc calibration that adds a single scalar offset to the model logits, derived from Bayesian decision theory and estimable from a small target validation set or even unlabeled data with KDE-based approaches. By realigning the decision boundary without retraining the backbone, the method yields robust improvements across diverse detectors and generators on benchmarks like AIGCDetectBenchmark and GenImage, and under perturbations such as JPEG. The approach offers a lightweight, adaptable solution for open-world AI-generated image detection, highlighting the importance of test-time calibration to counteract prior and input-shift biases in practical deployments.

Abstract

Despite being trained on balanced datasets, existing AI-generated image detectors often exhibit systematic bias at test time, frequently misclassifying fake images as real. We hypothesize that this behavior stems from distributional shift in fake samples and implicit priors learned during training. Specifically, models tend to overfit to superficial artifacts that do not generalize well across different generation methods, leading to a misaligned decision threshold when faced with test-time distribution shift. To address this, we propose a theoretically grounded post-hoc calibration framework based on Bayesian decision theory. In particular, we introduce a learnable scalar correction to the model's logits, optimized on a small validation set from the target distribution while keeping the backbone frozen. This parametric adjustment compensates for distributional shift in model output, realigning the decision boundary even without requiring ground-truth labels. Experiments on challenging benchmarks show that our approach significantly improves robustness without retraining, offering a lightweight and principled solution for reliable and adaptive AI-generated image detection in the open world. Code is available at https://github.com/muliyangm/AIGI-Det-Calib.
Paper Structure (35 sections, 2 theorems, 21 equations, 7 figures, 6 tables)

This paper contains 35 sections, 2 theorems, 21 equations, 7 figures, 6 tables.

Key Result

Proposition 1

The default threshold $f(x) = 0$ (or $\tau = 0.5$) is not Bayes-optimal under class-conditional input shift and label prior shift.

Figures (7)

  • Figure 1: Logit distributions of a popular AI-generated image detector, CNNSpot wang2020cnn, pretrained on ProGAN-generated fake images and evaluated on previously unseen fake images from StyleGAN2, WhichFaceIsReal (WFIR), and Midjourney, reveal a tendency to misclassify these unfamiliar fake samples as real. Our proposed calibration method significantly enhances detection accuracy by adaptively shifting the decision boundary to better align with the skewed data distribution.
  • Figure 2: Conceptual illustration of our proposed (a) supervised and (b) unsupervised calibration methods, both designed to identify an optimal scalar $\alpha$ that achieves an ideal separation between real and fake distributions, with or without access to ground-truth labels.
  • Figure 3: Effect of validation set size on the proposed supervised and unsupervised calibration methods. We report the average accuracies on the two benchmarks.
  • Figure 4: Performance comparison of different supervised calibration methods for estimating $\alpha$. Average accuracies of CNNSpot wang2020cnn on AIGCDetectBenchmark zhong2023patchcraft are reported.
  • Figure A: Logit distributions of the nine AI-generated image detectors on the Chameleon yan2025aide benchmark. All detectors are trained on real images from ImageNet and fake images generated using SD v1.4. We present both the original decision threshold and the adjusted threshold obtained through our calibration method.
  • ...and 2 more figures

Theorems & Definitions (4)

  • Proposition 1: Bayes Non-optimality
  • proof
  • Proposition 2: Scalar Correction
  • proof