Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions test/test_prototype_transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,21 @@ def test_common(self, transform, adapter, container_type, image_or_video, device
else:
assert output_item is input_item

if isinstance(input_item, datapoints.BoundingBox) and not isinstance(
transform, transforms.ConvertBoundingBoxFormat
):
assert output_item.format == input_item.format

# Enforce that the transform does not turn a degenerate box marked by RandomIoUCrop (or any other future
# transform that does this), back into a valid one.
# TODO: we should test that against all degenerate boxes above
for format in list(datapoints.BoundingBoxFormat):
sample = dict(
boxes=datapoints.BoundingBox([[0, 0, 0, 0]], format=format, spatial_size=(224, 244)),
labels=torch.tensor([3]),
)
assert transforms.SanitizeBoundingBoxes()(sample)["boxes"].shape == (0, 4)

@parametrize(
[
(
Expand Down
16 changes: 16 additions & 0 deletions test/test_prototype_transforms_functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,22 @@ def test_unkown_type(self, info):
with pytest.raises(TypeError, match=re.escape(str(type(unkown_input)))):
info.dispatcher(unkown_input, *other_args, **kwargs)

@make_info_args_kwargs_parametrization(
[
info
for info in DISPATCHER_INFOS
if datapoints.BoundingBox in info.kernels and info.dispatcher is not F.convert_format_bounding_box
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to exclude F.convert_format_bounding_box since its only job is to change the format.

],
args_kwargs_fn=lambda info: info.sample_inputs(datapoints.BoundingBox),
)
def test_bounding_box_format_consistency(self, info, args_kwargs):
(bounding_box, *other_args), kwargs = args_kwargs.load()
format = bounding_box.format

output = info.dispatcher(bounding_box, *other_args, **kwargs)

assert output.format == format


@pytest.mark.parametrize(
("alias", "target"),
Expand Down