-
Notifications
You must be signed in to change notification settings - Fork 7.1k
expose some prototype transforms utils #6989
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
Conversation
return h, w | ||
|
||
|
||
def _isinstance(obj: Any, types_or_checks: Tuple[Union[Type, Callable[[Any], bool]], ...]) -> bool: |
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.
This is the only thing we need to deal with before we move forward.
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.
I had a look on the usage of _isinstance
in our codebase and feel that it's useful enough to be a public utility. WDYT?
We obviously can't remove the underscore, so we need a new name. Perhaps check_type()
?
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.
Yes, I would expose it as well. +1 for check_type
. @vfdev-5 Do you have an opinion here?
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.
Summary: * expose some prototype transforms utils * rename _isinstance Reviewed By: YosuaMichael Differential Revision: D41648537 fbshipit-source-id: 3239b62cb3fc7a915208608d04775c3ed2a8281a
In order to make it easy to subclass the v2 transforms, we also need to expose some utilities for public usage. This PR adds a new module
torchvision.prototype.transforms.utils
for that. Everything else stays in_utils
as before.For completeness, we also discussed dynamically create this module. This can be achieved by adding the following to
__init__.py
Now, one can do
This would save us the split between the two modules, but has some issues as well:
from torchvision.prototype.transforms.utils import has_any
work perfectly fine, but are not picked up by static analyzers likemypy
or IDE'scc @vfdev-5 @datumbox @bjuncek