Beijing Jiaotong University, YanShan University
Reference github repository for the paper Learning on Gradients: Generalized Artifacts Representation for GAN-Generated Images Detection. Tan CC et al., proceedings of the IEEE/CVF CVPR 2023 . If you use our code, please cite our paper:
@inproceedings{tan2023learning,
title={Learning on Gradients: Generalized Artifacts Representation for GAN-Generated Images Detection},
author={Tan, Chuangchuang and Zhao, Yao and Wei, Shikui and Gu, Guanghua and Wei, Yunchao},
booktitle={Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition},
pages={12105--12114},
year={2023}
}
- 2023.08.17 The Gradient data is released. Baidu drive
- 2023.08.17 The Pytorch version of img2grad is released.
Img2grad environment:
We suggest transforming the image into a gradient using the tensorflow environment in docker image nvcr.io/nvidia/tensorflow:21.02-tf1-py3
from nvidia.
Classification environment: We recommend installing the required packages by running the command:
pip install -r requirements.txt
Download dataset from CNNDetection.
- Download pretrained model of stylegan, and put this
<project dir>/img2grad/stylegan/networks/
. Or run using
mkdir -p ./img2gad/stylegan/networks
wget https://lid-1302259812.cos.ap-nanjing.myqcloud.com/tmp/karras2019stylegan-bedrooms-256x256.pkl -O ./img2gad/stylegan/networks/karras2019stylegan-bedrooms-256x256.pkl
- Run using
sh ./transform_img2grad.sh {GPU-ID} {Data-Root-Dir} {Grad-Save-Dir}
sh ./train-detector.sh {GPU-ID} {Grad-Save-Dir}
Download all pretrained weight files fromhttps://drive.google.com/drive/folders/17-MAyCpMqyn4b_DFP2LekrmIgRovwoix?usp=share_link.
cd CNNDetection
CUDA_VISIBLE_DEVICES=0 python eval_test8gan.py --model_path {Model-Path} --dataroot {Grad-Test-Path} --batch_size {BS}
This repository borrows partially from the CNNDetection, stylegan, and genforce.