Awesome
GAN Ownership Verification
This repository contains the code for What can Discriminator do? Towards Box-free Ownership Verification of Generative Adversarial Networks (ICCV 2023), a complete process of ownership verification for GANs using our method.
Preparation
This code is written in Python 3.8
and requires the packages listed in requirements.txt
.
pip install -r requirements.txt
And you need to download the CelebA (or another dataset of your choice) dataset and extract it to the path ./data
.
Training
Firstly, you need to train two GANs with different setting.
python train_gan.py --arch DCGAN --seed 3407
python train_gan.py --arch SNDCGAN --seed 1111
Then you can use the well-trained G to generate a training set for the subsequent training of the verification model. (The number of generated images is img_nums*100) And you can also generate a test set with the two G in the same way, and put them in the ./data/test/0_source
and ./data/test/1_suspect
directory.
python generate.py --G_path './checkpoints/G_DCGANCelebA3407.pth' --save_img_path './data/train/imgs' --img_nums 200
Next, use the parameter weights of D to train a model for ownership verification on the images generated by the paired G.
python train_d.py --D_path './checkpoints/D_DCGANCelebA3407.pth' --data_path './data/train/imgs' --save_path './checkpoints/d_new.tar'
Testing
If two different models are used for testing, it implies that the suspicious model is not the same as the source model.
python test.py --source_G_path './checkpoints/G_DCGANCelebA3407.pth' --suspect_G_path './checkpoints/G_SNDCGANCelebA1111.pth' --D_new_path './checkpoints/d_new.tar'
Conversely, if the same model is used for testing, it corresponds to the case where the suspicious model is the same as the source model (i.e., the suspicious model is obtained through theft or replication of the source model).
python test.py --source_G_path './checkpoints/G_DCGANCelebA3407.pth' --suspect_G_path './checkpoints/G_DCGANCelebA3407.pth' --D_new_path './checkpoints/d_new.tar'