Self-Supervised Learning for Detecting AI-Generated Faces as Anomalies

Mian Zou, Baosheng Yu, Yibing Zhan, Kede Ma · DOI

Abstract

Traditional AI-generated face detection relies on binary classification, which often fails to generalize to new, unseen generators. This paper proposes a shift toward anomaly detection, modeling the distribution of real photographic images using self-supervised learning. By training on camera-intrinsic metadata (EXIF tags) and local facial consistency, the model learns a robust representation of "realness." A Gaussian Mixture Model (GMM) then identifies AI-generated faces as deviations from this learned distribution. The method demonstrates superior generalization across nine state-of-the-art generators, including modern diffusion models.

Introduction

The rapid evolution of Generative Adversarial Networks (GANs) and Diffusion Models has made AI-generated faces nearly indistinguishable from real ones. Most current detection methods employ binary classification, training on specific sets of "real" and "fake" images. However, these detectors frequently overfit to the specific artifacts of their training data, leading to poor generalization when faced with new generators like Midjourney or SDXL.

Instead of defining what "fake" looks like, this research builds a robust mathematical model of "real" photographic images. By treating AI-generated faces as anomalies that deviate from the distribution of real photos, the authors create a detector that generalizes significantly better to unseen AI models.

Methodology

The proposed framework consists of two primary stages: Self-Supervised Representation Learning and Gaussian Mixture Model (GMM) Training.

The proposed two-stage framework: self-supervised representation learning followed by GMM-based anomaly detection.

1. Self-Supervised Pretext Tasks

To learn the intrinsic characteristics of real photography, a ResNet-50 backbone is trained on two tasks using only photographic images:

  • EXIF Tag Ranking: The model learns to rank image pairs based on ordinal camera settings: aperture, exposure time, focal length, and ISO speed. This forces the network to capture camera-intrinsic features like sensor noise and depth of field—physical properties that AI generators often fail to replicate accurately.
  • Face Manipulation Classification: The model identifies local "tampering" (e.g., horizontal or vertical flipping of eyes or mouth). This teaches the model to recognize natural facial symmetry and structural consistency.

2. Anomaly Detection via GMM

After training the feature extractor, real faces are passed through it to create a feature distribution modeled by a Gaussian Mixture Model (GMM). During inference, a test image is flagged as AI-generated if the GMM assigns it a low likelihood, indicating its features fall outside the "real" cluster.

Experimental Setup

The model was trained on 200,000 face photos from the FDF dataset (containing valid EXIF metadata) and the GMM was constructed using 25,000 real images from CelebA-HQ. Evaluation was conducted against real images and AI-generated faces from nine state-of-the-art generators, including GANs (StyleGAN2, VQGAN) and Diffusion Models (LDM, DDIM, Stable Diffusion v2.1, FreeDoM, HPS, Midjourney, and SDXL).

Key Results and Insights

The proposed method achieved an average accuracy of 86.63% and an average precision (AP) of 93.01% across the nine generators.

Performance comparison against state-of-the-art detectors across various AI generators.
  • Superior Generalization: The approach outperformed six state-of-the-art detectors, beating the second-best method by over 4% in average accuracy.
  • Robustness to Diffusion Models: While older detectors struggle with modern diffusion models like Midjourney and SDXL, this anomaly-based approach maintained high performance, achieving over 91% accuracy on SDXL.
  • EXIF as a Proxy for Physics: By ranking EXIF tags, the model learns the "physics" of digital photography. AI models, which generate pixels based on statistical patterns rather than optical physics, often miss these subtle forensic cues.
  • Ablation Study: Combining both EXIF ranking and face manipulation tasks was crucial; using either task alone resulted in significantly lower accuracy (69.35% and 77.67%, respectively).

Conclusion

This research demonstrates that treating AI-generated content as an anomaly is a powerful strategy for building generalizable detectors. Future work includes extending this approach beyond human faces to general scenes and exploring a "bilevel framework" to optimize feature learning and GMM fitting simultaneously. Additionally, these self-supervised features could be used to augment traditional binary classifiers for increased robustness.

Summary updated

BibTeX
@inproceedings{zou2025self,
  author = {Mian Zou and Baosheng Yu and Yibing Zhan and Kede Ma},
  title = {{Self-Supervised Learning for Detecting AI-Generated Faces as Anomalies}},
  booktitle = {IEEE International Conference on Acoustics, Speech and Signal Processing},
  year = {2025},
  url = {https://openreview.net/forum?id=i4bUhdAni4},
}
Figure