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

Incorrect BoundingBoxes format conversion CXCYWH -> XYXY #8887

Open
NicolasHug opened this issue Jan 30, 2025 · 0 comments
Open

Incorrect BoundingBoxes format conversion CXCYWH -> XYXY #8887

NicolasHug opened this issue Jan 30, 2025 · 0 comments

Comments

@NicolasHug
Copy link
Member

NicolasHug commented Jan 30, 2025

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

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

1 participant