Skip to content

Batched box scale #4835

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

Closed
vadimkantorov opened this issue Nov 2, 2021 · 5 comments
Closed

Batched box scale #4835

vadimkantorov opened this issue Nov 2, 2021 · 5 comments

Comments

@vadimkantorov
Copy link

vadimkantorov commented Nov 2, 2021

🚀 The feature

Frequent utility in postprocessing box detections:

def batched_box_scale(boxes, image_shape, target_image_shape):
  fx = target_image_shape[..., -1] / image_shape[...., -1]
  fy = target_image_shape[..., -2] / image_shape[..., -2]
  return boxes * torch.stack([fx, fy, fx, fy], dim = -1).to(boxes.device)

Motivation, pitch

This is a frequently needed utility to bring back computed detections to a common / original coordinate frame.

cc @vfdev-5 @datumbox

@fmassa
Copy link
Member

fmassa commented Nov 2, 2021

Hi @vadimkantorov

This is planned with the revamp of the transforms. The RFC is in pmeier/torchvision-datasets-rework#1 , and we are starting to integrate it in #4721

Let us know what you think about it

@vadimkantorov
Copy link
Author

What do you mean by transforms? For me, this kind of utilities have nothing to do with augmentations. Probably, I misunderstand the term

@fmassa
Copy link
Member

fmassa commented Nov 4, 2021

I meant this will be handled by

# boxes is a custom object that is defined in #4721
boxes : BBox

# then the transforms will know how to resize them
T.resize(boxes, (50, 20))

@vadimkantorov
Copy link
Author

I only hope that there will also be functions accepting bare tensors - this would be more versatile and not require buying into new abstractions for porting existing code bases

@fmassa
Copy link
Member

fmassa commented Nov 5, 2021

@vadimkantorov new abstractions with transforms are in #4861

I hope they will be useful and would encourage users to use them

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants