Skip to content

Incorrect BoundingBoxes format conversion CXCYWH -> XYXY #8887

Open
@NicolasHug

Description

@NicolasHug

Thanks to @AntoineSimoulin for uncovering this issue in 5321f23

old_format = tv_tensors.BoundingBoxFormat.CXCYWH
new_format = tv_tensors.BoundingBoxFormat.XYXY

dtype = torch.int64
fn_type = "functional"
device = torch.device("cpu")


# bounding_boxes = make_bounding_boxes(format=old_format, dtype=dtype, device=device)
bounding_boxes = tv_tensors.BoundingBoxes([[ 5,  6, 10, 13]], format=tv_tensors.BoundingBoxFormat.CXCYWH, canvas_size=(17, 11))

if fn_type == "functional":
    fn = functools.partial(F.convert_bounding_box_format, new_format=new_format)
else:
    fn = transforms.ConvertBoundingBoxFormat(format=new_format)

actual = fn(bounding_boxes)
expected = _reference_convert_bounding_box_format(bounding_boxes, new_format)

assert_equal(actual, expected)

Gives:

BoundingBoxes([[ 0, -1, 10, 12]], format=BoundingBoxFormat.XYXY, canvas_size=(17, 11))
BoundingBoxes([[ 0,  0, 10, 12]], format=BoundingBoxFormat.XYXY, canvas_size=(17, 11))

The -1 part is clearly wrong. Maybe an easy fix is to call max(0, ...) at some point but I haven't looked into it yet.

cc @vfdev-5

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