@@ -337,6 +337,9 @@ def _affine_bounding_box_xyxy(
337337 center : Optional [List [float ]] = None ,
338338 expand : bool = False ,
339339) -> Tuple [torch .Tensor , Tuple [int , int ]]:
340+ if bounding_box .numel () == 0 :
341+ return bounding_box , spatial_size
342+
340343 angle , translate , shear , center = _affine_parse_args (
341344 angle , translate , scale , shear , InterpolationMode .NEAREST , center
342345 )
@@ -1013,6 +1016,9 @@ def perspective_bounding_box(
10131016 endpoints : Optional [List [List [int ]]],
10141017 coefficients : Optional [List [float ]] = None ,
10151018) -> torch .Tensor :
1019+ if bounding_box .numel () == 0 :
1020+ return bounding_box
1021+
10161022 perspective_coeffs = _perspective_coefficients (startpoints , endpoints , coefficients )
10171023
10181024 original_shape = bounding_box .shape
@@ -1203,6 +1209,9 @@ def elastic_bounding_box(
12031209 format : features .BoundingBoxFormat ,
12041210 displacement : torch .Tensor ,
12051211) -> torch .Tensor :
1212+ if bounding_box .numel () == 0 :
1213+ return bounding_box
1214+
12061215 # TODO: add in docstring about approximation we are doing for grid inversion
12071216 displacement = displacement .to (bounding_box .device )
12081217
0 commit comments