TL;DR
Synthetic image detectors look like geniuses in the lab, but their accuracy tanks in the real world when images get blurry, compressed, or come from brand-new AI generators. Worse yet, when you try to let these detectors say "I don't know" on hard cases, their built-in confidence scores can become completely inverted—confidently keeping their worst mistakes and throwing away right answers. This paper introduces ReSIDe, a lightweight, plug-and-play wrapper that mines a detector’s hidden layers to restore sanity to its confidence estimates without retraining the model.
What Problem Does This Paper Address?
Deep neural networks trained to spot AI-generated images—Synthetic Image Detectors (SIDs)—easily achieve near-perfect accuracy on clean, familiar test sets. Yet in deployment, they run headfirst into covariate shifts: real-world messiness like JPEG compression, Gaussian blur, low resolution, adversarial tweaks, or images created by unseen generators. Under these shifts, detection error rates often degrade to ~50% (essentially a coin flip).
To prevent costly mistakes, engineers use Selective Classification (SC), which gives a model the option to abstain when its confidence falls below a threshold. We measure SC success using the Area Under the Risk-Coverage Curve (AURC)—lower is better, meaning low error rates across high proportions of accepted data.
For practical reasons, we want post-hoc SC, meaning we freeze the pretrained detector and just compute a Confidence Score Function (CSF) from its final output logits (like Maximum Softmax Probability, or MSP). However, the authors uncover a nasty surprise: under covariate shifts, standard logit-based confidence scores break down pathologically.
Look at subplot (a) Blur above: as you raise the confidence threshold to be more selective (moving right to left toward lower coverage), the error rate (Risk) shoots up toward 1.0! The model is systematically more confident when it is wrong than when it is right.
Methods
To fix this broken compass without retraining the underlying detector, the authors propose ReSIDe (Reliable Synthetic Image Detection), which relies on two clever ideas:
- Unsupervised Linear Probing (ULP) for Intermediate Logits: A network's final logits can be viewed geometrically as how closely a sample's final features match learned class templates (centroids). The authors extend this to every hidden layer. Taking clean training images, they run spherical $k$-means clustering on each layer's feature vectors to find natural centroids. For a new test image, its cosine similarity to a layer's centroids acts as "generalized logits" for that layer. Standard confidence functions (like MSP or MaxLogit) can now be applied at every depth of the network, extracting $L+1$ layerwise confidence scores instead of just one.
- Preference Optimization for Score Aggregation: Now we need to blend those $L+1$ scores into a single number using a simple linear weighted sum—amounting to just tens of trainable parameters. Using a hold-out validation set containing shifted data, the authors optimize these weights via a pairwise contrast loss (inspired by Bradley–Terry preference models, similar to RLHF). It explicitly pushes correctly classified samples to have higher combined scores than misclassified ones. Crucially, they mathematically prove that minimizing this loss directly lowers an upper bound on the AURC.
Datasets
The experiments curate training, validation, and test splits from GenImage, a massive benchmark of over 2.6 million real (ImageNet-1K) and synthetic images across eight generators.
- Training: Real images + ADM and BigGAN across 50 semantic classes.
- Testing: Seven distinct splits—In-Distribution (ID) plus six isolated covariate shifts: Blur, Unseen Semantic Classes (950 new classes), Low Resolution, FGSM (adversarial attacks), JPEG Compression, and Unseen Generators (Midjourney, Wukong, Stable Diffusion v1.4/v1.5).
- Validation: Importantly, to avoid cheating, the validation sets used to tune the aggregation weights use different shift parameters than the test sets (e.g., unseen validation generators are GLIDE and VQDM, not Midjourney or Stable Diffusion). They also note extended evaluations on the recent EvalGen benchmark in the appendix.
Key Insights and Ideas
- Final-layer tunnel vision: Even when a detector's final output layer is completely fooled and overconfident under distribution shifts, its intermediate hidden layers still retain healthy geometric signals that distinguish familiar patterns from anomalies.
- Flipping the inverted distribution: On blurry images, baseline confidence distributions show misclassified images clustering at higher confidence values than correct ones. ReSIDe literally flips these distributions back into the proper order.
- Better together, and orthogonal to other fixes: While picking the single best intermediate layer already beats the final layer, linearly combining all layers drops AURC by up to another 22.79%. Furthermore, ReSIDe stacks cleanly on top of existing logit-normalization tricks like
pNormfor compounding gains.
Key Results
Tested on both CNN (ResNet50) and Vision Transformer (Swin-T) backbones across six different logit-based CSFs:
- Individual Shifts: ReSIDe slashes AURC by up to 69.55% (ResNet50 with MaxLogit under Blur, dropping AURC from a worse-than-random
0.7271down to0.2214). - Realistic Mixture Distribution: When all seven test distributions (ID + 6 shifts) are mixed equally to simulate wild deployment, baseline CSFs hover near random-guessing AURCs (
~0.356for ResNet50;~0.335for Swin-T). ReSIDe cuts AURC across the board by up to 44.88% (bringing Swin-T down to0.1845). - Stacking with pNorm: Combining ReSIDe with
pNormyields up to a 44.91% further AURC reduction overpNormalone.
Limitations and Future Work
The authors candidly note three practical constraints:
- DNN-only: Because ULP relies on hidden-layer representations, the full pipeline only works on deep neural networks (though the preference-based score aggregation could work on any model outputting multiple confidence signals).
- Validation set dependence: Because aggregation weights are learned on a hold-out validation set, practitioners must ensure their validation shifts are diverse enough not to overfit to one specific type of corruption.
- Training data access: Computing the spherical $k$-means centroids requires access to samples from the original training distribution; without them, one would have to approximate the training data, potentially introducing errors.
Summary updated