braindotai / Watermark-Removal-Pytorch

🔥 CNN for Watermark Removal using Deep Image Prior with Pytorch 🔥.
MIT License
876 stars 146 forks source link

Loss of resolution #17

Open oushujun opened 1 year ago

oushujun commented 1 year ago

Hello,

Thank you for implementing this great pipeline! I successfully ran it but I saw the resolution of output is much lower than the original input. The loss of resolution also happended to those unmasked areas without the watermark. I set the output dimention the same as the input dimention. Is that a way to improve the resolution and avoid changing the quality of unmasked regions?

Thanks, Shujun

braindotai commented 1 year ago

Can you send some screenshots? Quality reduction should be unnoticeable for the regions where there is no watermark.

flymans commented 1 year ago

Actually, I think the reason of low resolution is default of --max-dix arg. It's 512 pixels.

I ran into a bug: !python inference.py --max-dim=1024

TypeError: 'float' object cannot be interpreted as an integer

edwin-yan commented 1 year ago

Actually, I think the reason of low resolution is default of --max-dix arg. It's 512 pixels.

I ran into a bug: !python inference.py --max-dim=1024

TypeError: 'float' object cannot be interpreted as an integer

you do not need the equal sign. Replace it with a space

flymans commented 11 months ago

you do not need the equal sign. Replace it with a space

Nope. Still same error: !python inference.py --image-path='foo.jpg' --mask-path='bar.jpg' --max-dim 720 --training-steps 20000

Traceback (most recent call last): File "/content/Watermark-Removal-Pytorch/inference.py", line 16, in <module> remove_watermark( File "/content/Watermark-Removal-Pytorch/api.py", line 27, in remove_watermark image_np, mask_np = preprocess_images(image_path, mask_path, max_dim) File "/content/Watermark-Removal-Pytorch/helper.py", line 60, in preprocess_images image_pil, mask_pil = max_dimension_resize(image_pil, mask_pil, max_dim) File "/content/Watermark-Removal-Pytorch/helper.py", line 54, in max_dimension_resize return image_pil.resize((w, h)), mask_pil.resize((w, h)) File "/usr/local/lib/python3.10/dist-packages/PIL/Image.py", line 2192, in resize return self._new(self.im.resize(size, resample, box)) TypeError: 'float' object cannot be interpreted as an integer

REPTILEHAUS commented 9 months ago

I also get this error

friki67 commented 8 months ago

Yes, me too. You can fix this editing inference.py and changing the type of the parameter.

parser.add_argument('--max-dim', type = float, default = 512, help = 'Max dimension of the final output image')

change the bold part totype=int.

Regards

braindotai commented 7 months ago

@friki67 that's the correct fix, could you make the pull request?

friki67 commented 7 months ago

@friki67 that's the correct fix, could you make the pull request?

Sorry, I don't know how to do it :(

arg274 commented 7 months ago

It seems that setting it to a value higher than 512 makes the whole thing impractical. ETA is showing up to be 20 hours for a single image with a max_dim of 1024 on an RTX 2080. That's unfortunate because the low resolution images that it outputs with the default max_dim of 512 is impractical as well.