Skip to content

Conversation

pmeier
Copy link
Contributor

@pmeier pmeier commented Aug 12, 2022

import torch
from torchvision.prototype import features, transforms


image = features.EncodedImage.from_path(
    "test/assets/fakedata/logos/rgb_pytorch.png"
).decode()

bounding_boxes = features.BoundingBox(
    [[60, 30, 15, 15]],
    format=features.BoundingBoxFormat.CXCYWH,
    image_size=(100, 100),
    dtype=torch.float,
)

segmentation_masks = torch.zeros((1, 100, 100), dtype=torch.bool)
segmentation_masks[..., 24:36, 55:66] = True
segmentation_masks = features.SegmentationMask(segmentation_masks)

target = dict(
    boxes=bounding_boxes,
    masks=segmentation_masks,
)
sample = image, target

transform = transforms.ScaleJitter(target_size=(100, 100))

torch.manual_seed(0)

for i in range(5):
    transformed_image, transformed_target = transform(sample)
    transformed_bounding_boxes = transformed_target["boxes"]
    transformed_segmentation_masks = transformed_target["masks"]

0 1 2 3 4

I've verified that plugging image and target in the current reference transform yields the same results.

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!

@vfdev-5
Copy link
Contributor

vfdev-5 commented Aug 12, 2022

How about adding tests like for other transforms: checking _get_params and _transform ?

Copy link
Contributor

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

LGTM, thanks @pmeier !

@datumbox datumbox merged commit 2aa5474 into pytorch:main Aug 15, 2022
@pmeier pmeier deleted the scale-jitter branch August 15, 2022 16:39
@pmeier pmeier mentioned this pull request Aug 18, 2022
facebook-github-bot pushed a commit that referenced this pull request Aug 24, 2022
…nsforms (#6411)

Summary:
* port ScaleJitter from detection reference to prototype transforms

* add test

* use MagicMock as sentinel

Reviewed By: datumbox

Differential Revision: D38824248

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