WisconsinAIVision / UniversalFakeDetect

213 stars 26 forks source link

Detecting fake images

Towards Universal Fake Image Detectors that Generalize Across Generative Models
Utkarsh Ojha*, Yuheng Li*, Yong Jae Lee
(*Equal contribution)
CVPR 2023

[Project Page] [Paper]

>
Using images from one type of generative model (e.g., GAN), detect fake images from other breeds (e.g., Diffusion models)

Contents

Setup

  1. Clone this repository

    git clone https://github.com/Yuheng-Li/UniversalFakeDetect
    cd UniversalFakeDetect
  2. Install the necessary libraries

    pip install torch torchvision

Data

datasets └── test
├── progan
│── cyclegan
│── biggan │ . │ .

- Each directory (e.g., progan) will contain real/fake images under `0_real` and `1_fake` folders respectively.
- Dataset for the diffusion models (e.g., LDM/Glide) can be found [here](https://drive.google.com/file/d/1FXlGIRh_Ud3cScMgSVDbEWmPDmjcrm1t/view?usp=drive_link). Note that in the paper (Table 2/3), we had reported the results over 10k randomly sampled images. Since providing that many images for all the domains will take up too much space, we are only releasing 1k images for each domain; i.e., 1k images fake images and 1k real images for each domain (e.g., LDM-200).
- Download and unzip the file into `./diffusion_datasets` directory.

## Evaluation

- You can evaluate the model on all the dataset at once by running:
```bash
python validate.py  --arch=CLIP:ViT-L/14   --ckpt=pretrained_weights/fc_weights.pth   --result_folder=clip_vitl14 

Note that if no arguments are provided for real_path and fake_path, the script will perform the evaluation on all the domains specified in dataset_paths.py.

Training

Acknowledgement

We would like to thank Sheng-Yu Wang for releasing the real/fake images from different generative models. Our training pipeline is also inspired by his open-source code. We would also like to thank CompVis for releasing the pre-trained LDMs and LAION for open-sourcing LAION-400M dataset.

Citation

If you find our work helpful in your research, please cite it using the following:

@inproceedings{ojha2023fakedetect,
      title={Towards Universal Fake Image Detectors that Generalize Across Generative Models}, 
      author={Ojha, Utkarsh and Li, Yuheng and Lee, Yong Jae},
      booktitle={CVPR},
      year={2023},
}