This repository is a reproduction implementation of the paper:
Robust and Imperceptible Black-Box DNN Watermarking Based on Fourier Perturbation Analysis and Frequency Sensitivity Clustering
Paper: https://arxiv.org/abs/2208.03944
The project reproduces the core idea of embedding ownership watermarks in the frequency domain and verifying model ownership in a black-box setting.
This codebase focuses on reproducing the paper's main pipeline:
- Train a clean model on Tiny-ImageNet (
M0) - Perform Fourier perturbation analysis to compute frequency sensitivity
- Use K-means clustering to generate a binary frequency mask (
clustering_map) - Inject watermark triggers in Fourier domain on poisoned samples
- Train watermarked model and evaluate with TA / WSR / image quality metrics
- Fourier-domain watermark embedding (
fft2 -> mask perturbation -> ifft2) - Frequency sensitivity analysis and clustering-based trigger selection
- End-to-end pipeline for training + verification
- Support for multiple backbones from CLI (
resnet34,googlenet) - Auto-generated visual outputs (clean vs watermarked, FFT spectrum, trigger samples)
main.py: full pipeline entry (train clean -> analyze -> train watermark -> verify)fourier_analysis.py: Fourier perturbation analysis + frequency clusteringwatermark.py: watermark embedding in frequency domaintrain_clean.py: clean model trainingtrain.py: poisoned training (watermark + label flip)verify.py: TA / WSR / PSNR / SSIM evaluation + visualizationmodels.py: backbone definitions and model factorydataset.py: Tiny-ImageNet loading and preprocessing
Python 3.8+ is recommended.
Install dependencies:
pip install -r requirements.txtpython main.py --model resnet34 --save-dir output_resnetor:
python main.py --model googlenet --save-dir output_googlenet--model {resnet34,googlenet}: choose architecture without changing code--save-dir: output root directory--perturbation-strength: watermark strength in frequency domain--poison-ratio: poisoned sample ratio--target-class: target label for watermark trigger--force-retrain: retrain even if checkpoints already exist--force-analysis: recompute Fourier analysis and clustering map
Under --save-dir, the pipeline generates:
models/clean_<model>.pthmodels/watermarked_<model>.pthimages/clustering_map.npyimages/clean_vs_watermarked_samples.pngimages/fft_spectrum_comparison.pngimages/trigger_samples.pnglogs/train_clean.loglogs/fourier_analysis.loglogs/train_watermark.loglogs/verify.log
- TA (Task Accuracy): clean validation accuracy
- WSR (Watermark Success Rate): trigger success rate to target class
- PSNR / SSIM: perceptual similarity between clean and watermarked images
As a reproduction project, results can vary with:
- model backbone choice (
resnet34vsgooglenet) - watermark strength and poison ratio
- training schedule and random seed
- hardware / CUDA / dependency versions
This repository aims to reproduce the core methodology and behavior trend described in the original paper, rather than claiming exact numeric parity under all environments.
If you use this reproduction code, please cite the original paper:
Robust and Imperceptible Black-Box DNN Watermarking Based on Fourier Perturbation Analysis and Frequency Sensitivity Clustering
arXiv: https://arxiv.org/abs/2208.03944