Add vision requirement to image transforms#20712
Add vision requirement to image transforms#20712amyeroberts merged 4 commits intohuggingface:mainfrom
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.
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.
How is this different than having requires_backend(["vision"]) as the first line of the function?
There was a problem hiding this comment.
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.
Ah yes, tf_required and torch_required could probably be cleaned up too!
|
A quick question: If we add |
Yep. I'll add those in too. |
ydshieh
left a comment
There was a problem hiding this comment.
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.