This repository contains the implementation code for the paper:
TextureCrop: Enhancing Synthetic Image Detection through Texture-based Cropping (available at arXiv:2402.19091) Despina Konstantinidou, Christos Koutlis, Symeon Papadopoulos
Generative AI technologies produce increasingly realistic imagery, which, despite its potential for creative applications, can also be misused to produce misleading and harmful content. This renders Synthetic Image Detection (SID) methods essential for identifying AI-generated content online. State-of-the-art SID methods typically resize or center-crop input images due to architectural or computational constraints, which hampers the detection of artifacts that appear in high-resolution images. To address this limitation, we propose TextureCrop, an image pre-processing component that can be plugged in any pre-trained SID model to improve its performance. By focusing on high-frequency image parts where generative artifacts are prevalent, TextureCrop enhances SID performance with manageable memory requirements. Experimental results demonstrate a consistent improvement in AUC across various detectors by 6.1% compared to center cropping and by 15% compared to resizing, across high-resolution images from the Forensynths, Synthbuster and TWIGMA datasets.
Figure 1. Overview of the TextureCrop Pipeline.
Clone the repository:
git clone https://github.com/mever-team/texture-crop
Create the environment:
conda create -n sid python=3.11
conda activate sid
conda install pytorch torchvision torchaudio pytorch-cuda=12.1 -c pytorch -c nvidia
pip install -r requirements.txt
Store the datasets in datasets/
:
- Download the
Forensynths
test set as desrcibed in https://github.com/PeterWang512/CNNDetection - Download the
Synthbuster
dataset as desrcibed in https://zenodo.org/records/10066460 - Download the
RAISE
dataset as desrcibed in http://loki.disi.unitn.it/RAISE/guide.html - Download the
TWIGMA
dataset as desrcibed in https://zenodo.org/records/8031785 - Download the
OpenImages
dataset as desrcibed in https://storage.googleapis.com/openimages/web/download_v7.html
The data/
directory should look like:
data
└── forensynths
└── synthbuster
├── raise
└── twigma
└── openimagesdataset
The following models have been evalauated. Note that for some of these models, there are multiple pretrained instances.
Model Name | Parameters | Paper Title | Original Code |
---|---|---|---|
GramNet | - | Global Texture Enhancement for Fake Face Detection In the Wild | 🔗 |
CNNDetect | 0.1 and 0.5 | CNN-generated images are surprisingly easy to spot...for now | 🔗 |
GANID | ProGAN and StyleGAN2 | On the detection of synthetic images generated by diffusion models. | 🔗 |
DIMD | - | On the detection of synthetic images generated by diffusion models. | 🔗 |
UnivFD | - | Towards Universal Fake Image Detectors that Generalize Across Generative Models | 🔗 |
RINE | 4 and LDM | Leveraging Representations from Intermediate Encoder-blocks for Synthetic Image Detection | 🔗 |
PatchCraft | - | PatchCraft: Exploring Texture Patch for Efficient AI-generated Image Detection | 🔗 |
To evaluate all processing methods on an image using a specific model run:
python demo.py --method method --parameter parameter --image_path image
To evaluate a single model using a specific processing method (resize, centercrop, tencrop, or texture_crop):
python val.py --processing_method processing_method --method method --parameter parameter
To evaluate all models using all processing methods:
bash val.sh
To reproduce the ablation study run:
bash ablations.sh
.
Despina Konstantinidou ([email protected])