-
Notifications
You must be signed in to change notification settings - Fork 31.9k
Add vision requirement to image transforms #20712
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
Add vision requirement to image transforms #20712
Conversation
|
The documentation is not available anymore as the PR was closed or merged. |
sgugger
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thansk for working on this. Not too sur we actually need a decorator for that, with the existing tools.
src/transformers/image_transforms.py
Outdated
| return rescaled_image | ||
|
|
||
|
|
||
| @vision_required |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How is this different than having requires_backend(["vision"]) as the first line of the function?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be honest, I just saw the tf_required and copied from there. I'll remove the decorator and add those instead 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah yes, tf_required and torch_required could probably be cleaned up too!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Opened a draft PR here: #20715
sgugger
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perfect, thanks!
|
A quick question: If we add |
Yep. I'll add those in too. |
ydshieh
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @amyeroberts
(I was think if it is good to call require_backends in each call - but it seems this call is very fast so there should be no problem)
* Add require_vision decorator * Fixup * Use requires_backends * Add requires_backend to utils functions
What does this PR do?
Addresses issue when importing functions in the
image_transformsmodule if Pillow isn't installed. Namely:ChannelDimension. Resolved by rearranging imports.vision_requireddecorator to allow for errors only on select functions.Fixes #20627
This needs to be merged in before the transforms can be removed from the init in #20704
Snippet below shows new behaviour when running in an environment without Pillow installed:
Before submitting
Pull Request section?
to it if that's the case.
documentation guidelines, and
here are tips on formatting docstrings.