{"id":21444203,"url":"https://github.com/jonasricker/aeroblade","last_synced_at":"2025-07-27T13:10:00.043Z","repository":{"id":226443666,"uuid":"768702558","full_name":"jonasricker/aeroblade","owner":"jonasricker","description":"[CVPR2024] AEROBLADE: Training-Free Detection of Latent Diffusion Images Using Autoencoder Reconstruction Error","archived":false,"fork":false,"pushed_at":"2024-12-09T08:21:34.000Z","size":7594,"stargazers_count":53,"open_issues_count":1,"forks_count":9,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-07-14T21:37:28.316Z","etag":null,"topics":["autoencoder","cvpr","deepfake-detection","diffusion-models","latent-diffusion","midjourney","stable-diffusion"],"latest_commit_sha":null,"homepage":"https://openaccess.thecvf.com/content/CVPR2024/html/Ricker_AEROBLADE_Training-Free_Detection_of_Latent_Diffusion_Images_Using_Autoencoder_Reconstruction_CVPR_2024_paper.html","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"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":null,"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,"zenodo":null}},"created_at":"2024-03-07T15:20:59.000Z","updated_at":"2025-06-20T12:00:00.000Z","dependencies_parsed_at":"2024-05-14T08:52:38.837Z","dependency_job_id":"595efeb2-a179-4d98-8301-51fac3f6ae78","html_url":"https://github.com/jonasricker/aeroblade","commit_stats":null,"previous_names":["jonasricker/aeroblade"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/jonasricker/aeroblade","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonasricker%2Faeroblade","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonasricker%2Faeroblade/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonasricker%2Faeroblade/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonasricker%2Faeroblade/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jonasricker","download_url":"https://codeload.github.com/jonasricker/aeroblade/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonasricker%2Faeroblade/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267362339,"owners_count":24075098,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-27T02:00:11.917Z","response_time":82,"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":["autoencoder","cvpr","deepfake-detection","diffusion-models","latent-diffusion","midjourney","stable-diffusion"],"created_at":"2024-11-23T02:16:36.429Z","updated_at":"2025-07-27T13:10:00.007Z","avatar_url":"https://github.com/jonasricker.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# [[CVPR2024] AEROBLADE: Training-Free Detection of Latent Diffusion Images Using Autoencoder Reconstruction Error](https://openaccess.thecvf.com/content/CVPR2024/html/Ricker_AEROBLADE_Training-Free_Detection_of_Latent_Diffusion_Images_Using_Autoencoder_Reconstruction_CVPR_2024_paper.html)\n[Jonas Ricker](https://jonasricker.com), [Denis Lukovnikov](https://informatik.rub.de/ml/people/lukovnikov/), [Asja Fischer](https://informatik.rub.de/fischer/)    \nIEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), 2024\n\n\u003cp align=\"center\"\u003e\n\u003cimg src=\"media/header.png\" width=\"70%\" alt=\"header\"\u003e \n\u003c/p\u003e\n\n## Setup\nCreate a virtual environment and run\n```\npip install -r requirements.txt\npip install -e .\n```\n(tested with Python 3.10).\n\n## Quickstart\nIf you simply want to use AEROBLADE for detection, run\n```\npython scripts/run_aeroblade.py --files-or-dirs path/to/img.png path/to/dir\n```\nCalling the script without any arguments will use the images in `example_images`.\nNote that if you provide a directory, all images must have the same dimensions.\nBy default, it computes the reconstructions using the AEs from Stable Diffusion 1, Stable Diffusion 2, and Kandinsky 2.1 and measures the distance using the second LPIPS layer, which performed best in our experiments. Use `-h` to learn more about the available options.\n\nThe computed distances are printed and saved to `aeroblade_output/distances.csv`. Note that we save the negative distances, which is why the best AE is denoted by `max`.\n\n## Reproducing our Experiments\nHere we provide the commands to reproduce our experimental results.\nNote the following:\n- Your results might differ slightly due to randomness and different library versions.\n- Code to reconstruct the tables and figures is provided in the notebooks corresponding to the script names.\n- Most results are automatically cached to avoid repeated computations (the `cache` directory can grow quite large).\n- All reconstructions are saved in `data/reconstructions`, in unique directories for each configuration.\n\n### Data\nOur data can be downloaded from [Zenodo](https://zenodo.org/doi/10.5281/zenodo.10997234). Extract the `.zip` file and place the `data` directory inside the root directory of this repository.\n\n**Generated Images**\nAll generated images are readily available in `data/raw/generated`. For Stable Diffusion and Kandinsky, the directory name also contains the CLIP model used to extract the prompts, e.g., `CompVis-stable-diffusion-v1-1-ViT-L-14-openai`. We also provide the extracted prompts in `data/raw/prompts`.\n\n**Real Images**\nSince the real images from LAION-5B are subject to copyright, we cannot distribute them (see [FAQ](https://laion.ai/faq/)).\nTherefore, you will have to reconstruct the real dataset from the image URLs provided in `data/real/real_metadata.parquet`.\nThe following command will attempt to download the images from their respective URLs to `tmp/laion`:\n```\nimg2dataset --url_list data/raw/real/real_metadata.parquet --input_format \"parquet\" --url_col \"URL\" --caption_col \"TEXT\" --output_folder tmp/laion --resize_mode \"center_crop\" --min_image_size 512 --max_image_area 589824 --image_size 512 --encode_format \"png\" --encode_quality 6\n```\nTo ensure that the filenames correspond to the extracted prompts, you can run\n```\npython scripts/rename_real_images.py\n```\nThe renamed files will be saved to `data/raw/real`.\n\n**Note:** Images from LAION tend to become unavailable over time, which is why your dataset will likely be incomplete.\nAs a remedy, our scripts have the option to use pre-computed results for real images, which is detailed below.\nYou can also run the evaluations with a reduced number of images or use different real images.\n\n### 5.2. Evaluation of Detection Performance\n```\npython experiments/01_detect.py\n```\nTo use pre-computed distances of real images add `--precomputed-real-dist data/precomputed/01_default_real_dist.pickle`.\n\n### 5.4. Qualitative Image Analysis with AEROBLADE\n\n#### Relation Between Image Complexity and Reconstruction Error\n```\npython experiments/02_analyze_patches.py\n```\nTo use pre-computed distances and complexities of real images add `--precomputed-real-dist data/precomputed/02_default_real_dist.pickle --precomputed-real-compl data/precomputed/02_default_real_compl.pickle`.\n\n### 5.5. Additional Analyses\n\n#### Robustness to Perturbations\n```\npython experiments/01_detect.py --experiment-id robustness --amount 250 --transforms clean jpeg_90 jpeg_80 jpeg_70 jpeg_60 jpeg_50 blur_1.0 blur_2.0 blur_3.0 blur_4.0 blur_5.0 crop_0.9 crop_0.8 crop_0.7 crop_0.6 crop_0.5 noise_0.05 noise_0.1 noise_0.15 noise_0.2 noise_0.25\n```\nTo use pre-computed distances of real images add `--precomputed-real-dist data/precomputed/01_robustness_real_dist.pickle`.\n\n#### Exploring Different Distance Metrics\n```\npython experiments/01_detect.py --experiment-id distance_metric_ablation --distance-metrics lpips_vgg_0 lpips_alex_0 lpips_squeeze_0 psnr ssimc ms_ssim dists\n```\nTo use pre-computed distances of real images add `--precomputed-real-dist data/precomputed/01_distance_metric_ablation_real_dist.pickle`.\n\n#### Using Deeper Reconstructions\n```\npython experiments/03_deeper_reconstructions.py --experiment-id deeper_sd15 --real-dir data/raw/real --fake-dir data/raw/generated/runwayml-stable-diffusion-v1-5-ViT-L-14-openai --repo-id runwayml/stable-diffusion-v1-5\npython experiments/03_deeper_reconstructions.py --experiment-id deeper_sd21 --real-dir data/raw/real --fake-dir data/raw/generated/stabilityai-stable-diffusion-2-1-base-ViT-H-14-laion2b_s32b_b79k --repo-id stabilityai/stable-diffusion-2-1-base\n```\nTo use pre-computed distances of real images add `--precomputed-real-dist data/precomputed/03_deeper_sd15_real_dist.pickle` and `--precomputed-real-dist data/precomputed/03_deeper_sd21_real_dist.pickle`, respectively.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonasricker%2Faeroblade","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjonasricker%2Faeroblade","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonasricker%2Faeroblade/lists"}