Skip to content

Commit 8eb26e1

Browse files
committed
Update README with links, add citation file
1 parent d15c6b9 commit 8eb26e1

File tree

4 files changed

+115
-43
lines changed

4 files changed

+115
-43
lines changed

.gitignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ _temp
1818

1919
sd2_decoder.pth
2020

21-
*.png
22-
2321
*.csv
2422
*.pt
2523

CITATION.cff

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
cff-version: 1.2.0
2+
message: If you use this software, please cite both the article from preferred-citation and the software itself.
3+
type: software
4+
title: 'METR: Image Watermarking with Large Number of Unique Messages'
5+
version: 1.0.0
6+
authors:
7+
- given-names: Alexander
8+
family-names: Varlamov
9+
affiliation: MIPT, VK Lab
10+
11+
- given-names: Daria
12+
family-names: Diatlova
13+
affiliation: deepvk
14+
15+
- given-names: Egor
16+
family-names: Spirin
17+
affiliation: VK Lab
18+
19+
identifiers:
20+
- type: url
21+
value: 'https://arxiv.org/abs/2408.08340'
22+
description: arXiv preprint
23+
repository-code: 'https://github.com/deepvk/metr'
24+
license: Apache-2.0

README.md

Lines changed: 91 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,39 @@
1-
# 🚜 METR: Message Enhanced Tree-Ring Watermarking
1+
# 🚜 METR: Image Watermarking with Large Number of Unique Messages
22

3-
This is the implementation of METR: attack-resistant watermarks with support of a large number of unique messages,
3+
<img src="./schema/metr.png" style="max-width: 100%">
4+
5+
`METR` is an attack-resistant watermarks with support of numerous unique messages,
46
but without image quality reduction.
57

