Skip to content

🐍 Geometric Computer Vision Library for Spatial AI

[Fix] Fixed RandomAffine translation range check (#917)

shijianjian39e86d59b62b
diff --git a/kornia/augmentation/random_generator/random_generator.py b/kornia/augmentation/random_generator/random_generator.py
index 49a8848f5..466abcd48 100644
--- a/kornia/augmentation/random_generator/random_generator.py
+++ b/kornia/augmentation/random_generator/random_generator.py
@@ -244,7 +244,8 @@ def random_affine_generator(
if translate is not None:
translate = translate.to(device=device, dtype=dtype)
- _joint_range_check(cast(torch.Tensor, translate), "translate")
+ assert 0. <= translate[0] <= 1. and 0. <= translate[1] <= 1. and translate.shape == torch.Size([2]), \
+ f"Expect translate contains two elements and ranges are in [0, 1]. Got {translate}."
max_dx: torch.Tensor = translate[0] * width
max_dy: torch.Tensor = translate[1] * height
translations = torch.stack([