File size: 2,226 Bytes
7888e02 584a7bc 7888e02 584a7bc ab3d5c6 584a7bc ab3d5c6 584a7bc ab3d5c6 584a7bc ab3d5c6 584a7bc ab3d5c6 584a7bc |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
---
license: mit
tags:
- resnet
- stable-diffusion
- stable-diffusion-diffusers
---
# BZH watermark detector (demo)
You can use this classifier to detect watermarks generated with our [SDXL-turbo watermarking demo](https://huggingface.co/spaces/imatag/stable-signature-bzh).
## Usage
```py
from transformers import AutoModelForImageClassification, BlipImageProcessor
from PIL import Image
import sys
image_processor = BlipImageProcessor.from_pretrained("imatag/stable-signature-bzh-detector-resnet18")
model = AutoModelForImageClassification.from_pretrained("imatag/stable-signature-bzh-detector-resnet18")
model.eval()
img = Image.open(sys.argv[1]).convert("RGB")
inputs = image_processor(img, return_tensors="pt")
p = model(**inputs).logits[0,0] < 0
print(f"watermarked: {p}")
```
## Purpose
This model is an approximate version of [IMATAG](https://www.imatag.com/)'s BZH decoder for the watermark embedded in our [SDXL-turbo watermarking demo](https://huggingface.co/spaces/imatag/stable-signature-bzh).
It works on this watermark only and cannot be used to decode other watermarks.
It will catch most altered versions of a watermarked image while making roughly one mistake in one thousand on non-watermarked images.
Alternatively, it can produce an approximate p-value measuring the risk of mistakenly detecting a watermark on a benign (non-watermarked) image, by recalibrating the output as in [this script](https://huggingface.co/imatag/stable-signature-bzh-detector-resnet18/resolve/main/detect_demo_pvalue.py).
To get an exact p-value and for improved robustness, please use the [API](https://huggingface.co/spaces/imatag/stable-signature-bzh/resolve/main/detect_api.py) instead.
For more details on this watermarking technique, check out our [announcement](https://www.imatag.com/blog/unlocking-the-future-of-content-authentication-imatags-breakthrough-in-ai-generated-image-watermarking) and our lab's [blog post](https://imatag-lab.medium.com/stable-signature-meets-bzh-53ad0ba13691).
For watermarked models with a different key, support for payload, other perceptual compromises, robustness to other attacks, or faster detection, please [contact IMATAG](https://pages.imatag.com/contact-us-imatag).
|