Manuscript Offprint

arXiv:2610.11876

Relative Patch Response Learning for Generalizable AI-Generated Image Detection

Tianyu Wang, Ouxiang Li, Yanbin Hao, Zhenhua Tang, Shuo Wang

ABSTRACT

Generative models can now synthesize highly realistic images, simultaneously increasing the risks of misinformation and visual forgery. Therefore, detecting AI-generated images becomes more essential, and a reliable detector must generalize to unseen generators and stay robust to unseen perturbations in the wild. Existing detectors are typically trained on either independently collected real and generated images or aligned real-generated pairs designed to mitigate content bias. Building on aligned pairs, recent methods form a mixed view by replacing some patches of the real image with their generated counterparts. However, we find that self-attention lets real and generated patches interact, so the feature of each patch no longer reflects its own source alone. This contextual shift makes a per-patch source label an imprecise target. To this end, we propose Relative Patch Response Learning (PRL). Instead of labeling each patch, PRL compares the same patch across two mixed views of an aligned pair and learns from its patch response, the change of its score between the views. (i) To give precise supervision under the contextual shift, a relative response objective measures the responses of source-changed patches against those of source-unchanged patches, which respond to the shift alone. (ii) To provide a reliable reference for the shift, a reference coherence objective keeps each group of source-unchanged patches moving as a whole. (iii) Since the two views contain different amounts of generated content, an area ranking objective asks the view with the larger generated area to have a higher mean patch score. Extensive experiments demonstrate the superior performance of PRL, which surpasses the best prior methods by 4.3% and 5.9% in average balanced accuracy across eight standard and three in-the-wild benchmarks, respectively. Code is available at https://github.com/wittyuu/Relative-Patch-Response-Learning.

1 INTRODUCTION

Generative models nowadays can produce highly realistic images (Karras et al., 2019; Dhariwal & Nichol, 2021; Rombach et al., 2022; Esser et al., 2024; Lu et al., 2023; Li et al., 2026b), expanding the possibilities for visual content creation (OpenAI, 2025; Black Forest Labs et al., 2025; Wu et al., 2025) while increasing the risks of misinformation and visual forgery (Feuerriegel et al., 2023; Chen et al., 2025b; Nightingale & Farid, 2022; Yang et al., 2024). These concerns motivate AI-generated image detection, which aims to distinguish AI-generated images from real ones (Wang et al., 2020; Frank et al., 2020; Chai et al., 2020; Ojha et al., 2023). The task has two central challenges. The first is generalization: detectors are trained on a limited set of generators but must recognize images from unseen models (Corvi et al., 2023; Zhu et al., 2023). The second is robustness: images in the wild are resized, compressed and re-shared online, and a detector must remain effective after such post-processing (Grommelt et al., 2024; Cozzolino et al., 2024; Yan et al., 2025a; Cavia et al., 2024).

To meet these challenges, detectors have relied on hand-crafted features that expose the traces of generation, such as frequency spectra and pixel-level residuals (Frank et al., 2020; Tan et al., 2024b;

∗^{*}Equal contribution.

†^{\dagger}Corresponding author.

Figure

(a) Hand-crafted / VFMs

(b) Aligned pairs

(c) Mixed views

(d) Contextual shift

Figure 1: Three training paradigms and the contextual shift. (a) Detectors built on hand-crafted features or on vision foundation models (VFMs) learn from real and generated images collected separately. (b) Alignment-based methods pair each real image with a reconstruction of matched content, but treat the two as independent training samples with their own image-level labels; the pair itself is not used by the supervision. (c) Patch-level methods replace some patches of a real image by their reconstruction and label each patch by its own source, in addition to the image-level label. (d) Contextual shift: a real patch q has the same input in the real image and in a mixed view, yet its score rises once other patches are replaced, while the per-patch label of (c) still marks q as real.

Li et al., 2025), or on the pretrained representations of vision foundation models (VFMs) (Ojha et al., 2023; Koutlis & Papadopoulos, 2024; Liu et al., 2024; Yan et al., 2025b). In either case, the training data are real and generated images collected separately (Figure 1a). Such unaligned data differ in content, format and resolution as well as in source, and these differences offer a detector shortcuts around the traces of generation (Guillaro et al., 2025; Rajan et al., 2025). Alignment-based methods mitigate content bias by pairing each real image with a reconstruction of matched content, and detectors trained on such pairs generalize better (Chen et al., 2024; Rajan et al., 2025; Guillaro et al., 2025; Chen et al., 2025a) (Figure 1b). Yet the alignment only shapes the data. The two images are still trained as independent samples with image-level labels, and their correspondence is never used as supervision. Recent methods go a step further on the aligned pair. PPL (Yang et al., 2026), for example, replaces some patches of a real image with their reconstruction, forming a mixed view in which the source of every patch is known, and supervises each patch by its own source (Figure 1c).

