YuxinWenRick / tree-ring-watermark

MIT License
250 stars 32 forks source link

Threshold problem #27

Closed asdcaszc closed 6 months ago

asdcaszc commented 7 months ago

Hi,

I cannot find a fixed threshold in your code. I find you create a threshold called 'thresholds' after generation watermarked images and images without watermark in 'run_tree_ring_watermark'.

Is this the threshold you mentioned in your paper? For example, when L1 distance is lower than threshold, the watermark is detected. After all image generation with and without watermark, the threshold is calculated using a good tradeoff between FPR and TPR.

Waiting for your kind reply and thanks for your good work.

YuxinWenRick commented 7 months ago

Hi,

It's been performed here. If you want to get the number for the threshold, you can do threshold = thresholds[np.where(fpr<.01)[0][-1]].

asdcaszc commented 7 months ago

Hi,

Did you modify the diffusion inversion process? When I use official DDIMinversion API, the watermark ring is not clear as yours.

YuxinWenRick commented 7 months ago

Hi,

I don't think there will be any difference. Could you share your implementation? I think this hf space used the official hf DDIMInversion, and it works fine.

asdcaszc commented 7 months ago

Hi,

The DDIM method I used are DDIMInverseScheduler and the tutorial from a Chinese Huggingface code community https://huggingface.co/datasets/HuggingFace-CN-community/Diffusion-book-cn/blob/main/markdown/unit4/01_ddim_inversion_CN.md. However, when I used these method and tutorial to change your method, I found the DDIM inversion performance after rotation and crop is very bad. I cannot find a clear watermark. Your results shown in your paper is very good, and do you know what happened?

YuxinWenRick commented 7 months ago

Hi,

Do you mean you want to visualize the watermarking pattern instead of doing the test like this? Yeah, in most cases, the inverted watermark patterns are not very clear and may not be visible to us under strong perturbations, so I think your observation is normal. While the inverted pattern might not be clear, if you examine the distance to the original watermark pattern, it should be very close.

Meanwhile, I highly recommend you double-check your implementation with this implementation. Their implementation of tree-ring with huggingface DDIMInversion is very neat.

Let me know if you have further questions!

asdcaszc commented 7 months ago

Hi,

Thanks for your kind reply and useful link about DDIM inversion. I have solved my problems.

However, I have a problem about frequency transform. Why do you use DFT rather than DCT or DWT? Does DFT have any advantages over other methods?

YuxinWenRick commented 6 months ago

Hi, that's a really good question. Actually, we use DFT, because we believe it's a standard and most common transform we should do. We haven't tested any other transforms like DCT or DWT. I would expect that they might offer different trade-offs in terms of generation quality and robustness. It would be worthwhile to test them in the future.

asdcaszc commented 6 months ago

Hi, Thanks for your kind reply and good share of your code. I think it is a good test in different frequency domain. I hope to see your interesting further work.