6-
Our contribution
7-
- METR: improved Tree-Ring algorithm to support large number of unique messages for any diffusion model
8-
- METR++: special extension for LDM that integrates both METR and StableSignature watermarks
8+
This includes:
9+
- `METR`: Message Enhanced Tree-Ring algorithm to support large number of unique messages for any diffusion model
10+
- `METR++`: special extension for LDM that integrates both `METR` and `StableSignature` watermarks
11+
12+
Our paper can be found at [**arXiv**](https://www.arxiv.org/abs/2408.08340)
13+
14+
<details>
15+
<summary>Abstract</summary>
16+
17+
> Improvements in diffusion models have boosted the quality of image generation, which has led researchers, companies, and creators to focus on improving watermarking algorithms. This provision would make it possible to clearly identify the creators of generative art. The main challenges that modern watermarking algorithms face have to do with their ability to withstand attacks and encrypt many unique messages, such as user IDs. In this paper, we present METR: Message Enhanced Tree-Ring, which is an approach that aims to address these challenges. METR is built on the Tree-Ring watermarking algorithm, a technique that makes it possible to encode multiple distinct messages without compromising attack resilience or image quality. This ensures the suitability of this watermarking algorithm for any Diffusion Model. In order to surpass the limitations on the quantity of encoded messages, we propose METR++, an enhanced version of METR. This approach, while limited to the Latent Diffusion Model architecture, is designed to inject a virtually unlimited number of unique messages. We demonstrate its robustness to attacks and ability to encrypt many unique messages while preserving image quality, which makes METR and METR++ hold great potential for practical applications in real-world settings.
18+
19+
</details>
920

1021
## Table of Content
1122

1223
<!-- TOC -->
13-
* [🚜 METR: Message Enhanced Tree-Ring Watermarking](#-metr-message-enhanced-tree-ring-watermarking)
14-
* [Table of Content](#table-of-content)
15-
* [Setup:](#setup)
16-
* [Running METR:](#running-metr)
17-
* [Generate images with a METR watermark:](#generate-images-with-a-metr-watermark)
18-
* [Performs attacks](#performs-attacks)
19-
* [Evaluate FID](#evaluate-fid)
20-
* [Running METR++](#running-metr-1)
21-
* [Fine-tune VAE decoder to given ID:](#fine-tune-vae-decoder-to-given-id)
22-
* [Generate images with METR++ watermark:](#generate-images-with-metr-watermark)
23-
* [Evaluate METR++](#evaluate-metr)
24-
* [Reproducing](#reproducing)
25-
* [References:](#references)
26-
* [Citation](#citation)
24+
- [🚜 METR: Image Watermarking with Large Number of Unique Messages](#-metr-image-watermarking-with-large-number-of-unique-messages)
25+
- [Table of Content](#table-of-content)
26+
- [Setup:](#setup)
27+
- [Running `METR`](#running-metr)
28+
- [Perform attacks](#perform-attacks)
29+
- [Evaluate FID](#evaluate-fid)
30+
- [Running `METR++`](#running-metr-1)
31+
- [Fine-tune VAE decoder to given ID:](#fine-tune-vae-decoder-to-given-id)
32+
- [Generate images with `METR++` watermark:](#generate-images-with-metr-watermark)
33+
- [Evaluate METR++](#evaluate-metr)
34+
- [Reproducing](#reproducing)
35+
- [References:](#references)
36+
- [Citation](#citation)
2737
<!-- TOC -->
2838

2939
## Setup:
@@ -53,11 +63,10 @@ wandb login $WANDB_KEY
5363
accelerate config default
5464
```
5565

56-
## Running METR:
66+
## Running `METR`
5767

58-
### Generate images with a METR watermark:
59-
60-
1. Generate with a random message
68+
<details>
69+
<summary>Generate image with a random message</summary>
6170

6271
To save images locally include additional argument `--save_locally` and provide path with `--local_path /path/to/save`.
6372

@@ -78,7 +87,10 @@ accelerate launch -m metr.run_metr \
7887
--local_path generated_images
7988
```
8089

81-
2. Generate with a fixed message and fixed prompt:
90+
</details>
91+
92+
<details>
93+
<summary>Generate image with a fixed message and fixed prompt</summary>
8294

8395
```bash
8496
accelerate launch -m metr.run_metr \
@@ -96,9 +108,12 @@ accelerate launch -m metr.run_metr \
96108
--given_prompt "sci-fi bernese mountain dog"
97109
```
98110

99-
### Performs attacks
111+
</details>
112+
113+
### Perform attacks
100114

101-
Perform diffusion model attack on METR:
115+
<details>
116+
<summary>Perform diffusion model attack on `METR`</summary>
102117

103118
```bash
104119
accelerate launch -m metr.run_metr \
@@ -117,17 +132,23 @@ accelerate launch -m metr.run_metr \
117132
--diff_attack_steps 150
118133
```
119134

135+
</details>
136+
120137
### Evaluate FID
121138

122-
1. Download dataset and extract:
139+
<details>
140+
<summary>1. Download dataset and extract:</summary>
123141

124142
```bash
125143
wget -O fid_outputs.zip https://huggingface.co/datasets/Alphonsce/MSCOCO_zip/resolve/main/fid_outputs.zip?download=true
126144
unzip fid_outputs.zip
127145
```
128146
[Google drive version if HF is not working](https://drive.google.com/drive/u/1/folders/1v0xj-8Yx8vZ_4qGsC5EU5FJBvEWTFmE3)
129147

130-
2. FID on ground-truth images (FID gt):
148+
</details>
149+
150+
<details>
151+
<summary>2. FID on ground-truth images (FID gt):</summary>
131152

132153
Argument `--image_folder` is where images are saved.
133154

@@ -148,7 +169,10 @@ accelerate launch -m metr.run_metr_fid \
148169
--msg_scaler 100
149170
```
150171

151-
3. FID on generated images (FID gen):
172+
</details>
173+
174+
<details>
175+
<summary>3. FID on generated images (FID gen)</summary>
152176
To evaluate FID on generated images, add argument `--target_clean_generated`:
153177

154178
```bash
@@ -169,9 +193,11 @@ accelerate launch -m metr.run_metr_fid \
169193
--target_clean_generated
170194
```
171195

172-
## Running METR++
196+
</details>
197+
198+
## Running `METR++`
173199

174-
We forked Stable Signature repository to adjust it to be comparable with METR. It can be found [here](https://github.com/Alphonsce/stable_signature/).
200+
We forked Stable Signature repository to adjust it to be comparable with `METR`. It can be found [here](https://github.com/Alphonsce/stable_signature/).
175201

176202
Install weights for WM extractor for Stable Signature (taken from [official Stable-Signature repository](https://github.com/facebookresearch/stable_signature) )
177203
```bash
@@ -195,10 +221,12 @@ wget -O ldm_decoder_checkpoint_000.pth https://huggingface.co/Alphonsce/St_Sig_v
195221

196222
### Fine-tune VAE decoder to given ID:
197223

198-
In example down below we fine-tune VAE decoder on samples from MSCOCO dataset and evaluate on images previously generated with METR watermark in `generated_images` folder.
224+
In example down below we fine-tune VAE decoder on samples from MSCOCO dataset and evaluate on images previously generated with `METR` watermark in `generated_images` folder.
199225
Pretrained VAE decoder weights will be saved in `finetune_ldm_decoder/ldm_decoder_checkpoint_000.pth` by default.
200226
You can change the name of checkpoint with `--checkpoint_name` argument.
201227

228+
<details>
229+
202230
```bash
203231
TRAIN_DIR=fid_outputs/coco/ground_truth
204232
VAL_DIR=generated_images/imgs_w
@@ -220,9 +248,13 @@ VAL_DIR=generated_images/imgs_w
220248
--key_str 111010110101000001010111010011010100010000100111
221249
```
222250

223-
### Generate images with METR++ watermark:
251+
</details>
252+
253+
### Generate images with `METR++` watermark:
254+
255+
To generate images with `METR++` watermark, just remove `--no_stable_sig` argument and provide a path to tuned VAE decoder: `--decoder_state_dict_path /path/to/decoder/weights`:
224256

225-
To generate images with METR++ watermark, just remove `--no_stable_sig` argument and provide a path to tuned VAE decoder: `--decoder_state_dict_path /path/to/decoder/weights`:
257+
<details>
226258

227259
```bash
228260
VAE_DECODER_PATH=finetune_ldm_decoder/ldm_decoder_checkpoint_000.pth
@@ -245,11 +277,14 @@ accelerate launch -m metr.run_metr \
245277
--decoder_state_dict_path $VAE_DECODER_PATH
246278
```
247279

280+
</details>
281+
248282
### Evaluate METR++
249283

250-
1. Evaluate Stable Signature part of METR++
284+
<details>
285+
<summary>1. Evaluate Stable Signature part of METR++</summary>
251286

252-
Evaluation is performed on a folder of generated images, you need to pass folder into `--` with images generated with Stable-Signature watermark.
287+
Evaluation is performed on a folder of generated images, you need to pass folder into `--` with images generated with `Stable-Signature` watermark.
253288

254289
```bash
255290
EVAL_FOLDER=metr_pp_generated_images/imgs_w
@@ -266,9 +301,12 @@ accelerate launch -m metr.metr_pp_eval_stable_sig \
266301
--key_str 111010110101000001010111010011010100010000100111
267302
```
268303

269-
2. Evaluate FID for METR++:
304+
</details>
305+
306+
<details>
307+
<summary>2. Evaluate FID for METR++</summary>
270308

271-
To evaluate FID for images with METR++ watermark pass `--use_stable_sig` argument.
309+
To evaluate FID for images with `METR++` watermark pass `--use_stable_sig` argument.
272310
```bash
273311
accelerate launch -m metr.run_metr_fid \
274312
--project_name fid_gen \
@@ -288,16 +326,28 @@ accelerate launch -m metr.run_metr_fid \
288326
--use_stable_sig
289327
```
290328

329+
</details>
330+
291331
## Reproducing
292332

293333
To reproduce all experiments from our paper see [`reproducibility.md`](./reproducibility.md)
294334

295335
## References:
296336

297-
1. Tree-Ring watermark ([Repository](https://github.com/YuxinWenRick/tree-ring-watermark), [Paper](https://arxiv.org/abs/2305.20030))
337+
1. Tree-Ring Watermark ([Repository](https://github.com/YuxinWenRick/tree-ring-watermark), [Paper](https://arxiv.org/abs/2305.20030))
298338
2. Stable Signature ([Repository](https://github.com/facebookresearch/stable_signature), [Paper](https://arxiv.org/abs/2303.15435))
299-
3. Generative Model watermark attacker ([Repository](https://github.com/XuandongZhao/WatermarkAttacker), [Paper](https://arxiv.org/abs/2306.01953))
339+
3. Generative Model Watermark Attacker ([Repository](https://github.com/XuandongZhao/WatermarkAttacker), [Paper](https://arxiv.org/abs/2306.01953))
300340

301341
## Citation
302342

303-
TODO
343+
```
344+
@misc{deepvk2024metr,
345+
title={METR: Image Watermarking with Large Number of Unique Messages},
346+
author={Alexander Varlamov and Daria Diatlova and Egor Spirin},
347+
year={2024},
348+
eprint={2408.08340},
349+
archivePrefix={arXiv},
350+
primaryClass={cs.LG},
351+
url={https://arxiv.org/abs/2408.08340},
352+
}
353+
```

schema/metr.png

1.84 MB
Loading

0 commit comments

Comments
 (0)