Skip to content
This repository has been archived by the owner on Jun 2, 2024. It is now read-only.
/ LGrad Public archive
forked from chuangchuangtan/LGrad

Code for the paper: Learning on Gradients: Generalized Artifacts Representation for GAN-Generated Images Detection

Notifications You must be signed in to change notification settings

rjvaishnavi/LGrad

 
 

Repository files navigation

Learning on Gradients: Generalized Artifacts Representation for GAN-Generated Images Detection


Beijing Jiaotong University, YanShan University

overall pipeline

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}
}

Environment setup

To get started, we suggest transforming the image into a gradient using the environment from stylegan. Following this step, we recommend installing the required packages by running the command:

pip install -r requirements.txt

Getting the data

Download dataset from CNNDetection.

Transform Image to Gradients

  1. 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/karras2019styl
egan-bedrooms-256x256.pkl
  1. Run using
sh ./transform_img2grad.sh {GPU-ID} {Data-Root-Dir} {Grad-Save-Dir}

Training the model

sh ./train-detector.sh {GPU-ID} {Grad-Save-Dir}

Testing the detector

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}

Acknowledgments

This repository borrows partially from the CNNDetection and stylegan

About

Code for the paper: Learning on Gradients: Generalized Artifacts Representation for GAN-Generated Images Detection

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 99.1%
  • Shell 0.9%