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

Pad images to size requirements in call API #137

Merged
merged 4 commits into from
Jan 20, 2024
Merged

Conversation

RunDevelopment
Copy link
Member

Changes:

  • Add get_padding for SizeRequirements. This method will return the necessary to make a size satisfy the requirements.
  • Automatically pad (and later unpad) input images in the call API. This means that user code no longer has to handle padding and can run models on images of any size.
  • Some additional checks to verify call API requirements.

@RunDevelopment RunDevelopment marked this pull request as draft January 20, 2024 22:00
@RunDevelopment RunDevelopment marked this pull request as ready for review January 20, 2024 22:11
@RunDevelopment
Copy link
Member Author

Getting padding right turned out to be more interesting than I thought. The issue is that torch.nn.functional.pad(t, (0, pad_w, 0, pad_h), "reflect") only works if pad_w and pad_h are less than the width and height of the image respectively. So we first have to pad as much as we can with reflect and then use something else to cover the rest (if anything). Surprisingly non-trivial.

@joeyballentine joeyballentine merged commit bab2572 into main Jan 20, 2024
7 checks passed
@joeyballentine joeyballentine deleted the size-req-impr branch January 20, 2024 22:48
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.

2 participants