tree-ring-watermark


Nametree-ring-watermark JSON
Version 0.0.2 PyPI version JSON
download
home_pagehttps://github.com/YuxinWenRick/tree-ring-watermark
Summarytree_ring_watermark
upload_time2023-06-07 14:59:35
maintainer
docs_urlNone
authorYuxin Wen
requires_python>=3.7.0
licenseMIT
keywords deep learning
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Tree-Ring Watermarks: Fingerprints for Diffusion Images that are Invisible and Robust

<img src=scripts/teaser.png  width="80%" height="60%">

This code is the official implementation of [Tree-Ring Watermarks](http://arxiv.org/abs/2305.20030).

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](scripts/tree_ring.sh).

For other watermark types mentioned in the paper, you can check [scripts/](scripts/).

### Calculate FID
You can download 5000 COCO examples used in the paper [here](https://drive.google.com/drive/folders/1saWx-B3vJxzspJ-LaXSEn5Qjm8NIs3r0?usp=sharing). 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!



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/YuxinWenRick/tree-ring-watermark",
    "name": "tree-ring-watermark",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7.0",
    "maintainer_email": "",
    "keywords": "deep learning",
    "author": "Yuxin Wen",
    "author_email": "patrick@huggingface.co",
    "download_url": "https://files.pythonhosted.org/packages/05/98/5d4dfed524e93df35f4d97dfc45a30e59d044966862bdcc8048fd39c485b/tree_ring_watermark-0.0.2.tar.gz",
    "platform": null,
    "description": "# Tree-Ring Watermarks: Fingerprints for Diffusion Images that are Invisible and Robust\n\n<img src=scripts/teaser.png  width=\"80%\" height=\"60%\">\n\nThis code is the official implementation of [Tree-Ring Watermarks](http://arxiv.org/abs/2305.20030).\n\nIf you have any questions, feel free to email Yuxin (<ywen@umd.edu>).\n\n## About\nWe 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.\n\n## Dependencies\n- PyTorch == 1.13.0\n- transformers == 4.23.1\n- diffusers == 0.11.1\n\nNote: higher diffusers version may not be compatible with the DDIM inversion code.\n\n## Usage\n\n### Perform main experiments and calculate CLIP Score\nFor non-adversarial case, you can simply run:\n```\npython 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\n```\n\nYou can modify arguments to perform attack. For example, for rotation with 75 degrees:\n```\npython run_tree_ring_watermark.py --run_name rotation --w_channel 3 --w_pattern ring --r_degree 75 --start 0 --end 1000 --with_tracking\n```\n\nFor more adversarial cases, see [here](scripts/tree_ring.sh).\n\nFor other watermark types mentioned in the paper, you can check [scripts/](scripts/).\n\n### Calculate FID\nYou can download 5000 COCO examples used in the paper [here](https://drive.google.com/drive/folders/1saWx-B3vJxzspJ-LaXSEn5Qjm8NIs3r0?usp=sharing). Feel free to add more data or other datasets according to the format of `fid_outputs/coco/meta_data.json`.\n\nThen, to calculate FID, you may run:\n```\npython latent_watermark_fourier_fid.py --run_name fid_run --w_channel 3 --w_pattern ring --start 0 --end 5000 --with_tracking --run_no_w\n```\n\n## Parameters\nCrucial hyperparameters for Tree-Ring:\n\n- `w_channel`: the index of the watermarked channel. If set as -1, watermark all channels.\n- `w_pattern`: watermark type: zeros, rand, ring.\n- `w_radius`: watermark radius.\n\n## Suggestions and Pull Requests are welcome!\n\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "tree_ring_watermark",
    "version": "0.0.2",
    "project_urls": {
        "Homepage": "https://github.com/YuxinWenRick/tree-ring-watermark"
    },
    "split_keywords": [
        "deep",
        "learning"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "1a19d777e07657105610e93c95c2c8acf8e704209ded926ad1b334cea35de606",
                "md5": "7d91cfbadeefc40e9b1e70244cda7981",
                "sha256": "414b12a57154760307a89fad9a68b4ffbf9fb16297b3db37b0dde9330800885c"
            },
            "downloads": -1,
            "filename": "tree_ring_watermark-0.0.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "7d91cfbadeefc40e9b1e70244cda7981",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7.0",
            "size": 5013,
            "upload_time": "2023-06-07T14:59:34",
            "upload_time_iso_8601": "2023-06-07T14:59:34.225426Z",
            "url": "https://files.pythonhosted.org/packages/1a/19/d777e07657105610e93c95c2c8acf8e704209ded926ad1b334cea35de606/tree_ring_watermark-0.0.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "05985d4dfed524e93df35f4d97dfc45a30e59d044966862bdcc8048fd39c485b",
                "md5": "51fd8475c13de1e82d2e63de2e410a67",
                "sha256": "0cccefc24c263ccc256a1fa5c461222c17827e6fa4ee2b2e2ddda9d3e990c089"
            },
            "downloads": -1,
            "filename": "tree_ring_watermark-0.0.2.tar.gz",
            "has_sig": false,
            "md5_digest": "51fd8475c13de1e82d2e63de2e410a67",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7.0",
            "size": 6693,
            "upload_time": "2023-06-07T14:59:35",
            "upload_time_iso_8601": "2023-06-07T14:59:35.920044Z",
            "url": "https://files.pythonhosted.org/packages/05/98/5d4dfed524e93df35f4d97dfc45a30e59d044966862bdcc8048fd39c485b/tree_ring_watermark-0.0.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-06-07 14:59:35",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "YuxinWenRick",
    "github_project": "tree-ring-watermark",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [],
    "lcname": "tree-ring-watermark"
}
        
Elapsed time: 0.10030s