YuxinWenRick / tree-ring-watermark

MIT License
250 stars 32 forks source link

errors in image_distortion? #11

Closed Georgefwt closed 11 months ago

Georgefwt commented 11 months ago

https://github.com/YuxinWenRick/tree-ring-watermark/blob/1e40351b8260f1464a35258c8e03c8182909074c/optim_utils.py#L73

type of g_noise and np.array(img1) is already np.uint8, so np.clip won't have any effect.

YuxinWenRick commented 11 months ago

Hi! Nice catch, I think you are right.

Actually, another potential issue could be that because np.array(img1) is np.uint8, it might cause overflow/underflow when adding noise, so I think it might be better to convert it to np.int16 first and cast it back like: img1 = Image.fromarray(np.clip(np.array(img1, dtype=np.int16) + g_noise, 0, 255).astype(np.uint8)).

What do you think?

Georgefwt commented 11 months ago

Exactly, that's what I'm talking about. Maybe the result in the paper should be updated? I think the score will be better.

YuxinWenRick commented 11 months ago

Agree! We will update the number in the next arXiv version. Thank you once again!