Skip to content

Remove unnecessary input image padding#19

Open
BVlad917 wants to merge 1 commit intomv-lab:mainfrom
BVlad917:bogdanv/fix_padding_bug
Open

Remove unnecessary input image padding#19
BVlad917 wants to merge 1 commit intomv-lab:mainfrom
BVlad917:bogdanv/fix_padding_bug

Conversation

@BVlad917
Copy link
Copy Markdown

If an image's height/width already is a multiple of the window size, then we don't have to pad the input image. E.g., for an image of shape 256x512 and using window size of 8x8 the previous code would pad in both height and width by a full window in both dimensions (i.e., 8 pixels in height and 8 pixels in width), even though this is unnecessary. This is now removed, and for the given example the padding would be 0 in both dimensions.

@xenova
Copy link
Copy Markdown

xenova commented Nov 7, 2023

This is also something I noticed today while adding this to 🤗 Transformers.js.

When following this demo, the image (which is already 256x256) is unnecessarily padded to 264x264, meaning the upscaled version also has the padding (see right and bottom, the image is mirrored):
image

@xenova
Copy link
Copy Markdown

xenova commented Nov 7, 2023

Also, when running it with the replicate link (shown in the README), it does not add the padding:
image

@wade0604
Copy link
Copy Markdown

wade0604 commented Aug 21, 2024

I tried to replicate SWIN2SR, using the same experimental configuration as SWINIR, but it seems to be less effective than SWINIR from the logs, my training set DF2k and test set is Set5
The first log below is swinir, the second is swin2sr

train.log
train (1).log

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants