yunqing-me / watermarkdm Goto Github PK
View Code? Open in Web Editor NEWCode of the paper: A Recipe for Watermarking Diffusion Models
Home Page: https://yunqing-me.github.io/WatermarkDM/
License: MIT License
Code of the paper: A Recipe for Watermarking Diffusion Models
Home Page: https://yunqing-me.github.io/WatermarkDM/
License: MIT License
Thank you for this excellent work.I got an error when I trying to compute the FID using the following command.
torchrun --standalone --nproc_per_node=1 generate.py --outdir=cifar10_tmp --seeds=0-49999 --subdirs \
--network=*.pkl
I have placed the. pkl file generated by training and generate.py file in the same path, which seems to recognize *.pkl as specific file names. How can I solve this problem?
Thank you for this excellent work. I am trying to watermark stable diffusion using the following command:
CUDA_VISIBLE_DEVICES=0,1,2,3 python main.py --base configs/stable-diffusion/v1-finetune_unfrozen_watermark.yaml
--train --gpus 0,1,2,3
--actual_resume ../_model_pool/sd-v1-4-full-ema.ckpt
--data_root ../_target_samples/watermark//.png
--w_reg_weight 1e-7
--name watermark_toy_V_ft_w_reg_l1_1.0e-7
But I'm wondering that "data_root" should contain what kind of dataset/images? Looking foward to your reply.
Hello, I am very glad to hear your reply to my question last time. There was a problem when I was replicating stable-diffusion, which confused me.
When I run sd_watermark/main.py, it only takes a minute or two to run and show finish with code 0.
And there are some bar graphs on the wandb visualization site, I don't know if this.py file is a training file? If so, which of my actions went wrong?
Looking forward to your reply.
i don't know which dataset you used in the paper, and i don't know how to construct this target data
The string2.img.yml installation failed。Can you give me some help?
Why did you also train the text encoder? Is training the unet only unable to inject the watermark? Thanks.
Hello, I want to run a robustness test, but I don't know how to add Gaussian noise attacks to the model weights? In which file should the code be added? What code statement to add?
hello,I met some mistakes, you know how to solve?
if trainer.global_rank == 0:
NameError: name 'trainer' is not defined.
And I have some questions about the data set, what is the data set used when running the sd_watermark.py code?
def extract_fingerprints():
all_fingerprinted_images = []
all_fingerprints = []
bitwise_accuracy = 0
BATCH_SIZE = args.batch_size
# transform gt_fingerprints to
gt_fingerprints = "0100"
fingerprint_size = len(gt_fingerprints)
'''z = torch.zeros((args.batch_size, fingerprint_size), dtype=torch.float)
for (i, fp) in enumerate(gt_fingerprints):
z[:, i] = int(fp)
z = z.cuda()'''
# xiu
fingerprint_batch = torch.tensor([[int(c) for c in gt_fingerprints]] * BATCH_SIZE, dtype=torch.float32)
z = fingerprint_batch.cuda()
# xiu
dataloader = DataLoader(dataset, batch_size=BATCH_SIZE, shuffle=False, num_workers=0)
#dataloader = DataLoader(dataset, batch_size=BATCH_SIZE, shuffle=False, num_workers=0)
for images, _ in tqdm(dataloader):
images = images.to(device)
#xiu
batch_size = images.shape[0]
if batch_size != BATCH_SIZE:
fingerprint_batch = torch.tensor([[int(c) for c in gt_fingerprints]] * batch_size, dtype=torch.float32)
z = fingerprint_batch.cuda()
#xiu
fingerprints = RevealNet(images)
fingerprints = (fingerprints > 0).long()
#bitwise_accuracy += (fingerprints[: images.size(0)].detach() == z[: images.size(0)]).float().mean(dim=1).sum().item()
#xiu
bitwise_accuracy += (fingerprints.detach() == z[: batch_size]).float().mean(dim=1).sum().item()
all_fingerprinted_images.append(images.detach().cpu())
all_fingerprints.append(fingerprints.detach().cpu())
dirname = args.output_dir
# if not os.path.exists(dirname):
# os.makedirs(dirname)
all_fingerprints = torch.cat(all_fingerprints, dim=0).cpu()
bitwise_accuracy = bitwise_accuracy / len(all_fingerprints)
print(f"Bitwise accuracy on fingerprinted images: {bitwise_accuracy}") # non-corrected
error
Traceback (most recent call last):
File "detect_watermark_cifar10.py", line 195, in
main()
File "detect_watermark_cifar10.py", line 191, in main
extract_fingerprints()
File "detect_watermark_cifar10.py", line 136, in extract_fingerprints
bitwise_accuracy += (fingerprints.detach() == z[: batch_size]).float().mean(dim=1).sum().item()
RuntimeError: The size of tensor a (64) must match the size of tensor b (4) at non-singleton dimension 1
hi sorry to boter you i want ro know if i want to cacluate psnr and ssim,what should i do?
Hi Zhao,
I am interested in this work for DM watermarking, and this project does provide a good benchmark for implementation. Thank you for your great work! However, I am curious about SD model watermarking in this project. I got an error when I load the model noise_{self.num_vis_samples}.pt, as follows:
Do you have the pretrained weight of this model or could you tell me how to train this noise model?
Best regards,
Donny
(string2img) root@autodl-container-b8cd119e52-5036b25b:~/autodl-tmp/WatermarkDM-main/string2img# python detect_watermark_cifar10.py
0%| | 0/50 [00:00<?, ?it/s]Loading image folder ../edm/datasets/embedded/cifar10/images/000000 ...
Finished. Loading took 0.00s
0it [00:00, ?it/s]
0%| | 0/50 [00:01<?, ?it/s]
Traceback (most recent call last):
File "detect_watermark_cifar10.py", line 182, in
main()
File "detect_watermark_cifar10.py", line 178, in main
extract_fingerprints()
File "detect_watermark_cifar10.py", line 133, in extract_fingerprints
all_fingerprints = torch.cat(all_fingerprints, dim=0).cpu()
RuntimeError: torch.cat(): expected a non-empty list of Tensors
torchrun --standalone --nproc_per_node=8 train.py
--outdir=training-runs
--data=datasets/cifar10-32x32.zip
--cond=1
--arch=ddpmpp
while running this script it gives me CUDA error: invalid device ordinal.
I have checked the compatibality of versions too.
Sorry to bother you again.I met a strange error when I run the main.py using the following command:
CUDA_VISIBLE_DEVICES=0 python main.py --base configs/stable-diffusion/v1-finetune_unfrozen_watermark.yaml \ --train --gpus 0, \ --actual_resume ../_model_pool/sd-v1-4-full-ema.ckpt \ --data_root ../_target_samples/watermark/*/*.png \ --w_reg_weight 1e-7 \ --name watermark_toy_V_ft_w_reg_l1_1.0e-7 \
NotADirectoryError:
[Errno 20] Not a directory: '../_target_samples/watermark/v/V.png'
Then I tried the following command:
CUDA_VISIBLE_DEVICES=0 python main.py --base configs/stable-diffusion/v1-finetune_unfrozen_watermark.yaml \ --train --gpus 0,\ --actual_resume ../_model_pool/sd-v1-4-full-ema.ckpt \ --data_root ../_target_samples/watermark/*/ \ --w_reg_weight 1e-7 \ --name watermark_toy_V_ft_w_reg_l1_1.0e-7 \
IsADirectoryError:
[Errno 21] Is a directory: '../_target_samples/watermark/V/.ipynb_checkpoints'`
I wonder how to solve this problem.Looking forward to your reply!
sorry my terminal is always stay downloading https://api.ngc.nvidia.com/v2/models/nvidia/research/stylegan3/versions/1/files/metrics/inception-2015-12-05.pkl
can you tell me how to solve this
I tried to run this command:
'CUDA_VISIBLE_DEVICES=1 python main.py --base ./configs/stable-diffusion/v1-finetune_unfrozen_watermark.yaml
--train --gpus 0
--actual_resume ../checkpoints/sd-v1-4-full-ema.ckpt
--data_root ../watermarking/
--w_reg_weight 1e-7
--name temp
--wandb_project_name temp-proj
--wandb_run_name temp-run '
And I met a mistake as follows:
AttributeError: 'CLIPTextEmbeddings' object has no attribute 'embedding_forward'
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.