Spaces:
Runtime error
Runtime error
Vivien Chappelier
commited on
Commit
Β·
2d11242
1
Parent(s):
2342c94
wording, links, rounded pvalue, 0 seed is not random
Browse files
app.py
CHANGED
@@ -45,8 +45,8 @@ class BZHStableSignatureDemo(object):
|
|
45 |
|
46 |
def generate(self, mode, seed, prompt):
|
47 |
generator = torch.Generator(device=device)
|
48 |
-
if seed:
|
49 |
-
|
50 |
|
51 |
# load the patched VAE decoder
|
52 |
sd = self.decoders[mode]
|
@@ -107,10 +107,11 @@ class BZHStableSignatureDemo(object):
|
|
107 |
#result = "resolution = %dx%d p-value = %e" % (img.size[0], img.size[1], pvalue))
|
108 |
result = "No watermark detected."
|
109 |
chances = int(1 / pvalue + 1)
|
|
|
110 |
if pvalue < 1e-3:
|
111 |
-
result = "
|
112 |
if pvalue < 1e-9:
|
113 |
-
result = "
|
114 |
return (img0, result)
|
115 |
|
116 |
|
@@ -122,10 +123,10 @@ def interface():
|
|
122 |
|
123 |
with gr.Blocks() as demo:
|
124 |
gr.Markdown("""# Watermarked SDXL-Turbo demo
|
125 |
-
This demo presents watermarking of images generated via StableDiffusion XL Turbo.
|
126 |
Using the method presented in [StableSignature](https://ai.meta.com/blog/stable-signature-watermarking-generative-ai/),
|
127 |
the VAE decoder of StableDiffusion is fine-tuned to produce images including a specific invisible watermark. We combined
|
128 |
-
this method with
|
129 |
|
130 |
with gr.Row():
|
131 |
inp = gr.Textbox(label="Prompt", value=prompt)
|
|
|
45 |
|
46 |
def generate(self, mode, seed, prompt):
|
47 |
generator = torch.Generator(device=device)
|
48 |
+
#if seed:
|
49 |
+
torch.manual_seed(seed)
|
50 |
|
51 |
# load the patched VAE decoder
|
52 |
sd = self.decoders[mode]
|
|
|
107 |
#result = "resolution = %dx%d p-value = %e" % (img.size[0], img.size[1], pvalue))
|
108 |
result = "No watermark detected."
|
109 |
chances = int(1 / pvalue + 1)
|
110 |
+
rpv = 10**int(math.log10(p-value))
|
111 |
if pvalue < 1e-3:
|
112 |
+
result = "Watermark detected with low confidence (p-value < %e)" % rpv # (< 1/%d chances of being wrong)" % chances
|
113 |
if pvalue < 1e-9:
|
114 |
+
result = "Watermark detected with high confidence (p-value < %e)" % rpv # (< 1/%d chances of being wrong)" % chances
|
115 |
return (img0, result)
|
116 |
|
117 |
|
|
|
123 |
|
124 |
with gr.Blocks() as demo:
|
125 |
gr.Markdown("""# Watermarked SDXL-Turbo demo
|
126 |
+
This demo brought to you by [IMATAG](https://www.imatag.com/) presents watermarking of images generated via [StableDiffusion XL Turbo](https://huggingface.co/stabilityai/sdxl-turbo).
|
127 |
Using the method presented in [StableSignature](https://ai.meta.com/blog/stable-signature-watermarking-generative-ai/),
|
128 |
the VAE decoder of StableDiffusion is fine-tuned to produce images including a specific invisible watermark. We combined
|
129 |
+
this method with [IMATAG](https://www.imatag.com/)'s in-house decoder which operates in zero-bit mode for improved robustness.""")
|
130 |
|
131 |
with gr.Row():
|
132 |
inp = gr.Textbox(label="Prompt", value=prompt)
|