Skip to content

Commit 475d695

Browse files
NicolasHugfacebook-github-bot
authored andcommitted
[fbsync] fix {convert_format, clamp}_bounding_box (#7229)
Reviewed By: vmoens Differential Revision: D44416268 fbshipit-source-id: 664c723e512d08c8bb2e32e8efefbabbe65b0122
1 parent bc4273d commit 475d695

File tree

1 file changed

+5
-3
lines changed
  • torchvision/prototype/transforms/functional

1 file changed

+5
-3
lines changed

torchvision/prototype/transforms/functional/_meta.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -230,8 +230,10 @@ def convert_format_bounding_box(
230230
elif isinstance(inpt, datapoints.BoundingBox):
231231
if old_format is not None:
232232
raise ValueError("For bounding box datapoint inputs, `old_format` must not be passed.")
233-
output = _convert_format_bounding_box(inpt, old_format=inpt.format, new_format=new_format, inplace=inplace)
234-
return datapoints.BoundingBox.wrap_like(inpt, output)
233+
output = _convert_format_bounding_box(
234+
inpt.as_subclass(torch.Tensor), old_format=inpt.format, new_format=new_format, inplace=inplace
235+
)
236+
return datapoints.BoundingBox.wrap_like(inpt, output, format=new_format)
235237
else:
236238
raise TypeError(
237239
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(
266268
elif isinstance(inpt, datapoints.BoundingBox):
267269
if format is not None or spatial_size is not None:
268270
raise ValueError("For bounding box datapoint inputs, `format` and `spatial_size` must not be passed.")
269-
output = _clamp_bounding_box(inpt, format=inpt.format, spatial_size=inpt.spatial_size)
271+
output = _clamp_bounding_box(inpt.as_subclass(torch.Tensor), format=inpt.format, spatial_size=inpt.spatial_size)
270272
return datapoints.BoundingBox.wrap_like(inpt, output)
271273
else:
272274
raise TypeError(

0 commit comments

Comments
 (0)