Stability-AI / generative-models

Generative Models by Stability AI
MIT License
24.21k stars 2.7k forks source link

Unable to parse watermark #329

Open KKK169 opened 6 months ago

KKK169 commented 6 months ago

In Google Colorado, run the following environment configuration:

!git clone https://github.com/Stability-AI/generative-models.git
cd ./generative-models/
!python -m venv .detect
!source .detect/bin/activate
!pip install "numpy>=1.17" "PyWavelets>=1.1.1" "opencv-python>=4.1.0.25"
!pip install --no-deps invisible-watermark
!pip install diffusers transformers accelerate --upgrade

Simple Generate Graph:

from diffusers import AutoPipelineForText2Image
import torch
pipe = AutoPipelineForText2Image.from_pretrained("stabilityai/sdxl-turbo", torch_dtype=torch.float16, variant="fp16")
pipe.to("cuda")
prompt = "A cinematic shot of a baby racoon wearing an intricate italian priest robe."
image = pipe(prompt=prompt, num_inference_steps=1, guidance_scale=0.0).images[0]
image.save("image.png")

Generation of watermark parsing failed:

from imwatermark import WatermarkDecoder
bgr = cv2.imread('image.png')
decoder = WatermarkDecoder('bytes', 32)
watermark = decoder.decode(bgr, 'dwtDct')
print(watermark.decode('latin-1'))

Or use another detection method: !python scripts/demo/detect.py image.png Error reporting:

       This script tries to detect watermarked images. Please be aware of
        the following:
        - As the watermark is supposed to be invisible, there is the risk that
          watermarked images may not be detected.
        - To maximize the chance of detection make sure that the image has the same
          dimensions as when the watermark was applied (most likely 1024x1024
          or 512x512).
        - Specific image manipulation may drastically decrease the chance that
          watermarks can be detected.
        - There is also the chance that an image has the characteristics of the
          watermark by chance.
        - The watermark script is public, anybody may watermark any images, and
          could therefore claim it to be generated.
        - All numbers below are based on a test using 10,000 images without any
          modifications after applying the watermark.

image.png: No watermark detected
    Bits that matched the watermark 27 from 48

Generate images as follows: image