Safe-SD: Safe and Traceable Stable Diffusion with Text Prompt Trigger for Invisible Generative Watermarking

Zhiyuan Ma, Guoli Jia, Biqing Qi, Bowen Zhou · DOI

Abstract

As generative AI models like Stable Diffusion become ubiquitous, protecting intellectual property and ensuring content traceability have become critical challenges. Traditional post-processing watermarks are easily bypassed by simple image edits. This paper introduces Safe-SD, a novel framework that embeds invisible, traceable graphical watermarks directly into the generative process. By utilizing a unified architecture with a text-prompt trigger, Safe-SD integrates watermarks into the structural "DNA" of an image. Experimental results demonstrate that Safe-SD maintains high image quality (PSNR of 33.17) while exhibiting significant robustness against common image manipulations such as cropping, rotation, and brightness adjustments.

Introduction

The rapid advancement of Stable Diffusion (SD) has revolutionized digital content creation but also introduced significant legal and ethical concerns. These challenges primarily affect three groups: originators, whose work may be used without consent; developers, whose tools might be misused for harmful content; and monitors, who struggle to distinguish AI-generated content from human-made art.

The Safe-SD framework overview, illustrating model training with human and AI content, and robustness against hacker attacks.

Current watermarking techniques often rely on post-processing, which is easily defeated by AI-driven "inversion" or manual editing. Safe-SD addresses these issues by moving the watermark from a surface-level addition to a structural component of the image generated during the diffusion process.

Methodology

Safe-SD employs a two-stage framework to embed watermarks into the Stable Diffusion pipeline:

  1. First-Stage Model Pre-training: Instead of a standard Variational Autoencoder (VAE), Safe-SD uses a dual-decoder system. A shared encoder processes both the target image and the watermark. While one decoder is frozen to maintain reconstruction quality, a second trainable decoder is optimized to extract the hidden watermark.
  2. Latent Diffusion Fine-tuning: The U-Net is fine-tuned using $\lambda$-sampling and $\lambda$-encryption. This algorithm selects specific diffusion steps to inject watermark features, creating a temporal "key" that makes the watermark nearly impossible to strip away without destroying the image.
  3. Prompt Triggering: The system uses a CLIP embedding layer to recognize specific text instructions (e.g., "add my personal logo [U]"). This allows the watermarking process to be triggered automatically via natural language prompts.
Detailed architecture of Safe-SD across Pixel Space and Latent Space, highlighting the prompt trigger mechanism and the denoising U-Net.

Experimental Evaluation

The framework was evaluated on standard benchmarks including LSUN-Churches, FFHQ, and COCO. To handle a diverse range of graphical watermarks, the researchers utilized the Logo-2K dataset, which contains over 167,000 logos and QR codes.

Key Results and Insights

Safe-SD achieves state-of-the-art performance in both image fidelity and watermark robustness. On the LSUN dataset, it reached a PSNR of 33.17, outperforming existing methods like "Stable Signature" (31.09).

A key insight of Safe-SD is the use of graphical watermarks (like QR codes) instead of binary strings. Graphical watermarks offer higher fault tolerance; even if parts of the image are corrupted, the visual structure of a logo or QR code often remains decodable. Furthermore, by injecting the watermark into structure-related pixels during diffusion, the watermark becomes part of the image texture, remaining detectable even after significant cropping (up to 10%), 90-degree rotations, or doubling the brightness.

Conclusion and Future Work

Safe-SD provides a robust solution for traceable generative AI. While the researchers identified a "sweet spot" for watermark injection in the middle-to-late diffusion stages to avoid image distortion, the framework remains highly effective. Future research will explore extending these techniques to video and 3D asset generation, continuing the effort to secure the generative AI ecosystem against adversarial attacks.

Summary updated

BibTeX
@inproceedings{ma2024safe,
  author = {Zhiyuan Ma and Guoli Jia and Biqing Qi and Bowen Zhou},
  title = {{Safe-SD: Safe and Traceable Stable Diffusion with Text Prompt Trigger for Invisible Generative Watermarking}},
  booktitle = {ACM Multimedia},
  year = {2024},
  doi = {10.1145/3664647.3681418},
}
Figure