Unverified Commit acabaf80 authored by Philip Meier's avatar Philip Meier Committed by GitHub
Browse files

fix {convert_format, clamp}_bounding_box (#7229)

parent af7c6c04
...@@ -230,8 +230,10 @@ def convert_format_bounding_box( ...@@ -230,8 +230,10 @@ def convert_format_bounding_box(
elif isinstance(inpt, datapoints.BoundingBox): elif isinstance(inpt, datapoints.BoundingBox):
if old_format is not None: if old_format is not None:
raise ValueError("For bounding box datapoint inputs, `old_format` must not be passed.") raise ValueError("For bounding box datapoint inputs, `old_format` must not be passed.")
output = _convert_format_bounding_box(inpt, old_format=inpt.format, new_format=new_format, inplace=inplace) output = _convert_format_bounding_box(
return datapoints.BoundingBox.wrap_like(inpt, output) inpt.as_subclass(torch.Tensor), old_format=inpt.format, new_format=new_format, inplace=inplace
)
return datapoints.BoundingBox.wrap_like(inpt, output, format=new_format)
else: else:
raise TypeError( raise TypeError(
f"Input can either be a plain tensor or a bounding box datapoint, but got {type(inpt)} instead." f"Input can either be a plain tensor or a bounding box datapoint, but got {type(inpt)} instead."
...@@ -266,7 +268,7 @@ def clamp_bounding_box( ...@@ -266,7 +268,7 @@ def clamp_bounding_box(
elif isinstance(inpt, datapoints.BoundingBox): elif isinstance(inpt, datapoints.BoundingBox):
if format is not None or spatial_size is not None: if format is not None or spatial_size is not None:
raise ValueError("For bounding box datapoint inputs, `format` and `spatial_size` must not be passed.") raise ValueError("For bounding box datapoint inputs, `format` and `spatial_size` must not be passed.")
output = _clamp_bounding_box(inpt, format=inpt.format, spatial_size=inpt.spatial_size) output = _clamp_bounding_box(inpt.as_subclass(torch.Tensor), format=inpt.format, spatial_size=inpt.spatial_size)
return datapoints.BoundingBox.wrap_like(inpt, output) return datapoints.BoundingBox.wrap_like(inpt, output)
else: else:
raise TypeError( raise TypeError(
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment