Skip to content

Bounding Boxes Conversions #2687

@oke-aditya

Description

@oke-aditya

🚀 Feature

Simple feature request, we have a lot of useful bounding box operations, in torchvision.ops.boxes.py.

Motivation

Most data format come in either these two, VOC and COCO for object detection.
If we can provide a utility to convert it, it might ease the process from the user's side, just like how IoU and NMS did.

Pitch

Provide 2 functions, (please name them better)

def xywh_from_xyxy(torch_tensor : Tensor[x1 y1 x2 y2]):
   # Add the 2 dimensions of (y2-y1), (x2 - x1) to x2 and y2.

def xyxy_from_xywh(torch_tensor : Tensor[x y w h]):
   # x2 = x + w
   # y2 = y + h
   # Replace these 2 to x2 and y2.

Alternatives

I am unsure of any, for now, we can leave this to the user as well, but this is just utility no forcing.

Additional context

These are very commonly used in most repositories. Supporting natively like NMS and IoU provides a standard.
Again this is a utility so not a big feature or addition which we need, might help to simplify detection models. I'm unsure in segmentation models.

I can most probably submit a PR for this if it is good to go.

cc @pmeier

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions