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

[proto] Added resized_crop_bounding_box op #5853

Merged
merged 9 commits into from
Apr 25, 2022

Conversation

vfdev-5
Copy link
Collaborator

@vfdev-5 vfdev-5 commented Apr 21, 2022

Related to #5514

Description:

  • Added functional resized_crop_bounding_box op
  • Added tests
    • added format arg for test_correctness_crop_bounding_box

Results on synthetic images/bboxes:

Code
import numpy as np

import torch
import torchvision
from torchvision.prototype import features
from torchvision.prototype.transforms.functional import resized_crop_bounding_box, resized_crop_image_tensor

size = (64, 76)
# xyxy format
in_boxes = [
    [10, 15, 25, 35],
    [50, 5, 70, 22],
    [45, 46, 56, 62],
]
labels = [1, 2, 3]

im1 = 255 * np.ones(size + (3, ), dtype=np.uint8)
in_im = torch.tensor(im1).permute(2, 0, 1).view(1, 3, *size)

in_boxes = features.BoundingBox(
    in_boxes, format=features.BoundingBoxFormat.XYXY, image_size=size
)
    
top = -10
left = 5
height = size[0] - 15
width = size[1] + 20
out_size = (32, 32)


out_boxes = resized_crop_bounding_box(
    in_boxes, 
    in_boxes.format,
    top,
    left,
    height, 
    width, 
    out_size
)

out_im = resized_crop_image_tensor(in_im, top, left, height, width, out_size)

image

@vfdev-5 vfdev-5 requested a review from pmeier April 21, 2022 15:30
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, thanks Victor!

@vfdev-5 vfdev-5 merged commit 3b17452 into pytorch:main Apr 25, 2022
@vfdev-5 vfdev-5 deleted the proto-bbox-resized-crop branch April 25, 2022 08:53
@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 May 6, 2022
Summary:
* [proto] Added crop_bounding_box op

* Added tests for resized_crop_bounding_box

* Fixed code formatting

Reviewed By: jdsgomes, NicolasHug

Differential Revision: D36095714

fbshipit-source-id: 5896896af6e6f2cd656b4f157f2828dc93664f85
@vfdev-5 vfdev-5 changed the title Added resized_crop_bounding_box op [proto] Added resized_crop_bounding_box op May 9, 2022
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.

3 participants