Exposing the Fake: Effective Diffusion-Generated Images Detection

RuiPeng Ma, Jinhao Duan, Fei Kong, Xiaoshuang Shi, Kaidi Xu

TL;DR

The authors introduce SeDID (Stepwise Error for Diffusion-generated Image Detection), a forensic method that separates diffusion-generated images from real ones by analyzing reconstruction errors at intermediate diffusion steps. By demonstrating that diffusion models reconstruct their own outputs far more accurately than real images during a single reverse-and-denoise step, SeDID achieves average detection accuracies exceeding 93%, significantly outperforming prior baselines.

What Problem Does This Paper Address?

Diffusion models (such as DDPMs and Latent Diffusion Models) now generate remarkably realistic imagery, sparking concerns regarding deepfakes, copyright infringement, and misuse.

Existing detection schemes like DIRE inspect reconstruction fidelity, but they focus primarily on the fully reconstructed image at the final clean step ($x_0$). This approach misses the subtle discrepancies that emerge along intermediate steps of the diffusion and reverse trajectory. Furthermore, natural image distributions harbor complex high-frequency patterns that generative models do not perfectly reproduce. The paper tackles a core question: Can intermediate deterministic diffusion errors expose the distributional gap between real images and diffusion-synthesized visuals?

Methods

Inspired by Membership Inference Attacks (specifically SecMI), the authors formulate SeDID to exploit the deterministic forward (reverse) and backward (denoising) properties of Denoising Diffusion Implicit Models (DDIM):

  1. Stepwise Error ($t, \delta$-error): Given an image $x_0$, it is brought to an intermediate timestep $T_{SE}$. Using the deterministic reverse function $\phi_\theta$, the intermediate state is stepped forward to $T_{SE} + \delta$, and then brought immediately back using the deterministic denoising function $\psi_\theta$ to $T_{SE}$. The squared Euclidean distance between the original intermediate representation and this reconstructed state defines the stepwise error: $$E_{T_{SE},\delta} = \|\psi_\theta(\phi_\theta(\tilde{x}_{T_{SE}}, T_{SE}, \delta), T_{SE}, \delta) - \tilde{x}_{T_{SE}}\|^2$$ Because diffusion models are mathematically tailored to the manifold of their generated data, synthetic samples produce consistently smaller stepwise errors than real samples.

  2. Two Detection Variants:

  3. $\text{SeDID}_{\text{Stat}}$ (Statistical): Classifies an image as synthetic if its error falls below a calculated threshold ($E_{T_{SE},\delta} < h$).
  4. $\text{SeDID}_{\text{NNs}}$ (Neural Network): Feeds the intermediate representation pairs into a ResNet-18 classifier, learning structural spatial artifacts rather than relying on a single scalar norm.

Datasets

The authors evaluated SeDID across three established computer vision benchmarks, with images resized to $32 \times 32$ pixels:

  • CIFAR-10: 50,000 real images vs. 50,000 DDPM-generated images across 10 balanced classes.
  • Tiny-ImageNet: 200 categories; 50,000 real and 50,000 DDPM-generated images.
  • CelebA: High-attribute celebrity faces (center-cropped to 140 pixels prior to scaling); 50,000 real and 50,000 DDPM-generated images.

Key Insights and Ideas

  • Intermediate steps carry higher forensic signal than clean endpoints: Inspecting internal latents midway through diffusion exposes model familiarity far more reliably than end-to-end pixel reconstruction ($x_0$).
  • Dataset complexity dictates optimal timesteps ($T_{SE}$):
  • For diverse, multi-class datasets (CIFAR-10, Tiny-ImageNet), detection accuracy strongly increases with higher timesteps, peaking near pure noise ($T_{SE} = 990$).
  • For aligned, lower-entropy datasets (CelebA faces), detection accuracy exhibits the inverse trend, performing best at low noise levels ($T_{SE} = 165$).
  • Universal stepsize: Across all tested datasets, a stepsize of $\delta = 165$ consistently yielded the strongest separation between real and generated distributions.

Key Results

SeDID was benchmarked against the diffusion loss-based detection method by Matsumoto et al. (2023):

  • Massive Accuracy Gains: Across the three datasets, average detection accuracy jumped from 68.26% (baseline) to 90.24% with $\text{SeDID}_{\text{Stat}}$, and reached 93.99% with $\text{SeDID}_{\text{NNs}}$ (an average gain of over 25–30 percentage points).
  • Near-Perfect Detection on Complex Sets: On Tiny-ImageNet, $\text{SeDID}_{\text{NNs}}$ achieved 99.99% AUC and 99.80% accuracy (compared to the baseline’s 53.03% AUC and 52.54% accuracy).
  • CelebA Performance: Both SeDID variants attained near-flawless discrimination at lower timesteps ($\text{SeDID}_{\text{NNs}}$ scored 1.0000 AUC and 100% accuracy).

Limitations and Future Work

  • Low-Resolution Focus: Experiments were restricted to $32 \times 32$ image resolutions on standard DDPM pipelines; performance on high-resolution text-to-image models (e.g., SDXL, Midjourney) remains to be comprehensively benchmarked.
  • Manual Timestep Tuning: The optimal evaluation step $T_{SE}$ currently requires empirical dataset-specific tuning. The authors highlight the need for an automated mechanism to select $T_{SE}$.
  • Unexplained Behavioral Inversions: The stark divergence between CelebA (best at low $T_{SE}$) and Tiny-ImageNet/CIFAR-10 (best at high $T_{SE}$) requires deeper theoretical analysis.
  • Defensive Trade-offs: The authors note that trying to "defend" diffusion models against SeDID via aggressive regularization severely harms generation quality, resulting in blurry, unusable images.

Summary updated

BibTeX
@inproceedings{ma2023exposing,
  author = {RuiPeng Ma and Jinhao Duan and Fei Kong and Xiaoshuang Shi and Kaidi Xu},
  title = {{Exposing the Fake: Effective Diffusion-Generated Images Detection}},
  booktitle = {AdvML-Frontiers @ ICML},
  year = {2023},
  url = {https://openreview.net/forum?id=7R62e4Wgim},
}
Figure