예제 #1
0
    def test_tensor_bhw2(self, device):
        height, width = 3, 4
        grid = kornia.utils.create_meshgrid(
            height, width, normalized_coordinates=True).to(device)

        expected = kornia.utils.create_meshgrid(
            height, width, normalized_coordinates=False).to(device)

        grid_norm = kornia.denormalize_pixel_coordinates(grid, height, width)

        assert_allclose(grid_norm, expected)
예제 #2
0
    def test_jit(self, device):
        @torch.jit.script
        def op_script(img: torch.Tensor, height: int, width: int) -> torch.Tensor:
            return kornia.geometry.denormalize_pixel_coordinates(img, height, width)

        height, width = 3, 4
        grid = kornia.utils.create_meshgrid(height, width, normalized_coordinates=True).to(device)

        actual = op_script(grid, height, width)
        expected = kornia.denormalize_pixel_coordinates(grid, height, width)

        assert_close(actual, expected)
예제 #3
0
    def test_list(self, device):
        height, width = 3, 4
        grid = kornia.utils.create_meshgrid(
            height, width, normalized_coordinates=True).to(device)
        grid = grid.contiguous().view(-1, 2)

        expected = kornia.utils.create_meshgrid(
            height, width, normalized_coordinates=False).to(device)
        expected = expected.contiguous().view(-1, 2)

        grid_norm = kornia.denormalize_pixel_coordinates(grid, height, width)

        assert_allclose(grid_norm, expected)
예제 #4
0
 def op_script(input: torch.Tensor, height: int,
               width: int) -> torch.Tensor:
     return kornia.denormalize_pixel_coordinates(input, height, width)