def test_jit(self): angle = torch.tensor([90.]) batch_size, channels, height, width = 2, 3, 64, 64 img = torch.ones(batch_size, channels, height, width) rot = kornia.Rotate(angle) rot_traced = torch.jit.trace(kornia.Rotate(angle), img) assert_allclose(rot(img), rot_traced(img))
def test_jit(self, device, dtype): angle = torch.tensor([90.0], device=device, dtype=dtype) batch_size, channels, height, width = 2, 3, 64, 64 img = torch.ones(batch_size, channels, height, width, device=device, dtype=dtype) rot = kornia.Rotate(angle) rot_traced = torch.jit.trace(kornia.Rotate(angle), img) assert_close(rot(img), rot_traced(img))
def test_angle90_batch2_broadcast(self, device, dtype): # prepare input data inp = torch.tensor([[ [1., 2.], [3., 4.], [5., 6.], [7., 8.], ]], device=device, dtype=dtype).repeat(2, 1, 1, 1) expected = torch.tensor([[[ [0., 0.], [4., 6.], [3., 5.], [0., 0.], ]], [[ [0., 0.], [4., 6.], [3., 5.], [0., 0.], ]]], device=device, dtype=dtype) # prepare transformation angle = torch.tensor([90.], device=device, dtype=dtype) transform = kornia.Rotate(angle, align_corners=True) assert_allclose(transform(inp), expected, atol=1e-4, rtol=1e-4)
def test_angle90(self, device, dtype): # prepare input data inp = torch.tensor([[[1.0, 2.0], [3.0, 4.0], [5.0, 6.0], [7.0, 8.0]]], device=device, dtype=dtype) expected = torch.tensor([[[0.0, 0.0], [4.0, 6.0], [3.0, 5.0], [0.0, 0.0]]], device=device, dtype=dtype) # prepare transformation angle = torch.tensor([90.0], device=device, dtype=dtype) transform = kornia.Rotate(angle, align_corners=True) assert_close(transform(inp), expected, atol=1e-4, rtol=1e-4)
def test_angle90(self, device): # prepare input data inp = torch.tensor([[ [1., 2.], [3., 4.], [5., 6.], [7., 8.], ]]).to(device) expected = torch.tensor([[ [0., 0.], [4., 6.], [3., 5.], [0., 0.], ]]).to(device) # prepare transformation angle = torch.tensor([90.]).to(device) transform = kornia.Rotate(angle, align_corners=True) assert_allclose(transform(inp), expected)
def test_angle90(self): # prepare input data inp = torch.tensor([[ [1., 2.], [3., 4.], [5., 6.], [7., 8.], ]]) expected = torch.tensor([[ [0., 0.], [4., 6.], [3., 5.], [0., 0.], ]]) # prepare transformation angle = torch.tensor([90.]) transform = kornia.Rotate(angle) assert_allclose(transform(inp), expected)
def test_angle90_batch2_broadcast(self, device): # prepare input data inp = torch.tensor([[ [1., 2.], [3., 4.], [5., 6.], [7., 8.], ]]).repeat(2, 1, 1, 1).to(device) expected = torch.tensor([[[ [0., 0.], [4., 6.], [3., 5.], [0., 0.], ]], [[ [0., 0.], [4., 6.], [3., 5.], [0., 0.], ]]]).to(device) # prepare transformation angle = torch.tensor([90.]).to(device) transform = kornia.Rotate(angle) assert_allclose(transform(inp), expected)