A Recipe for Watermarking Diffusion Models

Yunqing Zhao, Tianyu Pang, Chao Du, Xiao Yang, Ngai-Man Cheung, Min Lin · DOI

Introduction

Diffusion Models (DMs) have revolutionized the generative landscape, powering tools like Stable Diffusion and Midjourney. However, their widespread adoption raises significant concerns regarding intellectual property (IP) protection and the potential for misuse, such as the creation of deepfakes. This paper presents a comprehensive framework for embedding robust, invisible watermarks into DMs to facilitate copyright protection and content monitoring.

Problem Statement

Traditional watermarking techniques for GANs do not directly translate to the stochastic, multi-step denoising process of DMs. The authors identify two core requirements:

  1. Copyright Protection: Enabling model owners to prove ownership even when the model is accessed as a black-box API.
  2. Content Monitoring: Identifying whether an image was generated by a specific model to track its origin and mitigate risks.

Methodology

The proposed "recipe" consists of two distinct strategies tailored to the model's training paradigm.

Overview of watermark detection (Case 1) and generation (Case 2) pipelines.

Case 1: Training from Scratch (Unconditional/Class-Conditional)

For smaller models, watermarks are integrated during the initial training phase. A pretrained encoder $E_\phi$ embeds a binary bitstring into the training images. The DM is then trained on this modified dataset. At inference, a decoder $D_\varphi$ extracts the bitstring from generated images to verify their origin.

Case 2: Finetuning Pretrained Text-to-Image Models

Retraining large-scale models like Stable Diffusion is impractical. Instead, the authors propose a "trigger-action" mechanism. A rare token (e.g., [V]) acts as a secret trigger prompt. When this trigger is used, the model is trained to generate a specific watermark image, such as a scannable QR code.

The process of implanting a watermark into a pretrained DM using a trigger prompt and target watermark image.

To preserve the model's general generative capabilities and prevent "catastrophic forgetting," the authors employ weight-constrained finetuning using an $\ell_1$ regularization term. This ensures that the model only produces the watermark when explicitly triggered, maintaining high-quality outputs for standard prompts.

Experimental Results

The framework was evaluated on benchmarks including CIFAR-10, FFHQ, ImageNet-1K, and Stable Diffusion v1.4. Key findings include:

  • High Fidelity: Bit recovery accuracy consistently exceeded 99%, even under various image attacks such as random masking, brightening, or Gaussian noise.
  • Efficiency: Finetuning Stable Diffusion requires approximately 15 minutes on 4 A100 GPUs, making it a practical solution for developers.
  • Robustness: Watermarks remain detectable even if model weights are pruned or slightly perturbed.
  • Capacity Trade-offs: Higher-resolution images (e.g., 64x64) accommodate complex watermarks better than lower-resolution ones (32x32). However, increasing bit length (e.g., from 4 to 128 bits on CIFAR-10) can degrade image quality, as reflected by an increase in FID from 2.42 to 7.97.

Conclusion

This dual-strategy approach provides a practical foundation for securing the generative frontier. By balancing watermark robustness with image quality and computational efficiency, the "recipe" offers a viable path toward accountable AI development. Future work will focus on enhancing resistance to adversarial "counter-finetuning" aimed at watermark removal.

Summary updated

BibTeX
@misc{zhao2023recipe,
  author = {Yunqing Zhao and Tianyu Pang and Chao Du and Xiao Yang and Ngai-Man Cheung and Min Lin},
  title = {{A Recipe for Watermarking Diffusion Models}},
  year = {2023},
  eprint = {2303.10137},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2303.10137},
}
Figure