@@ -230,8 +230,10 @@ def convert_format_bounding_box(
230
230
elif isinstance (inpt , datapoints .BoundingBox ):
231
231
if old_format is not None :
232
232
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 )
235
237
else :
236
238
raise TypeError (
237
239
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
268
elif isinstance (inpt , datapoints .BoundingBox ):
267
269
if format is not None or spatial_size is not None :
268
270
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 )
270
272
return datapoints .BoundingBox .wrap_like (inpt , output )
271
273
else :
272
274
raise TypeError (
0 commit comments