{"id":21444198,"url":"https://github.com/jonasricker/diffusion-model-deepfake-detection","last_synced_at":"2026-02-12T08:33:15.656Z","repository":{"id":152233615,"uuid":"584310396","full_name":"jonasricker/diffusion-model-deepfake-detection","owner":"jonasricker","description":"[VISAPP2024] Towards the Detection of Diffusion Model Deepfakes","archived":false,"fork":false,"pushed_at":"2024-11-20T11:50:54.000Z","size":1751,"stargazers_count":96,"open_issues_count":0,"forks_count":11,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-05-19T18:06:47.279Z","etag":null,"topics":["deepfake-detection","deepfakes","diffusion-models","gan","pytorch"],"latest_commit_sha":null,"homepage":"https://arxiv.org/abs/2210.14571","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jonasricker.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-01-02T07:33:55.000Z","updated_at":"2025-05-07T04:27:29.000Z","dependencies_parsed_at":"2024-01-22T09:43:48.232Z","dependency_job_id":"60f24e87-88d7-4f29-a5f8-a769fd49f0ed","html_url":"https://github.com/jonasricker/diffusion-model-deepfake-detection","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/jonasricker/diffusion-model-deepfake-detection","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonasricker%2Fdiffusion-model-deepfake-detection","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonasricker%2Fdiffusion-model-deepfake-detection/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonasricker%2Fdiffusion-model-deepfake-detection/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonasricker%2Fdiffusion-model-deepfake-detection/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jonasricker","download_url":"https://codeload.github.com/jonasricker/diffusion-model-deepfake-detection/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonasricker%2Fdiffusion-model-deepfake-detection/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29361819,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-12T01:03:07.613Z","status":"online","status_checked_at":"2026-02-12T02:00:06.911Z","response_time":55,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["deepfake-detection","deepfakes","diffusion-models","gan","pytorch"],"created_at":"2024-11-23T02:16:35.316Z","updated_at":"2026-02-12T08:33:15.640Z","avatar_url":"https://github.com/jonasricker.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# [VISIGRAPP2024] Towards the Detection of Diffusion Model Deepfakes\n[Jonas Ricker](https://jonasricker.com), [Simon Damm](https://informatik.rub.de/ml/people/damm/), [Thorsten Holz](https://cispa.de/de/people/c01thho), [Asja Fischer](https://informatik.rub.de/fischer/)  \nInternational Joint Conference on Computer Vision, Imaging and Computer Graphics Theory and Applications (VISIGRAPP), 2024\n\nThe extended version of our work with additional experiments and supplemental material is available on [arxiv](https://arxiv.org/abs/2210.14571).\n\n# Code\nWe provide the source code and instructions on how to recreate the results in the paper. The code is tested with Python 3.8. To install the required packages run `pip install -r requirements.txt`. You probably should install the [version of PyTorch matching your system](https://pytorch.org/get-started/locally/).\n\nThe commands below expect a working directory which contains data, models, and to which results will be written. To run the commandas as-is, save the path to this directory in a variable by executing `WORKDIR=path/to/working/directory`.\n\nInstructions for downloading the [Checkpoints](#checkpoints) and [Dataset](#dataset) are given in the corresponding sections. Your working directory should have the following structure:\n```bash\nworkdir/\n├── data\n│   └── diffusion_model_deepfakes_lsun_bedroom\n│       ├── test\n│       │   ├── ADM\n│       │   ├── ...\n│       ├── train  # only required for training your own models\n│       │   ├── ADM\n│       │   ├── ...\n│       └── val  # only required for training your own models\n│           ├── ADM\n│           ├── ...\n└── models\n    ├── gragnaniello2021\n    │   ├── gandetection_resnet50nodown_progan.pth\n    │   └── gandetection_resnet50nodown_stylegan2.pth\n    ├── mandelli2022\n    │   ├── method_A.pth\n    │   ├── method_B.pth\n    │   ├── method_C.pth\n    │   ├── method_D.pth\n    │   └── method_E.pth\n    └── wang2020\n        ├── blur_jpg_prob0.1.pth\n        ├── blur_jpg_prob0.5.pth\n        ├── finetuning\n        │   ├── ADM\n        │   │   └── model_epoch_best.pth\n        │   ├── ...\n        └── scratch\n            ├── ADM\n            │   └── model_epoch_best.pth\n            ├── ...\n```\n\nCalling any of the commands below with `-h` prints further information on the arguments.\n\n## Detector Evaluation\nTo recreate the results in Table 2 run\n```bash\npython evaluate_detectors.py $WORKDIR/data/diffusion_model_deepfakes_lsun_bedroom/test $WORKDIR/models $WORKDIR/output --img-dirs Real ProGAN StyleGAN ProjectedGAN Diff-StyleGAN2 Diff-ProjectedGAN DDPM IDDPM ADM PNDM LDM --predictors wang2020 gragnaniello2021 mandelli2022 --wang2020-model-path wang2020/blur_jpg_prob0.5.pth wang2020/blur_jpg_prob0.1.pth --gragnaniello2021-model-path gragnaniello2021/gandetection_resnet50nodown_progan.pth gragnaniello2021/gandetection_resnet50nodown_stylegan2.pth --metric AUROC PD@5% PD@1%\n```\n\nTo recreate Figures 1a and 1b run\n```bash\npython evaluate_detectors.py $WORKDIR/data/diffusion_model_deepfakes_lsun_bedroom/test $WORKDIR/models $WORKDIR/output --img-dirs Real ProGAN StyleGAN ProjectedGAN Diff-StyleGAN2 Diff-ProjectedGAN DDPM IDDPM ADM PNDM LDM --experiment finetuning --predictors wang2020 --wang2020-model-path wang2020/finetuning/ProGAN wang2020/finetuning/StyleGAN wang2020/finetuning/ProjectedGAN wang2020/finetuning/Diff-StyleGAN2 wang2020/finetuning/Diff-ProjectedGAN wang2020/finetuning/DDPM wang2020/finetuning/IDDPM wang2020/finetuning/ADM wang2020/finetuning/PNDM wang2020/finetuning/LDM wang2020/finetuning/GAN wang2020/finetuning/DM wang2020/finetuning/All --output cfm --metric AUROC\npython evaluate_detectors.py $WORKDIR/data/diffusion_model_deepfakes_lsun_bedroom/test $WORKDIR/models $WORKDIR/output --img-dirs Real ProGAN StyleGAN ProjectedGAN Diff-StyleGAN2 Diff-ProjectedGAN DDPM IDDPM ADM PNDM LDM --experiment finetuning --predictors wang2020 --wang2020-model-path wang2020/finetuning/ProGAN wang2020/finetuning/StyleGAN wang2020/finetuning/ProjectedGAN wang2020/finetuning/Diff-StyleGAN2 wang2020/finetuning/Diff-ProjectedGAN wang2020/finetuning/DDPM wang2020/finetuning/IDDPM wang2020/finetuning/ADM wang2020/finetuning/PNDM wang2020/finetuning/LDM wang2020/finetuning/GAN wang2020/finetuning/DM wang2020/finetuning/All --output cfm --metric PD@1%\n```\n\nTo recreate Figures 8a and 8b run\n```bash\npython evaluate_detectors.py $WORKDIR/data/diffusion_model_deepfakes_lsun_bedroom/test $WORKDIR/models $WORKDIR/output --img-dirs Real ProGAN StyleGAN ProjectedGAN Diff-StyleGAN2 Diff-ProjectedGAN DDPM IDDPM ADM PNDM LDM --experiment scratch --predictors wang2020 --wang2020-model-path wang2020/scratch/ProGAN wang2020/scratch/StyleGAN wang2020/scratch/ProjectedGAN wang2020/scratch/Diff-StyleGAN2 wang2020/scratch/Diff-ProjectedGAN wang2020/scratch/DDPM wang2020/scratch/IDDPM wang2020/scratch/ADM wang2020/scratch/PNDM wang2020/scratch/LDM wang2020/scratch/GAN wang2020/scratch/DM wang2020/scratch/All --output cfm --metric AUROC\npython evaluate_detectors.py $WORKDIR/data/diffusion_model_deepfakes_lsun_bedroom/test $WORKDIR/models $WORKDIR/output --img-dirs Real ProGAN StyleGAN ProjectedGAN Diff-StyleGAN2 Diff-ProjectedGAN DDPM IDDPM ADM PNDM LDM --experiment scratch --predictors wang2020 --wang2020-model-path wang2020/scratch/ProGAN wang2020/scratch/StyleGAN wang2020/scratch/ProjectedGAN wang2020/scratch/Diff-StyleGAN2 wang2020/scratch/Diff-ProjectedGAN wang2020/scratch/DDPM wang2020/scratch/IDDPM wang2020/scratch/ADM wang2020/scratch/PNDM wang2020/scratch/LDM wang2020/scratch/GAN wang2020/scratch/DM wang2020/scratch/All --output cfm --metric PD@1%\n```\n\nTo recreate the results in Tables 4 and 5 run\n```bash\npython evaluate_detectors.py $WORKDIR/data/diffusion_model_deepfakes_lsun_bedroom/test $WORKDIR/models $WORKDIR/output --img-dirs Real ProGAN StyleGAN ProjectedGAN Diff-StyleGAN2 Diff-ProjectedGAN DDPM IDDPM ADM PNDM LDM --experiment noise --predictors gragnaniello2021 --gragnaniello2021-model-path gragnaniello2021/gandetection_resnet50nodown_progan.pth --metric AUROC PD@5% PD@1% --perturbation noise\npython evaluate_detectors.py $WORKDIR/data/diffusion_model_deepfakes_lsun_bedroom/test $WORKDIR/models $WORKDIR/output --img-dirs Real ProGAN StyleGAN ProjectedGAN Diff-StyleGAN2 Diff-ProjectedGAN DDPM IDDPM ADM PNDM LDM --experiment blur --predictors gragnaniello2021 --gragnaniello2021-model-path gragnaniello2021/gandetection_resnet50nodown_progan.pth --metric AUROC PD@5% PD@1% --perturbation blur\npython evaluate_detectors.py $WORKDIR/data/diffusion_model_deepfakes_lsun_bedroom/test $WORKDIR/models $WORKDIR/output --img-dirs Real ProGAN StyleGAN ProjectedGAN Diff-StyleGAN2 Diff-ProjectedGAN DDPM IDDPM ADM PNDM LDM --experiment jpeg --predictors gragnaniello2021 --gragnaniello2021-model-path gragnaniello2021/gandetection_resnet50nodown_progan.pth --metric AUROC PD@5% PD@1% --perturbation jpeg\npython evaluate_detectors.py $WORKDIR/data/diffusion_model_deepfakes_lsun_bedroom/test $WORKDIR/models $WORKDIR/output --img-dirs Real ProGAN StyleGAN ProjectedGAN Diff-StyleGAN2 Diff-ProjectedGAN DDPM IDDPM ADM PNDM LDM --experiment cropping --predictors gragnaniello2021 --gragnaniello2021-model-path gragnaniello2021/gandetection_resnet50nodown_progan.pth --metric AUROC PD@5% PD@1% --perturbation cropping\n\npython evaluate_detectors.py $WORKDIR/data/diffusion_model_deepfakes_lsun_bedroom/test $WORKDIR/models $WORKDIR/output --img-dirs Real DDPM IDDPM ADM PNDM LDM --experiment noise_ft_DM --predictors wang2020 --wang2020-model-path wang2020/finetuning/DM --metric AUROC PD@5% PD@1% --perturbation noise\npython evaluate_detectors.py $WORKDIR/data/diffusion_model_deepfakes_lsun_bedroom/test $WORKDIR/models $WORKDIR/output --img-dirs Real DDPM IDDPM ADM PNDM LDM --experiment blur_ft_DM --predictors wang2020 --wang2020-model-path wang2020/finetuning/DM --metric AUROC PD@5% PD@1% --perturbation blur\npython evaluate_detectors.py $WORKDIR/data/diffusion_model_deepfakes_lsun_bedroom/test $WORKDIR/models $WORKDIR/output --img-dirs Real DDPM IDDPM ADM PNDM LDM --experiment jpeg_ft_DM --predictors wang2020 --wang2020-model-path wang2020/finetuning/DM --metric AUROC PD@5% PD@1% --perturbation jpeg\npython evaluate_detectors.py $WORKDIR/data/diffusion_model_deepfakes_lsun_bedroom/test $WORKDIR/models $WORKDIR/output --img-dirs Real DDPM IDDPM ADM PNDM LDM --experiment cropping_ft_DM --predictors wang2020 --wang2020-model-path wang2020/finetuning/DM --metric AUROC PD@5% PD@1% --perturbation cropping\n```\n\n## Feature Space Analysis\nTo extract the features from Gragnaniello2021 run\n```bash\npython detectors/gragnaniello2021/features.py --weights-path $WORKDIR/models/gragnaniello2021/gandetection_resnet50nodown_progan.pth --img-root $WORKDIR/data/diffusion_model_deepfakes_lsun_bedroom/test --output-root $WORKDIR/output\npython detectors/gragnaniello2021/features.py --weights-path $WORKDIR/models/gragnaniello2021/gandetection_resnet50nodown_stylegan2.pth --img-root $WORKDIR/data/diffusion_model_deepfakes_lsun_bedroom/test --output-root $WORKDIR/output\n```\n\nTo extract the features from Wang2020 using a modified version of the original script run\n```bash\npython detectors/wang2020/demo_dir_features.py --dir $WORKDIR/data/diffusion_model_deepfakes_lsun_bedroom/test --model_path $WORKDIR/models/wang2020/blur_jpg_prob0.1.pth --output_root $WORKDIR/output\npython detectors/wang2020/demo_dir_features.py --dir $WORKDIR/data/diffusion_model_deepfakes_lsun_bedroom/test --model_path $WORKDIR/models/wang2020/blur_jpg_prob0.5.pth --output_root $WORKDIR/output\npython detectors/wang2020/demo_dir_features.py --dir $WORKDIR/data/diffusion_model_deepfakes_lsun_bedroom/test --model_path $WORKDIR/models/wang2020/finetuning/All --output_root $WORKDIR/output\npython detectors/wang2020/demo_dir_features.py --dir $WORKDIR/data/diffusion_model_deepfakes_lsun_bedroom/test --model_path $WORKDIR/models/wang2020/finetuning/GAN --output_root $WORKDIR/output\npython detectors/wang2020/demo_dir_features.py --dir $WORKDIR/data/diffusion_model_deepfakes_lsun_bedroom/test --model_path $WORKDIR/models/wang2020/finetuning/DM --output_root $WORKDIR/output\npython detectors/wang2020/demo_dir_features.py --dir $WORKDIR/data/diffusion_model_deepfakes_lsun_bedroom/test --model_path $WORKDIR/models/wang2020/scratch/All --output_root $WORKDIR/output\npython detectors/wang2020/demo_dir_features.py --dir $WORKDIR/data/diffusion_model_deepfakes_lsun_bedroom/test --model_path $WORKDIR/models/wang2020/scratch/GAN --output_root $WORKDIR/output\npython detectors/wang2020/demo_dir_features.py --dir $WORKDIR/data/diffusion_model_deepfakes_lsun_bedroom/test --model_path $WORKDIR/models/wang2020/scratch/DM --output_root $WORKDIR/output\n```\n\nTo calculate the Maximum Mean Discrepancy (MMD) based on extracted features run\n```bash\npython feature_space_analysis/calculate_MMD.py -b $WORKDIR/output/features\n```\n\nThe plots can then be recreated using the notebooks `plot_MMD.ipynb` and `plot_tSNE.ipynb`.\n\n## Frequency Analysis\nTo recreate Figures 3a and 3b run\n```bash\npython frequency_analysis.py $WORKDIR/data/diffusion_model_deepfakes_lsun_bedroom/test $WORKDIR/output fft_hp --img-dirs Real ProGAN StyleGAN ProjectedGAN Diff-StyleGAN2 Diff-ProjectedGAN --log --vmin 1e-5 --vmax 1e-1\npython frequency_analysis.py $WORKDIR/data/diffusion_model_deepfakes_lsun_bedroom/test $WORKDIR/output fft_hp --img-dirs Real DDPM IDDPM ADM PNDM LDM --log --vmin 1e-5 --vmax 1e-1\n```\n\nTo compute DCT spectra, as in Figure 14, replace `fft_hp` with `dct`.\n\nTo recreate Figures 4a and 4b run\n```bash\npython frequency_analysis.py $WORKDIR/data/diffusion_model_deepfakes_lsun_bedroom/test $WORKDIR/output density --img-dirs Real ProGAN StyleGAN ProjectedGAN Diff-StyleGAN2 Diff-ProjectedGAN --log --fraction 0.49 --zoom\npython frequency_analysis.py $WORKDIR/data/diffusion_model_deepfakes_lsun_bedroom/test $WORKDIR/output density --img-dirs Real DDPM IDDPM ADM PNDM LDM --log --fraction 0.49 --zoom\n```\n\nTo recreate the results in Table 3 run\n```bash\npython logistic_regression.py $WORKDIR/data/diffusion_model_deepfakes_lsun_bedroom $WORKDIR/output --img-dirs ProGAN StyleGAN ProjectedGAN Diff-StyleGAN2 Diff-ProjectedGAN DDPM IDDPM ADM PNDM LDM\n```\nNote that to run this evaluation it is required to also have the `train` and `val` directories of the dataset.\n\n## Spectrum Evolutions\nSince we analyze the spectrum evolution using ADM, it is necessary to clone the [repository](https://github.com/openai/guided-diffusion) and install the package by calling `pip install .` from within. Also, download the LSUN Bedroom checkpoint and save it to `$WORKDIR/models/dhariwal2021/lsun_bedroom.pt`.\n\nFirst, compute the reference spectrum from 10k real images by running\n```bash\npython spectrum_evolutions.py $WORKDIR/data/diffusion_model_deepfakes_lsun_bedroom/test/Real $WORKDIR/output compute_reference lsun_bedroom_ref\n```\n\nTo generate samples at different steps of the denoising process run\n```bash\npython sample_adm_denoising_process.py --model $WORKDIR/models/dhariwal2021/lsun_bedroom.pt --output_dir $WORKDIR/output/spectrum_vs_steps --store_within True --stop 1000 --step 10 --timestep_respacing 1000 --attention_resolutions 32,16,8 --class_cond False --diffusion_steps 1000 --dropout 0.1 --image_size 256 --learn_sigma True --noise_schedule linear --num_channels 256 --num_head_channels 64 --num_res_blocks 2 --resblock_updown True --use_fp16 True --use_scale_shift_norm True\npython sample_adm_denoising_process.py --model $WORKDIR/models/dhariwal2021/lsun_bedroom.pt --output_dir $WORKDIR/output/spectrum_vs_steps --store_within True --stop 100 --step 1 --timestep_respacing 1000 --attention_resolutions 32,16,8 --class_cond False --diffusion_steps 1000 --dropout 0.1 --image_size 256 --learn_sigma True --noise_schedule linear --num_channels 256 --num_head_channels 64 --num_res_blocks 2 --resblock_updown True --use_fp16 True --use_scale_shift_norm True\n```\n\nTo recreate Figures 5a and 5b run\n```bash\npython spectrum_evolutions.py $WORKDIR/output/spectrum_vs_steps/denoising-1000_10 $WORKDIR/output --fraction 0.49 spectrum_vs_steps $WORKDIR/output/spectrum_vs_steps/lsun_bedroom_ref-10000_samples.npy\npython spectrum_evolutions.py $WORKDIR/output/spectrum_vs_steps/denoising-100_1 $WORKDIR/output --fraction 0.49 spectrum_vs_steps $WORKDIR/output/spectrum_vs_steps/lsun_bedroom_ref-10000_samples.npy\n```\n\nTo plot the spectrum deviation relative to the diffusion process instead of the real spectrum, we first need to generate samples at different steps of the diffusion process by running\n```bash\npython sample_adm_diffusion_process.py --data_dir $WORKDIR/data/diffusion_model_deepfakes_lsun_bedroom/test/Real --output_dir $WORKDIR/output/spectrum_vs_steps --stop 1000 --step 10 --timestep_respacing 1000 --attention_resolutions 32,16,8 --class_cond False --diffusion_steps 1000 --dropout 0.1 --image_size 256 --learn_sigma True --noise_schedule linear --num_channels 256 --num_head_channels 64 --num_res_blocks 2 --resblock_updown True --use_fp16 True --use_scale_shift_norm True\npython sample_adm_diffusion_process.py --data_dir $WORKDIR/data/diffusion_model_deepfakes_lsun_bedroom/test/Real --output_dir $WORKDIR/output/spectrum_vs_steps --stop 100 --step 1 --timestep_respacing 1000 --attention_resolutions 32,16,8 --class_cond False --diffusion_steps 1000 --dropout 0.1 --image_size 256 --learn_sigma True --noise_schedule linear --num_channels 256 --num_head_channels 64 --num_res_blocks 2 --resblock_updown True --use_fp16 True --use_scale_shift_norm True\n```\n\nThen, to recreate Figures 15a and 15b run\n```bash\npython spectrum_evolutions.py $WORKDIR/output/spectrum_vs_steps/denoising-1000_10 $WORKDIR/output --fraction 0.49 denoising_vs_diffusion $WORKDIR/output/spectrum_vs_steps/diffusion-1000_10\npython spectrum_evolutions.py $WORKDIR/output/spectrum_vs_steps/denoising-100_1 $WORKDIR/output --fraction 0.49 denoising_vs_diffusion $WORKDIR/output/spectrum_vs_steps/diffusion-100_1\n```\n\nTo recreate Figure 16 run\n```bash\npython spectrum_evolutions.py $WORKDIR/output/spectrum_vs_steps/denoising-100_1 $WORKDIR/output --fraction 0.49  classification $WORKDIR/data/diffusion_model_deepfakes_lsun_bedroom/test/Real\n```\n\nTo sample images using different numbers of sampling steps (without and with DDIM) run\n```bash\nfor step in 2 4 8 16 25 50 100 200 500 1000; do python sample_adm_denoising_process.py --model $WORKDIR/models/dhariwal2021/lsun_bedroom.pt --output_dir $WORKDIR/output/spectrum_vs_steps --timestep_respacing $step --attention_resolutions 32,16,8 --class_cond False --diffusion_steps 1000 --dropout 0.1 --image_size 256 --learn_sigma True --noise_schedule linear --num_channels 256 --num_head_channels 64 --num_res_blocks 2 --resblock_updown True --use_fp16 True --use_scale_shift_norm True; done\nfor step in 2 4 8 16 25 50 100 200 500 1000; do python sample_adm_denoising_process.py --model $WORKDIR/models/dhariwal2021/lsun_bedroom.pt --output_dir $WORKDIR/output/spectrum_vs_steps --use_ddim True --timestep_respacing $step --attention_resolutions 32,16,8 --class_cond False --diffusion_steps 1000 --dropout 0.1 --image_size 256 --learn_sigma True --noise_schedule linear --num_channels 256 --num_head_channels 64 --num_res_blocks 2 --resblock_updown True --use_fp16 True --use_scale_shift_norm True; done\n```\n\nThen, to recreate Figures 18a and 18b run\n```bash\npython spectrum_evolutions.py $WORKDIR/output/spectrum_vs_steps/sampling_steps $WORKDIR/output --fraction 0.49 --ylabel \"Denoising Steps\" --all-labels spectrum_vs_steps $WORKDIR/output/spectrum_vs_steps/lsun_bedroom_ref-10000_samples.npy\npython spectrum_evolutions.py $WORKDIR/output/spectrum_vs_steps/sampling_steps_ddim $WORKDIR/output --fraction 0.49 --ylabel \"Denoising Steps\" --all-labels spectrum_vs_steps $WORKDIR/output/spectrum_vs_steps/lsun_bedroom_ref-10000_samples.npy\n```\n\nTo recreate Figures 19a and 19b run\n```bash\npython spectrum_evolutions.py $WORKDIR/output/spectrum_vs_steps/sampling_steps $WORKDIR/output --fraction 0.49 --ylabel \"Denoising Steps\" --all-labels classification $WORKDIR/data/diffusion_model_deepfakes_lsun_bedroom/test/Real\npython spectrum_evolutions.py $WORKDIR/output/spectrum_vs_steps/sampling_steps_ddim $WORKDIR/output --fraction 0.49 --ylabel \"Denoising Steps\" --all-labels classification $WORKDIR/data/diffusion_model_deepfakes_lsun_bedroom/test/Real\n```\n\n## Fakeness Ratings\nTo recreate Figures 11 and 12 run\n```bash\npython fakeness.py $WORKDIR/data/diffusion_model_deepfakes_lsun_bedroom/test $WORKDIR/output/evaluate/cache $WORKDIR/output --img-dirs ADM DDPM Diff-ProjectedGAN Diff-StyleGAN2 IDDPM LDM PNDM ProGAN ProjectedGAN StyleGAN\npython fakeness.py $WORKDIR/data/diffusion_model_deepfakes_lsun_bedroom/test $WORKDIR/output/evaluate/cache $WORKDIR/output --img-dirs ADM DDPM IDDPM LDM PNDM --detector wang2020_finetuning_DM\n```\nNote that this script uses the cache generated by `evaluate_detectors.py`, which is why it needs to be called first.\n\n# Checkpoints\nPre-trained models from [Wang2020](https://github.com/peterwang512/CNNDetection), [Gragnaniello2021](https://github.com/grip-unina/GANimageDetection), and [Mandelli2022](https://github.com/polimi-ispl/gan-image-detection) can be downloaded from the corresponding repositories.\n\nCheckpoints for the models we trained ourselves using the architecture from [Wang2020](https://github.com/peterwang512/CNNDetection) are hosted on [Zenodo](https://doi.org/10.5281/zenodo.7673266).\nYou can re-create our checkpoints using our [Dataset](#dataset) and the instructions from the original repository.\n\n# Dataset\nThe main dataset used in this work is hosted on [Zenodo](https://doi.org/10.5281/zenodo.7528112).\nIn total, the dataset contains 50k samples (256x256) for each of the following generators trained on LSUN Bedroom, divided into train, validation, and test set (39k/1k/10k).\n\n| GANs | DMs |\n| :--- | :-- |\n| ProGAN | DDPM |\n| StyleGAN | IDDPM |\n| ProjectedGAN | ADM |\n| Diffusion-StyleGAN2 | PNDM |\n| Diffusion-ProjectedGAN | LDM |\n\nThe test set additionally contains 10k real images from [LSUN Bedroom](https://github.com/fyu/lsun) and can be used as-is.\nDue to storage limitations, the train and validation set contain only generated images. Real images, required for training, have to be added according to the [instructions given below](#train-and-validation-set).\n\n## Test Set\nThe test set can be downloaded from [Zenodo](https://zenodo.org/record/7528113). To validate that all images were downloaded correctly, you can run the following command and compare the hash value (computation takes some time).\n```\n$ find diffusion_model_deepfakes_lsun_bedroom/test/ -type f -print0 | sort -z | xargs -0 sha1sum | cut -d \" \" -f 1 | sha1sum\n68bd7326113b9cde3cd4eadf1e10e5fca77df751  -\n```\n\n## Train and Validation Set\nTo recreate the train and validation set, first download both zip-archives from [Zenodo](https://zenodo.org/record/7528113) and extract them in the same directory. Then, download the entire LSUN Bedroom training data in LMDB format according to the instructions in the [LSUN repository](https://github.com/fyu/lsun). Finally, run [recreate_train_data.py](recreate_train_data.py) (requires packages [lmbd](https://lmdb.readthedocs.io/en/release/) and [Pillow](https://pillow.readthedocs.io/en/stable/)):\n```\n$ python recreate_train_data.py path/to/bedroom_train_lmbd path/to/diffusion_model_deepfakes_lsun_bedroom\n```\nThe script will distribute real images such that for each generator there is a unique set of 40k real images (39k train, 1k validation) with the correct dimensions. Note that due to the large amount of images this will take some time. For each generator, real images will be in `0_real`, fake images in `1_fake`.\n\nThe script performs a simple form of validation. You can additionally run the following commands and compare the hash values (computation takes some time).\n```\n$ find diffusion_model_deepfakes_lsun_bedroom/train/ -type f -print0 | sort -z | xargs -0 sha1sum | cut -d \" \" -f 1 | sha1sum\n10fd255e5669e76b4e9bde93f672733a5dfa92fa  -\n\n$ find diffusion_model_deepfakes_lsun_bedroom/val/ -type f -print0 | sort -z | xargs -0 sha1sum | cut -d \" \" -f 1 | sha1sum\nc836fe592e49ab630ccc30675694ab32aff8e1a3  -\n```\n\n## Additional Datasets\nThe additional datasets (LSUN Cat, LSUN Horse, LSUN Church, ImageNet, FFHQ, Text2Img) are hosted on [Zenodo](https://zenodo.org/doi/10.5281/zenodo.10454274).\nFor each dataset we provide real and generated images from the generators specified in the paper. An exception is Text2Img, for which we cannot provide real images due to copyright.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonasricker%2Fdiffusion-model-deepfake-detection","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjonasricker%2Fdiffusion-model-deepfake-detection","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonasricker%2Fdiffusion-model-deepfake-detection/lists"}