π Geometric Computer Vision Library for Spatial AI
Python artificial-intelligencecomputer-visiondeep-learninghacktoberfestimage-processingmachine-learningneural-networkpythonpytorchroboticsspatial-ai
apply autopep8 formatting
edgarribaaa0993a8c9a1
diff --git a/test/test_homography_warper.py b/test/test_homography_warper.pyindex add849e32..0445eebea 100644--- a/test/test_homography_warper.py+++ b/test/test_homography_warper.py@@ -28,7 +28,7 @@ class TestHomographyWarper:@pytest.mark.parametrize("offset", [1, 3, 7])@pytest.mark.parametrize("shape", [- (4, 5), (2, 6), (4, 3), (5, 7),])+ (4, 5), (2, 6), (4, 3), (5, 7), ])def test_warp_grid_translation(self, shape, offset):# create input dataheight, width = shape@@ -38,7 +38,7 @@ class TestHomographyWarper:# instantiate warperwarper = tgm.HomographyWarper(height, width,- normalized_coordinates=False)+ normalized_coordinates=False)flow = warper.warp_grid(dst_homo_src)# the grid the src plus the offset should be equal to the flow@@ -49,7 +49,7 @@ class TestHomographyWarper:warper.grid[..., 1], flow[..., 1])@pytest.mark.parametrize("batch_shape", [- (1, 1, 4, 5), (2, 2, 4, 6), (3, 1, 5, 7),])+ (1, 1, 4, 5), (2, 2, 4, 6), (3, 1, 5, 7), ])def test_identity_resize(self, batch_shape):# create input databatch_size, channels, height, width = batch_shape@@ -71,14 +71,14 @@ class TestHomographyWarper:patch_src[..., -1, -1], patch_dst[..., -1, -1])@pytest.mark.parametrize("shape", [- (4, 5), (2, 6), (4, 3), (5, 7),])+ (4, 5), (2, 6), (4, 3), (5, 7), ])def test_translation(self, shape):# create input data- offset = 2. # in pixel+ offset = 2. # in pixelheight, width = shapepatch_src = torch.rand(1, 1, height, width)dst_homo_src = utils.create_eye_batch(batch_size=1, eye_size=3)- dst_homo_src[..., 0, 2] = offset / (width -1) # apply offset in x+ dst_homo_src[..., 0, 2] = offset / (width - 1) # apply offset in x# instantiate warper and from source to destinationwarper = tgm.HomographyWarper(height, width)@@ -86,7 +86,7 @@ class TestHomographyWarper:assert utils.check_equal_torch(patch_src[..., 1:], patch_dst[..., :-1])@pytest.mark.parametrize("batch_shape", [- (1, 1, 3, 5), (2, 2, 4, 3), (3, 1, 2, 3),])+ (1, 1, 3, 5), (2, 2, 4, 3), (3, 1, 2, 3), ])def test_rotation(self, batch_shape):# create input databatch_size, channels, height, width = batch_shape@@ -158,7 +158,7 @@ class TestHomographyWarper:@pytest.mark.parametrize("device_type", TEST_DEVICES)@pytest.mark.parametrize("batch_shape", [- (1, 1, 7, 5), (2, 3, 8, 5), (1, 1, 7, 16),])+ (1, 1, 7, 5), (2, 3, 8, 5), (1, 1, 7, 16), ])def test_gradcheck(self, batch_shape, device_type):# generate input datadevice = torch.device(device_type)diff --git a/torchgeometry/homography_warper.py b/torchgeometry/homography_warper.pyindex 5d0ebeaf4..b134e59cd 100644--- a/torchgeometry/homography_warper.py+++ b/torchgeometry/homography_warper.py@@ -15,11 +15,11 @@ __all__ = [# layer apiclass HomographyWarper(nn.Module):- """Warps patches by homographies.+ r"""Warps patches by homographies... math::- X_{dst} = H_{dst}^{src} * X_{src}+ X_{dst} = H_{src}^{\{dst\}} * X_{src}Args:height (int): The height of the image to warp.@@ -37,11 +37,11 @@ class HomographyWarper(nn.Module):self.padding_mode = padding_mode# create base grid to compute the flow- self.grid = create_meshgrid(height, width,- normalized_coordinates=normalized_coordinates)+ self.grid = create_meshgrid(+ height, width, normalized_coordinates=normalized_coordinates)def warp_grid(self, H):- """+ r""":param H: Homography or homographies (stacked) to transform all pointsin the grid.:returns: Tensor[1, Height, Width, 2] containing transformed points in@@ -57,7 +57,7 @@ class HomographyWarper(nn.Module):return flow.view(batch_size, self.height, self.width, 2) # NxHxWx2def forward(self, patch_src, dst_homo_src):- """Warps an image or tensor from source into reference frame.+ r"""Warps an image or tensor from source into reference frame.Args:patch_src (torch.Tensor): The image or tensor to warp.@@ -92,7 +92,7 @@ class HomographyWarper(nn.Module):def homography_warp(patch, dst_H_src, dsize, padding_mode='zeros'):- """+ r""".. note:: Functional API for :class:`torgeometry.HomographyWarper`Warps patches by homographies.