From 777f4815b654f8420f3d4886475bb15ecc36560e Mon Sep 17 00:00:00 2001 From: Alphonsce Date: Tue, 23 Apr 2024 00:25:22 +0300 Subject: [PATCH] final readme version --- .gitignore | 3 +- README.md | 84 +++++++++++++++++++++++++++++++++++++++++++++++++----- 2 files changed, 79 insertions(+), 8 deletions(-) diff --git a/.gitignore b/.gitignore index 04f6049..e916521 100644 --- a/.gitignore +++ b/.gitignore @@ -35,4 +35,5 @@ finetune_ldm_decoder *_images -fid_eval_* \ No newline at end of file +fid_eval_* +val_mock \ No newline at end of file diff --git a/README.md b/README.md index 57090e9..0672c20 100644 --- a/README.md +++ b/README.md @@ -158,7 +158,13 @@ wget https://huggingface.co/stabilityai/stable-diffusion-2-1-base/resolve/main/v wget https://raw.githubusercontent.com/Stability-AI/stablediffusion/main/configs/stable-diffusion/v2-inference.yaml ``` -You can download our pre-trained for message `111010110101000001010111010011010100010000100111` VAE decoder from [here](https://huggingface.co/Alphonsce/St_Sig_vae_decoder/resolve/main/ldm_decoder_checkpoint_000.pth?download=true). +**You can download our pre-trained VAE Decoder for message `111010110101000001010111010011010100010000100111`:** + +```bash +mkdir -p finetune_ldm_decoder +cd finetune_ldm_decoder +wget -O ldm_decoder_checkpoint_000.pth https://huggingface.co/Alphonsce/St_Sig_vae_decoder/resolve/main/ldm_decoder_checkpoint_000.pth?download=true +``` ### Fine-tune VAE decoder to given ID: @@ -181,7 +187,6 @@ VAL_DIR=generated_images/imgs_w --batch_size 4 \ --steps 100 \ --num_val_imgs 200 \ - --num_keys 1 \ --not_rand_key \ --key_str 111010110101000001010111010011010100010000100111 ``` @@ -246,20 +251,85 @@ accelerate launch -m metr.run_metr_fid \ --msg_scaler 100 \ --use_stable_sig ``` +--- +# Reproducing experiments from paper: -## Reproducing experiments from paper: +## Diffusion and VAE attack on METR: -### Diffusion and VAE attack on METR: +### Diffusion attack: +```bash +bash scripts/metr_generative_att/diff_att_metr.sh +``` +### VAE attack: +```bash +bash scripts/metr_generative_att/vae_2018_att_metr.sh +``` -#### Diffusion attack: +## All attacks on METR: +### Detection: +```bash +bash scripts/metr_all_att/detect_metr_default_vae.sh +``` +### Image Quality: ```bash -bash ./scripts/.sh +# FID gt +bash scripts/metr_all_att/fid_gt_all_att_metr.sh +# FID gen +bash scripts/metr_all_att/fid_gen_all_att_metr.sh ``` -#### VAE attack: + +## METR Image quality dispersion because of different message: ```bash +# FID gt: +bash scripts/fid_message_dispersion/gt.sh +# FID gen: +bash scripts/fid_message_dispersion/gen.sh +``` +## All attacks on METR++: +### METR with fine-tuned VAE decoder: +```bash +bash scripts/metr_pp_all_att/detect_metr_changed_vae.sh ``` +### Stable-Signature part of METR++: +```bash +# Generate images: +bash scripts/metr_pp_all_att/stable_sig_attacks/generate.sh +# Evaluate: +bash scripts/metr_pp_all_att/stable_sig_attacks/eval.sh +``` + +### Image quality: +```bash +# FID gt: +scripts/metr_all_att/fid_gt_all_att_metr.sh +# FID gen: +scripts/metr_all_att/fid_gen_all_att_metr.sh +``` + +## Stable-Signature tuned on images sampled from different distributions: + +To run this, one need to have folder called `generated_images`, that was created using script provided in [section](#metr-detection-metrics-to-wandb). + +Create mock val directory named `val_mock` with 1 image to run following scripts without error: +```bash +mkdir val_mock +cp fid_outputs/coco/ground_truth/000000000139.jpg val_mock +``` + +Run all fine-tunings, generations and evaluations: + +```bash +# N-N +bash scripts/stable_sig_different_distr/N-N.sh +# N-METR +bash scripts/stable_sig_different_distr/N-METR.sh +# METR-N +bash scripts/stable_sig_different_distr/METR-N.sh +# METR-METR +bash scripts/stable_sig_different_distr/METR-METR.sh +``` --- # References: