Skip to content

Added wrap_dataset_for_transforms_v2 into datasets and handled beta w… #7279

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
Feb 17, 2023

Conversation

vfdev-5
Copy link
Collaborator

@vfdev-5 vfdev-5 commented Feb 17, 2023

Description:

  • Added wrap_dataset_for_transforms_v2 into datasets and handled beta warning
  • Added tests

Usage:

python -c "import torchvision; torchvision.disable_beta_transforms_warning(); from torchvision.datasets import wrap_dataset_for_transforms_v2"
> 
python -c "from torchvision.datasets import wrap_dataset_for_transforms_v2"
> 
/vision/torchvision/transforms/v2/__init__.py:54: UserWarning: The torchvision.datapoints and torchvision.transforms.v2 namespaces are still Beta. While we will try our best to maintain backward compatibility, some APIs or behaviors might change without a deprecation cycle. To help us improve these new features, please provide your feedback here: https://github.com/pytorch/vision/issues/6753.You can silence this warning by calling torchvision.disable_beta_transform_warning().
  warnings.warn(_BETA_TRANSFORMS_WARNING)
/vision/torchvision/datapoints/__init__.py:14: UserWarning: The torchvision.datapoints and torchvision.transforms.v2 namespaces are still Beta. While we will try our best to maintain backward compatibility, some APIs or behaviors might change without a deprecation cycle. To help us improve these new features, please provide your feedback here: https://github.com/pytorch/vision/issues/6753.You can silence this warning by calling torchvision.disable_beta_transform_warning().
  warnings.warn(_BETA_TRANSFORMS_WARNING)
python -c "from torchvision.datasets import CIFAR10"
> 

cc @bjuncek @pmeier

setattr(torchvision, "_WARN_ABOUT_BETA_TRANSFORMS", value)


def test_no_warns_if_imported_from_datasets():
Copy link
Member

@NicolasHug NicolasHug Feb 17, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test is failing, but I'd suggest removing both tests.
They can interfere with the import and warnings in ways that we may not predict properly, and this may lead to surprising or undesired behaviour (like masking a warning it shouldn't mask).

I agree we should test this, it can be done with a strategy similar to the one proposed in #7269, but we should probably leave that for next week

Copy link
Collaborator

@pmeier pmeier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a few comments on the tests. Module level __getattr__ for the import looks fine to me to resolve the circular dependency.

@pmeier
Copy link
Collaborator

pmeier commented Feb 17, 2023

Copy link
Member

@NicolasHug NicolasHug left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for the PR @vfdev-5 . Some minor comment but the behaviour LGTM. We should also remove wrap_dataset_for_transforms_v2 from datapoints.__init__.py before merging

@NicolasHug NicolasHug mentioned this pull request Feb 17, 2023
49 tasks
@vfdev-5 vfdev-5 requested review from pmeier February 17, 2023 13:07
@vfdev-5 vfdev-5 force-pushed the reimport-wrap_dataset_for_transforms_v2 branch from ab715dc to 24fd7d6 Compare February 17, 2023 13:45
Copy link
Collaborator

@pmeier pmeier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM is CI is green. Thanks Victor!

Copy link
Member

@NicolasHug NicolasHug left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot @vfdev-5 , still LGTM!

@vfdev-5 vfdev-5 merged commit ac1512b into pytorch:main Feb 17, 2023
@vfdev-5 vfdev-5 deleted the reimport-wrap_dataset_for_transforms_v2 branch February 17, 2023 14:03
@github-actions
Copy link

Hey @vfdev-5!

You merged this PR, but no labels were added. The list of valid labels is available at https://github.com/pytorch/vision/blob/main/.github/process_commit.py

facebook-github-bot pushed a commit that referenced this pull request Mar 28, 2023
…ed beta w… (#7279)

Summary: Co-authored-by: Nicolas Hug <[email protected]>

Reviewed By: vmoens

Differential Revision: D44416626

fbshipit-source-id: 44e576c380d9003ec480bb89e599e5e1dcb704f7
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