示例#1
0
    def test_affine_shear(self, device, dtype):
        torch.manual_seed(0)
        shear = torch.rand(1, 2, device=device, dtype=dtype)
        input = torch.rand(1, 2, 3, 4, device=device, dtype=dtype)

        transform = kornia.Affine(shear=shear, device=device, dtype=dtype)
        actual = transform(input)
        expected = kornia.shear(input, shear)
        assert_close(actual, expected, atol=1e-4, rtol=1e-4)
示例#2
0
    def test_affine_shear(self, device):
        torch.manual_seed(0)
        shear = torch.rand(1, 2, device=device)
        input = torch.rand(1, 2, 3, 4, device=device)

        transform = kornia.Affine(shear=shear).to(device)
        actual = transform(input)
        expected = kornia.shear(input, shear)
        assert_allclose(actual, expected)
示例#3
0
def ShearY(x, v):
    batch_size = v.size(0)
    shear = torch.zeros((batch_size, 2), device=x.device)
    shear[:, 1] = v
    return kornia.shear(x, shear)
 def _transform(self, img: torch.Tensor,
                param: torch.Tensor) -> torch.Tensor:
     B, _, _, _ = img.shape
     translation = param
     return kornia.shear(img, translation.expand(B, 2))
示例#5
0
def shear_y(img: torch.Tensor, mag: torch.Tensor) -> torch.Tensor:
    mag = torch.stack([torch.zeros_like(mag), mag], dim=1)
    return kornia.shear(img, mag)