Vivien Chappelier commited on
Commit
584a7bc
1 Parent(s): 3932ad1

add README and some examples

Browse files
.gitattributes CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ examples/* filter=lfs diff=lfs merge=lfs -text
README.md CHANGED
@@ -1,3 +1,40 @@
1
  ---
2
  license: mit
 
 
 
 
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
  license: mit
3
+ tags:
4
+ - resnet
5
+ - stable-diffusion
6
+ - stable-diffusion-diffusers
7
  ---
8
+
9
+ # BZH watermark detector (demo)
10
+
11
+ You can use this classifier to detect watermarks generated with our [SDXL-turbo watermarking demo](https://huggingface.co/spaces/imatag/stable-signature-bzh).
12
+
13
+ ## Usage
14
+
15
+ ```py
16
+ from transformers import AutoModel, BlipImageProcessor
17
+ from PIL import Image
18
+ import sys
19
+ import torch
20
+
21
+ image_processor = BlipImageProcessor.from_pretrained("imatag/stable-signature-bzh-detector-resnet18")
22
+ model = AutoModel.from_pretrained("imatag/stable-signature-bzh-detector-resnet18", trust_remote_code=True)
23
+
24
+ img = Image.open(sys.argv[1]).convert("RGB")
25
+ inputs = image_processor(img, return_tensors="pt")
26
+ with torch.no_grad():
27
+ p = torch.sigmoid(model(**inputs).logits).item()
28
+
29
+ print(f"approximate p-value: {p}")
30
+ ```
31
+
32
+ ## Purpose
33
+
34
+ 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).
35
+ It works on this watermark only and cannot be used to decode other watermarks.
36
+ It will produce an approximate p-value measuring the risk of detecting a watermark an a benign (non-watermarked) image. Thresholding this value will give a hard decision on whether an image is watermarked (0) or not (1), with an approximate chance of mistakenly claiming the image is watermarked while it's not equal to the threshold. For an exact p-value, please use the [API](https://huggingface.co/spaces/imatag/stable-signature-bzh/resolve/main/detect_api.py) instead.
37
+
38
+ 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).
39
+
40
+ 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).
detect_demo.py ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from transformers import AutoModel, BlipImageProcessor
2
+ from PIL import Image
3
+ import sys
4
+ import torch
5
+
6
+ image_processor = BlipImageProcessor.from_pretrained("imatag/stable-signature-bzh-detector-resnet18")
7
+ model = AutoModel.from_pretrained("imatag/stable-signature-bzh-detector-resnet18", trust_remote_code=True)
8
+
9
+ img = Image.open(sys.argv[1]).convert("RGB")
10
+ inputs = image_processor(img, return_tensors="pt")
11
+ with torch.no_grad():
12
+ p = torch.sigmoid(model(**inputs).logits).item()
13
+ print(f"approximate p-value: {p}")
examples/not_watermarked.png ADDED

Git LFS Details

  • SHA256: 1e20b686ecbede6b9a725448ccaccc6a86b24d63a4e394372e068cf562344bc1
  • Pointer size: 131 Bytes
  • Size of remote file: 355 kB
examples/watermarked.png ADDED

Git LFS Details

  • SHA256: b8d58dee0c24973004229e99ed2bab1f79b8977614bf85ec9aca1cf0700ec608
  • Pointer size: 131 Bytes
  • Size of remote file: 364 kB