However, such a per-patch label is an imprecise target. In a vision transformer, self-attention lets every token gather evidence from the whole view. In a mixed view, the traces of generation in the replaced patches therefore spread into the real ones, and the real patches in turn dilute the replaced ones, so the feature of a patch moves with its context although the patch itself does not. We call this contextual shift (Figure 1d). The feature of a patch thus has two parts: the trace of its own source and the shift caused by the other patches, and a label that names only the source cannot tell them apart. It pushes the whole feature toward one class, so the supervision meant for the local trace is mixed with a context term, which Figure 2 makes visible in trained detectors. The label is exact about where the generated patches are, but it says nothing about what the feature of a patch should be once the rest of the view has changed.

To this end, we propose Relative Patch Response Learning (PRL), which supervises responses instead of labels. From each aligned pair, we build two mixed views that differ in which patches are replaced (Figure 3), so that every patch has aligned content in both views and only its source may differ. A linear head maps the feature of each patch to a score, higher for stronger evidence of generation, and the change of this score between the two views is its patch response. For a patch whose source is the same in both views, the input is identical, so the response is the contextual shift alone; for a patch whose source differs, the response adds the effect of its own change. The same-source patches thus serve as references for the source-changed ones. PRL has three objectives. (i) Relative response supervises each source-changed group relative to its reference, which subtracts the shift and leaves a precise target. (ii) Reference coherence keeps each reference group moving as a whole, which makes it a stable and reliable reference. (iii) Area ranking asks the view with the

Figure

Change of each patch score from the real image to the mixed input

High

Figure 2: Contextual shift in trained detectors. Each mixed input takes the outlined square from the aligned reconstruction and the rest from the real image. The maps show how much each patch score changes from the real image to the mixed input, darker for a larger change. For DINOv3 and PPL, we train a patch head on them. Although only the square changed, the DINOv3 detector and PPL respond outside it almost as much as inside it. PRL keeps a shift outside the square and responds inside it.

larger generated area to score higher. Experiments validate this design. Supervising the fine-grained correspondence within aligned pairs while accounting for the contextual shift improves the detector on both fronts. PRL averages 96.40% balanced accuracy on eight standard benchmarks of diverse generators and 93.74% on three in-the-wild benchmarks, surpassing the best previous method by 4.3% and 5.9%, respectively. Our contributions are as follows:

• We point out that existing methods underuse the correspondence between aligned data. Image-level methods train the two images independently, and patch-level supervision on mixed views ignores the contextual shift, which makes its per-patch labels imprecise targets.

• We propose PRL, which supervises patch responses rather than labels. Relative response supervision reduces the shared contextual component against the same-source patches, reference coherence keeps the reference stable, and area-based ranking adds a view-level constraint.

• On eight standard benchmarks of diverse generators and three in-the-wild benchmarks, PRL surpasses the best previous methods by 4.3% and 5.9% in average balanced accuracy, respectively. It also transfers to the detection of locally manipulated images with no additional training data.

