diff --git a/kornia/augmentation/_2d/geometric/crop.py b/kornia/augmentation/_2d/geometric/crop.py index 560156bc99..3146630c92 100644 --- a/kornia/augmentation/_2d/geometric/crop.py +++ b/kornia/augmentation/_2d/geometric/crop.py @@ -140,7 +140,8 @@ def precrop_padding( if padding is None: padding = self.compute_padding(input.shape) - input = pad(input, padding, value=flags["fill"], mode=flags["padding_mode"]) + if any(padding): + input = pad(input, padding, value=flags["fill"], mode=flags["padding_mode"]) return input diff --git a/kornia/geometry/transform/flips.py b/kornia/geometry/transform/flips.py index db81e48dc5..d0c66192a4 100644 --- a/kornia/geometry/transform/flips.py +++ b/kornia/geometry/transform/flips.py @@ -124,8 +124,7 @@ def hflip(input: Tensor) -> Tensor: Returns: The horizontally flipped image tensor. """ - w = input.shape[-1] - return input[..., torch.arange(w - 1, -1, -1, device=input.device)] + return input.flip(-1).contiguous() def vflip(input: Tensor) -> Tensor: @@ -141,5 +140,4 @@ def vflip(input: Tensor) -> Tensor: Returns: The vertically flipped image tensor. """ - h = input.shape[-2] - return input[..., torch.arange(h - 1, -1, -1, device=input.device), :] + return input.flip(-2).contiguous()