Skip to content

🐍 Geometric Computer Vision Library for Spatial AI

remove unnecesary if statement

dvd4219177ca11cef
diff --git a/kornia/augmentation/augmentations.py b/kornia/augmentation/augmentations.py
index d78a27c24..7b5ccede6 100644
--- a/kornia/augmentation/augmentations.py
+++ b/kornia/augmentation/augmentations.py
@@ -67,23 +67,18 @@ def random_hflip(input: torch.Tensor, p: float = 0.5, return_transformation: boo
trans_mat: torch.Tensor = torch.eye(3, device=device, dtype=dtype).expand(input.shape[0], -1, -1)
- if input[to_flip].nelement() != 0:
-
- flipped[to_flip] = hflip(input[to_flip])
- flipped.squeeze_()
-
- if return_transformation:
+ flipped[to_flip] = hflip(input[to_flip])
+ flipped.squeeze_()
- w: int = input.shape[-2]
- flip_mat: torch.Tensor = torch.tensor([[-1, 0, w],
- [0, 1, 0],
- [0, 0, 0]])
+ if return_transformation:
- trans_mat[to_flip] = flip_mat.to(device).to(dtype)
+ w: int = input.shape[-2]
+ flip_mat: torch.Tensor = torch.tensor([[-1, 0, w],
+ [0, 1, 0],
+ [0, 0, 0]])
- return flipped, trans_mat
+ trans_mat[to_flip] = flip_mat.to(device).to(dtype)
- return flipped
+ return flipped, trans_mat
- flipped.squeeze_()
- return (flipped, trans_mat) if return_transformation else flipped
+ return flipped