π Geometric Computer Vision Library for Spatial AI
Python artificial-intelligencecomputer-visiondeep-learninghacktoberfestimage-processingmachine-learningneural-networkpythonpytorchroboticsspatial-ai
fix input shape in get_rotation_matrix2d
edgarribaf4e6180365a5
diff --git a/test/test_imgwarp.py b/test/test_imgwarp.pyindex e02c1c8fc..4f2ca6710 100644--- a/test/test_imgwarp.py+++ b/test/test_imgwarp.py@@ -129,8 +129,8 @@ class Tester(unittest.TestCase):# generate input databatch_size = 1center_base = torch.zeros(batch_size, 2)- angle_base = torch.ones(batch_size, 1)- scale_base = torch.ones(batch_size, 1)+ angle_base = torch.ones(batch_size)+ scale_base = torch.ones(batch_size)# 90 deg rotationcenter = center_base@@ -169,8 +169,8 @@ class Tester(unittest.TestCase):# generate input databatch_size = 1center = torch.zeros(batch_size, 2)- angle = torch.ones(batch_size, 1)- scale = torch.ones(batch_size, 1)+ angle = torch.ones(batch_size)+ scale = torch.ones(batch_size)center = utils.tensor_to_gradcheck_var(center) # to varangle = utils.tensor_to_gradcheck_var(angle) # to vardiff --git a/torchgeometry/imgwarp.py b/torchgeometry/imgwarp.pyindex bcf0e6d18..7a92bae65 100644--- a/torchgeometry/imgwarp.py+++ b/torchgeometry/imgwarp.py@@ -303,11 +303,11 @@ def get_rotation_matrix2d(center, angle, scale):if not (len(center.shape) == 2 and center.shape[1] == 2):raise ValueError("Input center must be a Bx2 tensor. Got {}".format(center.shape))- if not (len(angle.shape) == 2 and angle.shape[1] == 1):- raise ValueError("Input angle must be a Bx1 tensor. Got {}"+ if not len(angle.shape) == 1:+ raise ValueError("Input angle must be a B tensor. Got {}".format(angle.shape))- if not (len(scale.shape) == 2 and scale.shape[1] == 1):- raise ValueError("Input scale must be a Bx1 tensor. Got {}"+ if not len(scale.shape) == 1:+ raise ValueError("Input scale must be a B tensor. Got {}".format(scale.shape))if not (center.shape[0] == angle.shape[0] == scale.shape[0]):raise ValueError("Inputs must have same batch size dimension. Got {}"@@ -318,7 +318,7 @@ def get_rotation_matrix2d(center, angle, scale):beta = torch.sin(angle_rad) * scale# unpack the center to x, y coordinates- x, y = torch.chunk(center, chunks=2, dim=1)+ x, y = center[..., 0], center[..., 1]# create output tensorbatch_size, _ = center.shape