Abstract
Current AI-generated image detectors predominantly rely on the final semantic layer of pre-trained models like CLIP. However, this research demonstrates that the final layers of Vision Transformers (ViTs) are optimized for high-level semantics, which can obscure the subtle, local structural artifacts characteristic of AI generation. We introduce MoLD (Mixture of Layers for AI-generated image Detection), a method that adaptively fuses features from across the entire Transformer backbone. MoLD achieves state-of-the-art performance, reaching 98.2% Average Precision on the GenImage benchmark and exhibiting superior generalization to unseen generative models.
The Problem: Semantic vs. Forensic Features
As generative models like Stable Diffusion and Midjourney evolve, distinguishing real photographs from AI-generated ones becomes increasingly difficult. Traditional detection methods often leverage the final layer of a pre-trained Vision Transformer (ViT), specifically from CLIP. The authors argue this approach is flawed: the final layers are designed to capture abstract concepts (e.g., "dog" vs. "cat"), whereas AI artifacts are typically local and structural (e.g., unnatural pixel gradients). By the time information reaches the final layer, these forensic cues are often "washed out" by semantic abstraction.
MoLD: Mixture of Layers for Detection
To address this, the authors propose MoLD. Instead of relying on a single layer, MoLD dynamically weights and combines features from all layers of a frozen ViT backbone.
The MoLD pipeline consists of four key steps:
- Feature Extraction: The
[CLS]token (global representation) is extracted from every layer of the ViT. - Gating Network: A lightweight neural network analyzes the input image to determine the relative importance of each layer for that specific sample.
- Adaptive Fusion: Features are projected into a shared space and aggregated based on the weights provided by the gating network.
- Efficiency: The massive ViT backbone remains frozen; only the small gating and fusion modules are trained, ensuring computational efficiency.
The "Mid-Layer" Advantage
A systematic layer-wise analysis revealed that mid-level layers (typically layers 12–18 in a 24-layer model) frequently outperform the final layer in detection accuracy.
This phenomenon is attributed to several factors:
- Complementary Information: Different layers capture unique, non-overlapping "fingerprints" of AI generation. Analysis of misclassified samples showed that layers fail on different types of images, suggesting that a multi-layer approach is inherently more robust.
- Semantic Interference: High-level semantic meaning can actually hinder detection. Experiments using CutMix to scramble semantic content showed that while final-layer performance dropped significantly, earlier layers remained robust.
- Attention Distance: Lower and middle layers have a shorter "attention distance," focusing on local pixel neighborhoods where generative artifacts are most prominent.
Key Results and Robustness
MoLD sets a new benchmark for both accuracy and generalization:
- Superior Generalization: When trained on one generator (e.g., ADM) and tested on others (e.g., Midjourney or Wukong), MoLD significantly outperformed existing methods like UnivFD. On the GenImage benchmark, it achieved an average precision (AP) of 98.2%, a substantial leap from the previous state-of-the-art of 90.4%.
- Robustness to Post-Processing: The model maintains high performance even when images undergo common social media degradations, such as JPEG compression, blurring, or resizing.
- Backbone Agnostic: While primarily evaluated using CLIP, MoLD also improved detection when applied to other backbones like DINOv2.
Conclusion and Future Directions
MoLD demonstrates that the "forensic" value of a Vision Transformer lies in its intermediate representations rather than its final output. While highly effective, the authors note that certain models like Midjourney remain challenging, producing artifacts that are exceptionally elusive. Future research will explore the application of multi-layer features to AI-edited images (inpainting) and aim to provide more explainable insights into the specific mathematical properties these mid-layers detect.
Summary updated