-
Notifications
You must be signed in to change notification settings - Fork 7.1k
[proto] Fixes Transform._transformed_types and torch.Tensor #6487
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
vfdev-5
commented
Aug 24, 2022
- Fixes unexpected behaviour with Transform._transformed_types and torch.Tensor
- Added a test for color space conversion
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.
LGTM, thanks! You got some unused imports.
@@ -42,7 +42,7 @@ def _transform(self, inpt: Any, params: Dict[str, Any]) -> Any: | |||
|
|||
class ConvertColorSpace(Transform): | |||
# F.convert_color_space does NOT handle `_Feature`'s in general | |||
_transformed_types = (torch.Tensor, features.Image, PIL.Image.Image) |
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.
Maybe we should have an alias for these three, since they will often happen together?
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.
We can do on a follow up. Good idea for when we review the whole input validation mechanism as a whole.
@@ -45,12 +45,18 @@ def query_chw(sample: Any) -> Tuple[int, int, int]: | |||
return chws.pop() | |||
|
|||
|
|||
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.
Could you also use this in has_all
?
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 think we can't change easily for-loops types -> objects into objects -> types.
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.
True, I didn't see that. Could you add a comment to has_all
why we are not using it, since that is not obvious?
I'm merging this because I really need this to progress other work. Let's follow up with the non-blocking comments. |
…6487) Summary: * Fixes unexpected behaviour with Transform._transformed_types and torch.Tensor * Make code consistent to has_any, has_all implementation * Fixed failing flake8 check Reviewed By: NicolasHug Differential Revision: D39131010 fbshipit-source-id: 376289d1b0854acdf76f4495a1eabf940058551b