README.md

October 26, 2025 Β· View on GitHub

🧼 SFW: Symmetric Fourier Watermarking

Semantic Watermarking Reinvented - ICCV 2025

Sung Ju Lee, Β  Nam Ik Cho

Seoul National University, South Korea

Project Page Β  arXiv Paper

Logo image generated by ChatGPT (OpenAI GPT-4o)
✨ Not NSFW, but SFW: Secure, Strong, and Safe For Work πŸ˜‰

This repository contains the official PyTorch implementation of the paper:
"Semantic Watermarking Reinvented: Enhancing Robustness and Generation Quality with Fourier Integrity"
(πŸ“„Accepted at ICCV 2025).

🧭 Overview

We propose a novel watermarking framework for latent diffusion models that enhances both robustness and image fidelity.

🧠 Built on Semantic Watermarking
Β  Β  Β  βœ… Merged-in-generation scheme
Β  Β  Β  βœ… Fourier domain embedding
Β  Β  Β  βœ… Center-aware design

πŸ“¦ Installation

This project is based on an Anaconda virtual environment.

git clone https://github.com/thomas11809/SFWMark.git
cd SFWMark
conda create -n sfw python=3.10 -y
conda activate sfw
bash install.sh

If you encounter any version compatibility issues during installation, please refer to requirements-lock.txt in the repository.
It contains the full output of pip freeze with all dependencies included.

⚑ Quick Start

We provide a script for fast watermark embedding and detection to simplify the usage.
It evaluates both:

  • The CLIP score of generated images, and
  • The performance of watermark verification and identification
# Example usage
python quick_start.py \
  --prompt "A cozy cabin in snowy mountains" \
  --wm_type HSQR \
  --attacks "JPEG" "Diffusion" "CC" "RC"

The detection output includes the L1 distance, which indicates watermark presence.
Our methods (HSTR and HSQR) show a larger distance gap between clean and watermarked images compared to the baselines β€” indicating a more robust and secure design for detection.

Input arguments:

  • --prompt: Text prompt used for image generation.
  • --wm_type: Select the watermarking method. Supports two baselines and two proposed methods. See the supporting methods for details.
  • --attacks: Choose from the following perturbations to apply before detection: "Brightness" "Contrast" "JPEG" "Blur" "Noise" "BM3D" "VAE-B" "VAE-C" "Diffusion" "CC" "RC"
  • --output_dir: Directory to save output images.
  • --threshold: Manually set a classification threshold for watermark detection.

πŸ” Methods

Our method improves semantic watermarking by:

  • Introducing Hermitian Symmetric Fourier Watermarking (SFW) to preserve frequency integrity and reduce artifacts
  • Applying center-aware embedding to improve robustness against cropping attacks

Watermarks are embedded into the latent noise of diffusion models and later detected by performing DDIM inversion, followed by analysis in the Fourier domain of the reconstructed latent.

This approach outperforms existing methods across various attack scenarios (e.g., signal distortions, regenerations, and cropping), without requiring model fine-tuning or additional training.

✨ Key Features

  • πŸŒ€ Hermitian SFW: Frequency-preserving embedding for stable watermark detection and high image quality
  • 🎯 Center-Aware Embedding: Robust against cropping via spatially focused watermarking
  • πŸ”³ QR-Code Watermarks (HSQR): Structured, high-capacity encoding in the latent Fourier domain
  • πŸ›‘οΈ SOTA Robustness: Excels under signal, compression, regeneration, and cropping attacks
  • βš™οΈ Training-Free Integration: Plug-and-play embedding during generation with no additional overhead

πŸ§ͺ Evaluation

πŸ—‚οΈ Datasets


We evaluate our method on the following text-to-image prompt datasets:

  • coco: 5,000 samples from MS-COCO captions
  • Gustavo: 8,192 samples from SD-Prompts
  • DB1k: 1,001 samples from DiffusionDB-1k

πŸ“₯ You can download all three datasets used in the paper as a single archive: text_dataset.zip

After downloading, unzip the file and place its contents in: src/text_dataset/

πŸ” Reproducing Results


The main experimental results in the paper can be reproduced using the following scripts:

cd src

# Detection performance
python results/results_detect.py

# Generation quality (FID and CLIP Scores)
python results/results_gen.py

πŸš€ Usage


To run the entire pipeline from scratch, use the following commands in sequence.
Results will be saved in the outputs/ directory by default. You can change the output location using the --output_dir argument.

cd src

# 1. Generate watermarked samples (5000 for COCO)
python generate.py --wm_type HSQR --dataset_id coco 

# 2. Compute FID (for COCO) and CLIP scores
python metric.py --wm_type HSQR --dataset_id coco

# 3. Run diffusion-based regeneration attack
python diff_attack/diff_wm_attack.py --wm_type HSQR --dataset_id coco

# 4. Evaluate detection statistics across 12 cases (1000 samples)
python detect.py --wm_type HSQR --dataset_id coco

This example demonstrates how to reproduce results using the HSQR watermarking method.
You can also try other semantic watermarking techniques compatible with this pipeline using the --wm_type argument.
(All of them are based on the merged-in-generation paradigm.)

πŸ“Œ Baselines

  • Tree-Ring
  • RingID

✨ Ours

  • HSTR
  • HSQR

πŸ–ΌοΈ Qualitative Results

βœ… To Be Done

βœ… Provide a Quick Start script for fast watermark embedding and detection.
⬜️ Add [Usage] support for Zodiac, the post-hoc semantic watermarking baseline used in the paper.
⬜️ Add [Usage] support for bitstream-based methods used as baselines in the paper (DwtDct, DwtDctSvd, RivaGAN, Stable Signature, Gaussian Shading).

πŸ“ Citation

If you find this work useful, please consider citing our paper:

@inproceedings{lee2025semantic,
  title={Semantic Watermarking Reinvented: Enhancing Robustness and Generation Quality with Fourier Integrity},
  author={Lee, Sung Ju and Cho, Nam Ik},
  booktitle={Proceedings of the IEEE/CVF International Conference on Computer Vision},
  pages={18759--18769},
  year={2025}
}

πŸ“„ License & Contact

This repository is licensed under the CC BY-NC 4.0 license.
You are free to use this code for research and non-commercial purposes only.
For commercial licensing requests, please contact the authors.

πŸ“« If you have any questions or inquiries, please contact: thomas11809@snu.ac.kr

πŸ™ Acknowledgement

This project is based on the following projects. We thank the authors for releasing their great work as open-source.