[ICCV'25 Highlight] Bi-Level Optimization for Self-Supervised AI-Generated Face Detection

January 11, 2026 · View on GitHub

This repository contains the official PyTorch implementation of the paper "Bi-Level Optimization for Self-Supervised AI-Generated Face Detection" by Mian Zou, Nan Zhong, Baosheng Yu, Yibing Zhan, and Kede Ma.

☀️ If you find this work useful for your research, please kindly star our repo and cite our paper! ☀️

⭐️Our series work: AIGFD_EXIF (ICASSP'25), SDAIE (TPAMI'26)

  • Release arXiv paper
  • ICCV 2025 open access
  • Release inference codes
  • Release checkpoints
    • OC-detector
    • BC-detector
  • Release datasets
    • Testing
    • Training
  • Release training codes

📁 Datasets

Datasets & MaterialsLink
TrainingBaidu Disk
TestingBaidu Disk

We use FDF (CC BY-NC-SA 2.0 version) for self-supervised training, and you can download it from the original project page. We also provide the augmented FDF by the proposed artificial face manipulations and the corresponding codes (See dataset/training_dataset/preprocessing). After downloading all the necessary files, please put them into the data folder, with the data structure in the data folder as

SSL_training_data
├── fdf_ccby2_exif_ordinal_categorical.json
├── FDF
│   ├── data
│   │   ├── face_dataaug_neg
│   │   │   ├── 1000002_0.png
│   │   │   ├──...
│   │   ├── fdf
│   │   │   ├── bounding_box
│   │   │   ├── landmarks
│   │   │   ├── fdf_metainfo.json
│   │   │   ├── images
│   │   │   │   ├── 128
│   │   │   │   │   ├──100000.png
│   │   │   │   │   ├──...
│   │   │   │   ├──...

For the test sets we used in the main experiments, we collected them from DiffusionFace and DiFF, and put them together for testing. If you find them useful, please cite these two papers. We also generate and collect additional AI-synthesized faces produced by other generative models. They are Diffusion Models: DDIM (2020), LDM (2022), SDv2.1 (2022), FreeDoM (2023), HPS (2023), Midjourney (2023), SDXL (2023), and GANs: ProGAN (2018), StarGAN (2018), StyleGAN2 (2020), pi-GAN (2021), VQ-GAN (2021). During testing, please put the dataset in the data folder, and the data structure is as follows:

data
├── celeba-face
│   ├── train.txt
│   ├── test.txt
│   ├── imgs
├── ddim
├── freeDoM
├── hps
├── ldm
├── midjourney
├── sdxl
├── sdv21
├── stargan
├── stylegan2
├── pigan
├── progan
├── vqgan

🚀 Quick Start

1. Installation of base requirements

  • python == 3.8
  • PyTorch == 1.13
  • Miniconda
  • CUDA == 11.7

2. Download the pretrained models

ModelDownload
OC-GMMBaidu Disk
BC-MLPBaidu Disk

After downloading these checkpoints, put them into the folder pretrained.

3. Inference

OC-GMM

CUDA_VISIBEL_DEVICES=4 python OC_GMM.py --resume ./pretrained/OC.pth

BC-MLP

CUDA_VISIBEL_DEVICES=4 python BC_MLP.py --resume ./pretrained/BC.pth [--only_gan, --only_diffusion, --only_paper, optional for choosing test sets, including images from GANs, diffusion models, or those mentioned in the paper.]

BC-MLP Complexity

CUDA_VISIBEL_DEVICES=4 python BC_MLP.py --resume ./pretrained/BC.pth --complexity_cal

⚡ Self-Supervised Training via Bi-Level Optimization

CUDA_VISIBLE_DEVICES=5 python SSL_training.py --batch_size 48 --output ./output/train_SSL/ --save_model \
--name FaceCoarse-autol3e4_equalExFa-rn50exifinit_bz48_lr_1e5_FLfidelityV2-u-SM \
--lr 1e-5 --cosineTmax 20 --scheduler cosine --resume_text None \
--weight autol --weights_exif 1.0 --weights_face 1.0 --autol_lr 3e-4 --task face_coarse

Citation

If you find this repository useful in your research, please consider citing the following paper:

@inproceedings{zou2025bi,
  title={Bi-Level Optimization for Self-Supervised AI-Generated Face Detection},
  author={Zou, Mian and Zhong, Nan and Yu, Baosheng and Zhan, Yibing and Ma, Kede},
  year={2025},
  booktitle={International Conference on Computer Vision},
  pages={18959--18968}
}