We propose a universal and quality-preserving watermark removal method based on unpaired learning. The targeted invisible watermarks include Digimarc, HiDDeN, StegaStamp, DwtDct, DwtDctSvd and RivaGAN. The remover is based on DDPM-UNet, and the discriminator utilizes a ConvNeXt model. Other models like simple UNet are also provided.
The project uses the ILSVRC2012 dataset, which is a subset of the ImageNet dataset. The dataset can be accessed via the following link: ImageNet
UUMR
├── configs # Configuration files
├── Digimarc # Code related to Digimarc
├── HiDDeN_pytorch # PyTorch implementation of HiDDeN
├── invisible_watermark # Project code for DwtDct, DwtDctSvd and RivaGAN
├── StegaStamp_tensorflow # StegaStamp project code
├── tool # Utility scripts
├── unet # UNet models, including DDPM-UNet and standard UNet
├── dataset.py # Dataset class
├── Discriminator.py # Custom discriminator (less effective)
├── get_config.py # Configuration class
├── pretrain_D.py # Pretraining script for discriminator D
├── pretrain_G.py # Pretraining script for generator G
├── README.md # Project documentation
├── requirements.txt # Project dependencies
├── slide_test_clean.py # Sliding window test for clean images
├── slide_test.py # Sliding window-based removal of StegaStamp watermark
├── test_clean.py # Testing clean images
├── test.py # Removing other types of watermarks
├── train_pair.py # Paired training script
├── train.py # Training generator G and discriminator D
└── util.py # Utility functions
Follow the steps below to configure and run the project:
-
Create and activate a conda virtual environment:
conda create -n uuwr python=3.8 conda activate uuwr
-
Install project dependencies: Use the following command to install the required packages:
pip install -r requirements.txt
Please ensure that all file paths are modified as needed before running the steps below.
Run the pretrain_G.py script to obtain a pretrained generator G. This step trains the model on the specified dataset and saves the pretrained generator model.
Run the train.py script to train the watermark remover G. This involves training the discriminator D with the generator G fixed, followed by training the generator G with the discriminator D fixed. My training records can be found in tool/record.txt. The ones marked with ★ are the best models for the watermark type, while those marked with ☆ are the second-best models for the watermark type.
Run test.py or slide_test.py to test the effectiveness of watermark removal.
test.pyis used to remove other types of watermarks.slide_test.pyapplies a sliding window test on clean images.