Skip to content

implementation of the paper Scaling Up AI-Generated Image Detection with Generator-Aware Prototypes

Notifications You must be signed in to change notification settings

UltraCapture/GAPL

Repository files navigation

[Scaling Up AI-Generated Image Detection with Generator-Aware Prototypes]

arXiv License: MIT Huggingface

πŸ”₯ News

[2026.02] πŸŽ‰ GAPL has been accepted to CVPR 2026!

[2025.12] πŸ“„ Paper released on arXiv

πŸ’‘ Motivation

Motivation Framework

Figure 1: Overview of our proposed Generator-Aware Prototype Learning (GAPL) framework.

In scaling up AIGI detections, generated images show heterogenity and cause previous AIGI detector fails to scale.

We learn a small set of forgery concepts as Generator-Aware Prototypes. And convert diverse generators into some certain prototypes.

πŸ› οΈ Preparation

1. Environment Setup

We provide the minimum requirement package in requirements.txt, you could check whether your environment satisfy it or create an enviroment with the following command.

pip install -r requirements.txt

πŸš€ Quick inference

To evaluate performance of the proposed GAPL, You need to download the checkpoint from

1. Evaluate the proposed model in benchmarks.

To reproduce the results reported in our paper across various benchmarks:

  1. Modify the dataset paths in benchmarks.py to point to your local data.
  2. Run the evaluation script:
bash scripts/val_bench.sh

2. Single Image Inference

You can also run inference on a single image to detect whether it is Real or Fake.

python inference.py \
  --model_path pretrained/checkpoint.pt \
  --image_path assets/test_image.jpg \
  --device cuda

Output Example:

[INFO] Loading model from pretrained/checkpoint.pt...
[RESULT] Image: assets/test_image.jpg
  -> Prediction: Fake (AI-Generated)
  -> Confidence: 99.8%

πŸ‹οΈ Training a GAPL model

πŸ“¦ Prerequisites

Before starting, please ensure you have prepared the required datasets:

  • Stage 1 Data:
    • GenImage or CNNSpot Training Set.
    • CLIP Pre-trained Model (will be automatically downloaded via HuggingFace).
  • Stage 2 Data:

Stage 1: Backbone Training & Prototype Extraction

In this stage, we train the backbone and learn the initial generator-aware prototypes.

Step 1: Configure Paths Please open prototype_dataset.py and modify the dataset paths to match your local environment.

Step 2: Train Backbone Run the following script to start training:

bash scripts/stage1.sh

Step 3: Extract Prototypes After the backbone training converges, run the extraction script to generate the prototype vectors:

prototype/dream_prototype.py

⚑ Fast Track: We provide the pre-trained Stage 1 checkpoint and pre-extracted prototype vectors. You can skip this stage by downloading them from pretrained.

Stage 2: Fine-tuning

In the second stage, we fine-tune the model using the Community Forensics dataset to enhance robustness against diverse generators.

Run Training:

scripts/stage2.sh

πŸ–ŠοΈ Citation

If you find our work useful in your research, please consider citing:

@article{qin2025Scaling,
  title={Scaling Up AI-Generated Image Detection with Generator-Aware Prototypes},
  author={Qin, Ziheng and Ji, Yuheng and Tao, Renshuai and Tian, Yuxuan and Liu, Yuyang and Wang, Yipu and Zheng, Xiaolong},
  journal={arXiv preprint arXiv:2512.12982},
  year={2025}
}

πŸ™ Acknowledgements

Our code is developed based on the following excellent open-source repositories. We appreciate their excellent work and contributions to the community:

CNNDetection

Community Forensics We leverage the dataset and borrow some code from this codebase.

About

implementation of the paper Scaling Up AI-Generated Image Detection with Generator-Aware Prototypes

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published