Skip to content

[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

Merged
merged 6 commits into from
Aug 25, 2022

Conversation

vfdev-5
Copy link
Collaborator

@vfdev-5 vfdev-5 commented Aug 24, 2022

  • Fixes unexpected behaviour with Transform._transformed_types and torch.Tensor
  • Added a test for color space conversion

@vfdev-5 vfdev-5 requested a review from datumbox August 25, 2022 10:08
Copy link
Contributor

@datumbox datumbox left a 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)
Copy link
Collaborator

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?

Copy link
Contributor

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:
Copy link
Collaborator

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?

Copy link
Collaborator Author

@vfdev-5 vfdev-5 Aug 25, 2022

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.

Copy link
Collaborator

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?

@datumbox
Copy link
Contributor

@vfdev-5 This gaussian_blur_image_tensor test is flaky. It's been failing a lot lately. Could you look into it on a separate PR?

@datumbox
Copy link
Contributor

I'm merging this because I really need this to progress other work. Let's follow up with the non-blocking comments.

@datumbox datumbox merged commit 0eb8aab into pytorch:main Aug 25, 2022
@vfdev-5 vfdev-5 deleted the proto-fix-transformed_types branch August 25, 2022 11:08
facebook-github-bot pushed a commit that referenced this pull request Aug 30, 2022
…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants