This is the official implementation of the paper On the use of Benford's law to detect GAN-generated images, accepted to ICPR2020 and currently available on arXiv.
This repository is currently under maintenance, if you are experiencing any problems, please open an issue.
-
Install conda
-
Create the
benford-gan
environment with environment.yml:conda env create -f environment.yml conda activate benford-gan
-
Install
pyjpeg-dct
package [1]:cd pyjpeg-dct pip install -e .
If you fail in installing
pyjpeg-dct
, you probably miss thepython3.6-dev
package for your OS. Google is your friend :)
Besides the feature extraction part, the rest of the pipeline is really dependent on the dataset used in the paper. Keep this in mind if you try to replicate the paper results. If you just want the feature extraction functions go straight to extract_first_digit_hist.py and extract_features_from_hist.py.
- Insert dataset root (folder containing images) into params.py. You probably also need to modify/delete lines 5-11 according to the dataset you want to use and its location on your machine.
- Extract first digit histograms extract_first_digit_hist.py.
- Compute divergence features from histograms extract_features_from_hist.py
- Run Random Forest classifier* rf_combinations_logo.py
* NB: to obtain results for test_compression=False
run rf_combinations_logo.py,
to obtain results for test_compression=True
run rf_combinations_logo_test_only.py
- Build db cnn_build_db.py
- Finetune Xception cnn_finetuning.py
- Extract cooccurrences extract_cooccurrences.py
- Train SVM on cooccurrences svm_cooccurrences.py
- Train RF on cooccurrences rf_cooccurrences.py
Image and Sound Processing Lab - Politecnico di Milano
- Nicolò Bonettini
- Paolo Bestagini
- Simone Milani
- Stefano Tubaro
[1] Courtesy of https://github.com/wartmanm/pyjpeg-dct