Home

Awesome

Detecting Images generated by Diffusers

Code for paper available on Arxiv

This paper explores the task of detecting images generated by text-to-image diffusion models. To evaluate this, we consider images generated from captions in the MSCOCO and Wikimedia datasets using two state-of-the-art models: Stable Diffusion and GLIDE. Our experiments show that it is possible to detect the generated images using simple Multi-Layer Perceptrons (MLPs), starting from features extracted by CLIP, or traditional Convolutional Neural Networks (CNNs). We also observe that models trained on images generated by Stable Diffusion can detect images generated by GLIDE relatively well, however, the reverse is not true. Lastly, we find that incorporating the associated textual information with the images rarely leads to significant improvement in detection results but that the type of subject depicted in the image can have a significant impact on performance. This work provides insights into the feasibility of detecting generated images, and has implications for security and privacy concerns in real-world applications.

approach

Preprocessing

To train and test a new model it is necessary to generate one synthetic image for each prompt available in the two considered datasets.

Run the following command to start the generation:

python3 generate_images.py

You can customize it with the following parameters:

This should be run for each dataset and for each part of the dataset (train/val/test). The output folders will look like:

- datasets
  - train
      - Prompt 0
        - Fake Image 0
        - ...
        - ...
        - Fake Image N
        - Pristine Image
       
      - ...
      - ...
      - Prompt N
        - ...
  - val
      - Prompt 0
        - Fake Image 0
        - ...
        - ...
        - Fake Image N
        - Pristine Image
       
      - ...
      - ...
      - Prompt N
        - ...
  - test 
      - Prompt 0
        - Fake Image 0
        - ...
        - ...
        - Fake Image N
        - Pristine Image
       
      - ...
      - ...
      - Prompt N
        - ...

Training

To train a model on the prepared dataset run the following command:

python3 train.py --config path/to/config

You can customize it with the following parameters:

Inference

To test a model on the prepared dataset run the following command:

python3 test.py --config path/to/config --model_weights path/to/model/weights

You can customize it with the following parameters: