Skip to content

Conversation

pmeier
Copy link
Contributor

@pmeier pmeier commented Nov 4, 2021

This ports the initial chunk of transforms from https://github.com/pmeier/torchvision-datasets-rework/tree/rfc/transforms. You can find a discussion of this in pmeier/torchvision-datasets-rework#1.

Here is a quick demonstration:

import os.path

from torchvision import io, utils
from torchvision.prototype import transforms, features
from torchvision.transforms.functional import to_pil_image


def show(image, bounding_box):
    annotated_image = utils.draw_bounding_boxes(image, bounding_box.convert("xyxy").unsqueeze(0))
    to_pil_image(annotated_image).show()


image = features.Image(io.read_image(os.path.join("test", "assets", "fakedata", "logos", "rgb_pytorch.jpg")))
bounding_box = features.BoundingBox((60, 30, 12, 12), format="cxcywh", image_size=image.shape[-2:])

show(image, bounding_box)

transform = transforms.Compose(
    transforms.Resize(256),
    transforms.HorizontalFlip(),
)

# this would normally come from a dataset, i.e. `for sample in datasets.load("coco")`
sample = dict(foo=image, bar=bounding_box)
transformed_sample = transform(sample)

show(transformed_sample["foo"], transformed_sample["bar"])

before
after

Note to reviewers: there are two changes that make the diff look a lot larger than it is:

  1. I've renamed torchvision/prototype/transforms/presets.py to _presets.py in order to make it consistent with the other files there. All the changes in torchvision/prototype/models are just fixing the imports.
  2. I've moved some functionality from torchvision/prototype/datasets/utils/_internal.py to torchvision/prototype/utils/_internal.py. This also results in a few import changes in other files.

cc @vfdev-5 @datumbox @bjuncek

@facebook-github-bot
Copy link
Contributor

facebook-github-bot commented Nov 4, 2021

💊 CI failures summary and remediations

As of commit 8788d32 (more details on the Dr. CI page):


  • 1/1 failures introduced in this PR

1 failure not recognized by patterns:

Job Step Action
CircleCI binary_libtorchvision_ops_android Build 🔁 rerun

This comment was automatically generated by Dr. CI (expand for details).

Please report bugs/suggestions to the (internal) Dr. CI Users group.

Click here to manually regenerate this comment.

Copy link
Member

@fmassa fmassa 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 a lot!

Would be good to add tests in a follow-up PR. Also, it would be instructive to implement the basic presets to see how this combines together (without AutoAugment for now for simplicity).

@fmassa fmassa mentioned this pull request Nov 5, 2021
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.

@pmeier Some of the tests are failing and they are related (see 1, 2)

Marking with "Request changes" to avoid accidental merges. We can merge after fixing the tests.

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.

Thanks for fixing the import issue. LGTM.

@pmeier pmeier merged commit 272e080 into pytorch:main Nov 11, 2021
@pmeier pmeier deleted the prototype/transforms branch November 11, 2021 10:32
@github-actions
Copy link

Hey @pmeier!

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

cyyever pushed a commit to cyyever/vision that referenced this pull request Nov 16, 2021
* add initial chunk of prototype transforms

* fix tests

* add error message

* fix more imports

* add explicit no-ops

* add test for no-ops

* cleanup
facebook-github-bot pushed a commit that referenced this pull request Nov 17, 2021
Summary:
* add initial chunk of prototype transforms

* fix tests

* add error message

* fix more imports

* add explicit no-ops

* add test for no-ops

* cleanup

Reviewed By: datumbox

Differential Revision: D32470491

fbshipit-source-id: 56f1c4291554842ae0166e37e955600764f563bf
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