References (67)

  • Flow matching for in-context image generation and editing in latent space (opens arXiv in a new tab)
  • Real-time deepfake detection in the real-world (opens arXiv in a new tab)
  • What makes fake images detectable? Understanding properties that generalize
  • DRCT: Diffusion reconstruction contrastive training towards universal detection of diffusion generated images
  • Dual data alignment makes AI-generated image detector easier generalizable
  • Synthetic politics: Prevalence, spreaders, and emotional reception of AI-generated political images on X. In ACM Conference on Hypertext and Social Media (HT), 2025b
  • FIRE: Robust detection of diffusion-generated images via frequency-guided reconstruction error
  • On the detection of synthetic images generated by diffusion models
  • Raising the bar of AI-generated image detection with CLIP. In IEEE/CVF Conference on Computer Vision and Pattern Recognition Workshops (CVPRW), 2024
  • SimLBR: Learning to detect fake images by learning to detect real images
  • Diffusion models beat GANs on image synthesis
  • Scaling rectified flow transformers for high-resolution image synthesis
  • Research can help to tackle AI-generated disinformation
  • Leveraging frequency analysis for deep fake image recognition
  • PiD: Generalized AI-generated images detection with pixelwise decomposition residuals
  • Fake or JPEG? Revealing common biases in generated image detection datasets
  • A bias-free training paradigm for more general AI-generated image detection
  • LoRA: Low-rank adaptation of large language models
  • AutoSplice: A text-prompt manipulated image dataset for media forensics
  • DailyBench: A unified benchmark for AI-generated and manipulated images from modern generative models (opens arXiv in a new tab)
  • Any-resolution AI-generated image detection by spectral learning
  • A style-based generator architecture for generative adversarial networks
  • Adam: A method for stochastic optimization
  • Leveraging representations from intermediate encoder-blocks for synthetic image detection
  • Detecting compressed AI-generated images via phase spectrum robustness
  • Improving synthetic image detection towards generalization: An image transformation perspective
  • Easier painting than thinking: Can text-to-image models set the stage, but not direct the play? In International Conference on Learning Representations (ICLR), pp. 86729–86758, 2026b
  • Microsoft COCO: Common objects in context
  • Forgery-aware adaptive transformer for generalizable synthetic image detection
  • Seeing is not always believing: Benchmarking human and model perception of AI-generated images
  • LaRE $^{2}$: Latent reconstruction error based method for diffusion-generated image detection
  • AI-synthesized faces are indistinguishable from real faces and more trustworthy
  • Towards universal fake image detectors that generalize across generative models
  • Community forensics: Using thousands of generators to train fake image detectors
  • A difference-in-difference approach to detecting AI-generated images
  • Scaling up AI-generated image detection with generator-aware prototypes
  • Aligned datasets improve detection of latent diffusion-generated images
  • AEROBLADE: Training-free detection of latent diffusion images using autoencoder reconstruction error
  • High-resolution image synthesis with latent diffusion models
  • DINOv3
  • Frequency-aware deepfake detection: Improving generalizability through frequency space domain learning
  • Rethinking the up-sampling operations in CNN-based generative network for generalizable deepfake detection
  • C2P-CLIP: Injecting category common prompt in CLIP to enhance generalization in deepfake detection
  • CNN-generated images are surprisingly easy to spot
  • DIRE for diffusion-generated image detection
  • Qwen-Image Technical Report
  • Zero-shot detection of AI-generated image via RAW-RGB alignment
  • A sanity check for AI-generated image detection
  • Orthogonal subspace decomposition for generalizable AI-generated image detection
  • Characteristics and prevalence of fake social media profiles with AI-generated faces
  • D $^{3}$: Scaling up deepfake detection by learning from discrepancy
  • All patches matter, more patches better: Enhance AI-generated image detection via panoptic patch learning
  • SemGIR: Semantic-guided image regeneration based method for AI-generated image detection and attribution
  • PatchCraft: Exploring texture patch for efficient AI-generated image detection (opens arXiv in a new tab)
  • GenImage: A million-scale benchmark for detecting AI-generated image
  • ADM, BigGAN, Glide, Midjourney, Stable Diffusion v1.4 and v1.5, VQDM and Wukong
  • EvalGEN holds 2,765 images from five recent text-to-image generators (Flux, GoT, Infinity, OmniGen and NOVA) driven by GenEval prompts; it has no real counterpart, so we report accuracy on its synthetic images
  • ProGAN, StyleGAN, StyleGAN2, BigGAN, CycleGAN, StarGAN, GauGAN, CRN, IMLE, SITD, SAN, DeepFake and WFIR
  • Guided, three LDM variants, three Glide variants and DALL-E, nineteen subsets in total
  • The generated images come from AI-art communities and passed a human perception test, every image is at least $448 \times 448$ pixels, and the generators are unknown
  • cropping instead of resizing, colour jitter, random rotation and random masking
  • VAE reconstruction, high-frequency debias from the real image and pixel mixup
  • It is trained on the Community Forensics set (Park & Owens, 2025) of several thousand generators
  • PRL is above $98.8\%$ on every DRCT-2M subset and above $99\%$ on every EvalGEN generator; on DDA-COCO its two lowest subsets are the SD3.5 and Flux reconstructions
  • Most of the detectors it evaluates stay within a few points of chance on most editors
  • Balanced accuracy (%) on the eleven benchmarks of Table 1 for the released DDA model (DINOv2), for DDA adapted from its official code to our DINOv3 backbone with LoRA, and for PRL, which uses the same backbone, adaptation and aligned pairs
  • >Method</td><td colspan=