Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unnecessary input image padding #19

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

BVlad917
Copy link

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

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

xenova commented Nov 7, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants