Skip to content
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

Re-write getting started guide for transforms V2 #7870

Merged
merged 12 commits into from
Aug 23, 2023

Conversation

NicolasHug
Copy link
Member

Will submit re-write of "e2e" example when this is merged.

@pytorch-bot
Copy link

pytorch-bot bot commented Aug 22, 2023

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/vision/7870

Note: Links to docs will display an error until the docs builds have been completed.

❌ 8 New Failures, 2 Unrelated Failures

As of commit dfeafa2 with merge base 11e49de (image):

NEW FAILURES - The following jobs have failed:

FLAKY - The following job failed but was likely due to flakiness present on trunk:

BROKEN TRUNK - The following job failed but was present on the merge base:

👉 Rebase onto the `viable/strict` branch to avoid these failures

This comment was automatically generated by Dr. CI and updates every 15 minutes.

from torchvision.utils import draw_bounding_boxes


def plot(imgs):
Copy link
Member Author

@NicolasHug NicolasHug Aug 22, 2023

Choose a reason for hiding this comment

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

I think we need to reduce the boilerplate to a very strict minimum in the examples, because they're already complex enough as it is - we don't need noise.

I opted for the option of creating a new file here. I don't have a super strong opinion on how it should be done, other than the fact that this code shouldn't be part of the example itself.

Hopefully this is non-blocking anyway and we can figure out a long-term solution later, if there are concerns with this one.

# dataset = wrap_dataset_for_transforms_v2(dataset)
# # Now the dataset returns datapoints!
#
# Using your own datasets
Copy link
Member Author

Choose a reason for hiding this comment

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

I dropped the part about PennFudanDataset here. It seems too specific for this "getting started" guide.

Depending on what pytorch/tutorials#2533 looks like, we may link to it form there.

docs/source/transforms.rst Outdated Show resolved Hide resolved
Copy link
Collaborator

@vfdev-5 vfdev-5 left a comment

Choose a reason for hiding this comment

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

Good re-write. Just few comments and good to go from my side

gallery/v2_transforms/plot_transforms_v2.py Outdated Show resolved Hide resolved
gallery/v2_transforms/plot_transforms_v2.py Outdated Show resolved Hide resolved
gallery/v2_transforms/plot_transforms_v2.py Outdated Show resolved Hide resolved
docs/source/transforms.rst Outdated Show resolved Hide resolved
@NicolasHug NicolasHug requested a review from pmeier August 22, 2023 18:00
Co-authored-by: vfdev <vfdev.5@gmail.com>
Copy link
Contributor

@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.

Few minor comments, but LGTM anyway.


assets_directory = pathlib.Path("../assets")
# If you're trying to run that on collab, you can download the assets and the
# helpers from https://github.com/pytorch/vision/tree/main/gallery/
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
# helpers from https://github.com/pytorch/vision/tree/main/gallery/
# helpers from https://github.com/pytorch/vision/tree/main/gallery/v2_transforms

Copy link
Member Author

Choose a reason for hiding this comment

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

assets are in gallery

# If you're trying to run that on collab, you can download the assets and the
# helpers from https://github.com/pytorch/vision/tree/main/gallery/
from helpers import plot
img = read_image(str(Path('../assets') / 'astronaut.jpg'))
Copy link
Contributor

Choose a reason for hiding this comment

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

This will also not work on Collab without user interference, right?

Copy link
Member Author

Choose a reason for hiding this comment

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

probably not


return path, image, bounding_boxes, masks, labels
transforms = v2.Compose([
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we avoid the plural for the variable name to not clash with the namespace? Somewhat weak argument, since for some datasets we would have transforms=transform. Still, I would prefer keeping it singular here and in general.

Copy link
Member Author

@NicolasHug NicolasHug Aug 23, 2023

Choose a reason for hiding this comment

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

This is sort of related to #7866.

These are transforms, it makes sense to call this variable transforms. If there was a single transform I'd call it transform, or t.

I personally strongly dislike the new trend of importing the module as transforms in our tests.

gallery/v2_transforms/plot_transforms_v2.py Outdated Show resolved Hide resolved
gallery/v2_transforms/plot_transforms_v2.py Outdated Show resolved Hide resolved
@NicolasHug NicolasHug merged commit 6f72b76 into pytorch:main Aug 23, 2023
53 of 63 checks passed
facebook-github-bot pushed a commit that referenced this pull request Sep 6, 2023
Summary: (Note: this ignores all push blocking failures!)

Reviewed By: matteobettini

Differential Revision: D48900408

fbshipit-source-id: 04f3cf195318b4b03c527feb05de92d5700717e0

Co-authored-by: vfdev <vfdev.5@gmail.com>
Co-authored-by: Philip Meier <github.pmeier@posteo.de>
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