SAFE: A Lightweight General AI Image Detection Method Achieving 96.7% Accuracy Across 33 Test Subsets
SAFE is a lightweight AI‑image detection framework using only 1.44 M parameters and 2.30 B FLOPs that preserves fine‑grained artifacts through crop‑based preprocessing, invariant augmentations, and high‑frequency wavelet features, achieving an average 96.7 % accuracy across 33 test subsets and strong generalization to unseen GAN and diffusion generators.
AI‑generated images have become so realistic that they spread widely on social media, creating an urgent need for universal detection methods that can generalize to unseen generative models such as GANs and diffusion models.
The research team from Xiaohongshu and the University of Science and Technology of China proposes SAFE, a detection framework that uses only 1.44 M parameters and 2.30 B FLOPs, yet reaches an average accuracy of 96.7 % on 33 test subsets—4.5 percentage points higher than the previous state‑of‑the‑art.
Key innovations of SAFE:
1. Artifact Preservation : Replace the conventional down‑sampling (Resize) in preprocessing with random cropping (RandomCrop) during training and center cropping (CenterCrop) during inference, preserving fine‑grained pixel relationships that reveal AI‑specific artifacts.
2. Invariant Augmentation : Introduce ColorJitter and RandomRotation to reduce bias from color variations and rotation, improving robustness to diverse visual conditions.
3. Local Awareness : Apply a patch‑wise random mask (RandomMask) during training, forcing the model to focus on local regions and enhancing its ability to detect forgeries even when large portions of the image are masked.
In addition, SAFE extracts high‑frequency features using a discrete wavelet transform (DWT), leveraging the pronounced differences between AI‑generated and natural images in the high‑frequency domain.
Experimental results:
The model is trained on AI images generated by ProGAN and corresponding real images, and evaluated on a broad test set covering 26 different generative models (both GANs and diffusion models). Compared with ten strong baselines, SAFE consistently outperforms them in both classification accuracy (ACC) and average precision (AP).
On the DiTFake benchmark—built from the latest diffusion generators Flux, Stable Diffusion 3, and PixArt—SAFE attains 99.4 % average accuracy, demonstrating exceptional generalization to new generators.
Plug‑and‑play capability: Because SAFE’s transformations are model‑agnostic, they can be inserted into existing detectors. When applied to the GenImage benchmark, the plug‑in yields a noticeable performance boost across all evaluated methods.
Ablation studies: Removing the crop‑based preprocessing degrades performance, confirming its importance over traditional resizing. Each augmentation (ColorJitter, RandomRotation, RandomMask) contributes positively, and their combination yields the best results. Feature‑level ablations show that high‑frequency operators (FFT, DCT, DWT) achieve comparable performance, with DWT offering a good trade‑off between simplicity and effectiveness.
The paper (accepted at KDD 2025) and the source code are publicly available:
Paper: https://arxiv.org/abs/2408.06741
Code: https://github.com/Ouxiang-Li/SAFE
Xiaohongshu Tech REDtech
Official account of the Xiaohongshu tech team, sharing tech innovations and problem insights, advancing together.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.