Skip to content

Fix: Allow img_size to be int or tuple in PatchEmbed #2477

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

Merged
merged 1 commit into from
Apr 19, 2025

Conversation

sddongxh
Copy link

This PR modifies the PatchEmbed constructor to support img_size as either an int or a Tuple[int, int], making it compatible with downstream inputs that may provide HxW dimensions. This improves flexibility and avoids unnecessary conversion and lint error elsewhere.

Changes:

  • Updated type hint for img_size to Union[int, Tuple[int, int]]
  • Ensured internal usage converts int to (int, int)

No changes in behavior if used with default integer input.

@rwightman
Copy link
Collaborator

@sddongxh it already is fully compatible with tuple inputs, just the typing was never updated....

@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

@sddongxh
Copy link
Author

@sddongxh it already is fully compatible with tuple inputs, just the typing was never updated....

why not ... the lint error is quite annoying

@rwightman
Copy link
Collaborator

yeah, I'll merge it, the comment is suggesting that funcitonality was changed/fixed, but it's just type annotation and lint

@rwightman rwightman merged commit 0c136f7 into huggingface:main Apr 19, 2025
22 checks passed
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.

3 participants