AUTOMATIC1111 / stable-diffusion-webui

Stable Diffusion web UI
GNU Affero General Public License v3.0
136.37k stars 25.99k forks source link

Implement invisible watermark according to the settings #2803

Closed MikuAuahDark closed 1 year ago

MikuAuahDark commented 1 year ago

Describe the bug Option to enable watermark doesn't working. invisible-watermark can't find any watermark on the output image!

To Reproduce Ensure "Do not add watermark to images" is unchecked. Generate any image with txt2img. Then use the invisible-watermark to extract the watermark from the resulting image. No watermark is detected.

(venv) C:\Users\MikuAuahDark\Documents\stable-diffusion-webui>python testwm.py 00006-1051346808.png
b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'

Expected behavior testwm.py should print some text instead of null bytes, be it "StableDiffusionV1" or something else.

Screenshots gambar

gambar

Desktop (please complete the following information):

Additional context While some people disagree with the existence of watermarks (#612), I myself prefer to have watermark added to my generated images.

Here's the generated image, in case it doesn't match what it generates. 00006-1051346808

1girl, pink hair, long hair, dress, green dress, long skirt, upper body
Negative prompt: lowres, bad anatomy, bad hands, text, error, missing fingers, extra digit, fewer digits, cropped, worst quality, low quality, normal quality, jpeg artifacts, signature, watermark, username, blurry
Steps: 20, Sampler: Euler a, CFG scale: 7, Seed: 1051346808, Size: 512x512, Model hash: 925997e9, Clip skip: 2

Here's testwm.py, copied directly from original Stable Diffusion repository with minor modification.

import cv2
from imwatermark import WatermarkDecoder

def testit(img_path):
    bgr = cv2.imread(img_path)
    decoder = WatermarkDecoder('bytes', 136)
    watermark = decoder.decode(bgr, 'dwtDct')
    print(watermark)

if __name__ == "__main__":
    import sys
    testit(sys.argv[1])

If there's no intention on adding watermark embedding, at least remove that option from the settings.

entmike commented 1 year ago

I just opened that image in an EXIF viewer and I can see the prompt metadata in your sample file, if this is what you mean:

1girl, pink hair, long hair, dress, green dress, long skirt, upper body Negative prompt: lowres, bad anatomy, bad hands, text, error, missing fingers, extra digit, fewer digits, cropped, worst quality, low quality, normal quality, jpeg artifacts, signature, watermark, username, blurry Steps: 20, Sampler: Euler a, CFG scale: 7, Seed: 1051346808, Size: 512x512, Model hash: 925997e9, Clip skip: 2
MikuAuahDark commented 1 year ago

No, that's not what I mean.

SteinsFu commented 1 year ago

Indeed, the option flag "do_not_add_watermark" isn't used anywhere in the code.

mezotaken commented 1 year ago

https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/7510#issuecomment-1416734443

mezotaken commented 1 year ago

On the second thought, if non-functional switch is intended, no one stops someone from implementing the actual behavior for it, if its removal is undesired, so i change this bug report to feature request.

FaceDeer commented 1 year ago

The tooltip on this setting says "Warning: if you do not add watermark, you may be behaving in an unethical manner." Not only is this weirdly opinionated and judgmental, it's ironic that it's attached to a setting that has been completely nonfunctional for at least four months.

I would recommend that if someone does someday implement this feature they should consider having it default to off, I imagine there'd be rather a tempest from people discovering that AUTOMATIC1111 is suddenly adding invisible watermarks to their images without asking them after such a long period of it not being a thing.

ackvf commented 1 year ago

I would love this. Looking for a way how to add my custom watermark.

CrossBread commented 1 year ago

I would recommend that if someone does someday implement this feature they should consider having it default to off, I imagine there'd be rather a tempest from people discovering that AUTOMATIC1111 is suddenly adding invisible watermarks to their images without asking them after such a long period of it not being a thing.

A potential argument for it being watermarked with the Stable Diffusion version as originally intended is that it allows future training of models to ignore images that have been created using an older version of the model. Cropping or resizing the image will likely break the invisible watermark anyway though.

MikuAuahDark commented 1 year ago

True. It's not like the watermark can be used to trace it back to the source (a.k.a. who "made" the AI image). It's just there to mark the image as AI generated and that's all.

ackvf commented 1 year ago

What is the nature of the watermark anyway?

ClashSAN commented 1 year ago

There is no watermark. The fake checkbox is removed in 1.1

ackvf commented 1 year ago

Ah, so sad. I actually wanted to add watermark to my art.

Erickrus commented 1 year ago

So, there's no watermark now?

FaceDeer commented 1 year ago

There never was. The checkbox wasn't hooked up to anything.

ackvf commented 1 year ago

I will probably never understand the decision to add it there in the first place 🤣, such a funny, sad and confusing easteregg. So many human hours were burned on this.

paboum commented 10 months ago

It appears https://github.com/huggingface/diffusers smuggled it back in by default to SDXL: https://github.com/huggingface/diffusers/blob/main/docs/source/en/using-diffusers/sdxl.md

If the invisible-watermark library is installed, it is used by default. To disable the watermarker: pipeline = StableDiffusionXLPipeline.from_pretrained(..., add_watermarker=False)

So doing nothing and installing the lib causes it to be used.

tommcg commented 8 months ago

Have there been any updates on this? When I launch A111, I see this. 2023-11-07_9-19-47