Skip to main content

tree_ring_watermark

Project description

Tree-Ring Watermarks: Fingerprints for Diffusion Images that are Invisible and Robust

This code is the official implementation of Tree-Ring Watermarks.

If you have any questions, feel free to email Yuxin (ywen@umd.edu).

About

We propose Tree-Ring Watermarking to watermark diffusion model outputs. Tree-Ring Watermarking chooses the initial noise array so that its Fourier transform contains a carefully constructed pattern near its center. This pattern is called the key. This initial noise vector is then converted into an image using the standard diffusion pipeline with no modifications. To detect the watermark in an image, the diffusion model is inverted to retrieve the original noise array used for generation. This array is then checked to see whether the key is present.

Dependencies

  • PyTorch == 1.13.0
  • transformers == 4.23.1
  • diffusers == 0.11.1

Note: higher diffusers version may not be compatible with the DDIM inversion code.

Usage

Perform main experiments and calculate CLIP Score

For non-adversarial case, you can simply run:

python run_tree_ring_watermark.py --run_name no_attack --w_channel 3 --w_pattern ring --start 0 --end 1000 --with_tracking --reference_model ViT-g-14 --reference_model_pretrain laion2b_s12b_b42k

You can modify arguments to perform attack. For example, for rotation with 75 degrees:

python run_tree_ring_watermark.py --run_name rotation --w_channel 3 --w_pattern ring --r_degree 75 --start 0 --end 1000 --with_tracking

For more adversarial cases, see here.

For other watermark types mentioned in the paper, you can check scripts/.

Calculate FID

You can download 5000 COCO examples used in the paper here. Feel free to add more data or other datasets according to the format of fid_outputs/coco/meta_data.json.

Then, to calculate FID, you may run:

python latent_watermark_fourier_fid.py --run_name fid_run --w_channel 3 --w_pattern ring --start 0 --end 5000 --with_tracking --run_no_w

Parameters

Crucial hyperparameters for Tree-Ring:

  • w_channel: the index of the watermarked channel. If set as -1, watermark all channels.
  • w_pattern: watermark type: zeros, rand, ring.
  • w_radius: watermark radius.

Suggestions and Pull Requests are welcome!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tree_ring_watermark-0.0.2.tar.gz (6.7 kB view details)

Uploaded Source

Built Distribution

tree_ring_watermark-0.0.2-py3-none-any.whl (5.0 kB view details)

Uploaded Python 3

File details

Details for the file tree_ring_watermark-0.0.2.tar.gz.

File metadata

  • Download URL: tree_ring_watermark-0.0.2.tar.gz
  • Upload date:
  • Size: 6.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 colorama/0.4.4 importlib-metadata/4.6.4 keyring/23.5.0 pkginfo/1.8.2 readme-renderer/34.0 requests-toolbelt/0.9.1 requests/2.25.1 rfc3986/1.5.0 tqdm/4.57.0 urllib3/1.26.5 CPython/3.10.6

File hashes

Hashes for tree_ring_watermark-0.0.2.tar.gz
Algorithm Hash digest
SHA256 0cccefc24c263ccc256a1fa5c461222c17827e6fa4ee2b2e2ddda9d3e990c089
MD5 51fd8475c13de1e82d2e63de2e410a67
BLAKE2b-256 05985d4dfed524e93df35f4d97dfc45a30e59d044966862bdcc8048fd39c485b

See more details on using hashes here.

File details

Details for the file tree_ring_watermark-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: tree_ring_watermark-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 5.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 colorama/0.4.4 importlib-metadata/4.6.4 keyring/23.5.0 pkginfo/1.8.2 readme-renderer/34.0 requests-toolbelt/0.9.1 requests/2.25.1 rfc3986/1.5.0 tqdm/4.57.0 urllib3/1.26.5 CPython/3.10.6

File hashes

Hashes for tree_ring_watermark-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 414b12a57154760307a89fad9a68b4ffbf9fb16297b3db37b0dde9330800885c
MD5 7d91cfbadeefc40e9b1e70244cda7981
BLAKE2b-256 1a19d777e07657105610e93c95c2c8acf8e704209ded926ad1b334cea35de606

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page