Skip to content
Merged
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
9 changes: 9 additions & 0 deletions torchvision/prototype/transforms/functional/_geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,9 @@ def _affine_bounding_box_xyxy(
center: Optional[List[float]] = None,
expand: bool = False,
) -> Tuple[torch.Tensor, Tuple[int, int]]:
if bounding_box.numel() == 0:
return bounding_box, spatial_size

angle, translate, shear, center = _affine_parse_args(
angle, translate, scale, shear, InterpolationMode.NEAREST, center
)
Expand Down Expand Up @@ -1013,6 +1016,9 @@ def perspective_bounding_box(
endpoints: Optional[List[List[int]]],
coefficients: Optional[List[float]] = None,
) -> torch.Tensor:
if bounding_box.numel() == 0:
return bounding_box

perspective_coeffs = _perspective_coefficients(startpoints, endpoints, coefficients)

original_shape = bounding_box.shape
Expand Down Expand Up @@ -1203,6 +1209,9 @@ def elastic_bounding_box(
format: features.BoundingBoxFormat,
displacement: torch.Tensor,
) -> torch.Tensor:
if bounding_box.numel() == 0:
return bounding_box

# TODO: add in docstring about approximation we are doing for grid inversion
displacement = displacement.to(bounding_box.device)

Expand Down