π Geometric Computer Vision Library for Spatial AI
Python artificial-intelligencecomputer-visiondeep-learninghacktoberfestimage-processingmachine-learningneural-networkpythonpytorchroboticsspatial-ai
reorganize api, move main code to core package and expose to top level
edgarribaf506d0fafeeb
diff --git a/docs/source/core.rst b/docs/source/core.rstnew file mode 100644index 000000000..125b7a802--- /dev/null+++ b/docs/source/core.rst@@ -0,0 +1,13 @@+torchgeometry.core+==================++.. currentmodule:: torchgeometry.core++.. toctree::+ :maxdepth: 2++ geometric+ transformations+ pinhole+ conversions+ warpingdiff --git a/docs/source/index.rst b/docs/source/index.rstindex 48213caef..85e460210 100644--- a/docs/source/index.rst+++ b/docs/source/index.rst@@ -20,11 +20,7 @@ TGM focuses on Image and tensor warping functions such as::maxdepth: 2:caption: Package Reference- geometric- transformations- pinhole- conversions- warping+ coreimagelossescontribdiff --git a/mypy_files.txt b/mypy_files.txtindex 8067b8860..bcde574dc 100644--- a/mypy_files.txt+++ b/mypy_files.txt@@ -1,9 +1,9 @@+torchgeometry/core/homography_warper.pytorchgeometry/image/gaussian.pytorchgeometry/losses/ssim.pytorchgeometry/losses/dice.pytorchgeometry/losses/focal.pytorchgeometry/losses/tversky.pytorchgeometry/losses/depth_smooth.py-torchgeometry/homography_warper.pytorchgeometry/contrib/spatial_soft_argmax2d.pytorchgeometry/contrib/extract_patches.pydiff --git a/test/test_imgwarp.py b/test/test_imgwarp.pyindex d5f624c3b..ef15bdf9a 100644--- a/test/test_imgwarp.py+++ b/test/test_imgwarp.py@@ -162,13 +162,13 @@ def test_warp_perspective_crop(batch_size, device_type, channels):points_src, points_dst)# create points grid in normalized coordinates- grid_src_norm = tgm.create_meshgrid(src_h, src_w,- normalized_coordinates=True)+ grid_src_norm = tgm.utils.create_meshgrid(+ src_h, src_w, normalized_coordinates=True)grid_src_norm = grid_src_norm.repeat(batch_size, 1, 1, 1).to(device)# create points grid in pixel coordinates- grid_src_pix = tgm.create_meshgrid(src_h, src_w,- normalized_coordinates=False)+ grid_src_pix = tgm.utils.create_meshgrid(+ src_h, src_w, normalized_coordinates=False)grid_src_pix = grid_src_pix.repeat(batch_size, 1, 1, 1).to(device)src_norm_trans_src_pix = tgm.normal_transform_pixel(src_h, src_w).repeat(diff --git a/test/test_utils.py b/test/test_utils.pyindex b6f840222..f486fbfa7 100644--- a/test/test_utils.py+++ b/test/test_utils.py@@ -11,7 +11,7 @@ import utils # test utils[(4, 4), (1, 4, 4), (3, 4, 4), ])def test_tensor_to_image(batch_shape):tensor = torch.ones(batch_shape)- image = tgm.tensor_to_image(tensor)+ image = tgm.utils.tensor_to_image(tensor)assert image.shape[:2] == batch_shape[-2:]assert isinstance(image, np.ndarray)@@ -20,7 +20,7 @@ def test_tensor_to_image(batch_shape):[(4, 4), (4, 4, 1), (4, 4, 3), ])def test_image_to_tensor(batch_shape):image = np.ones(batch_shape)- tensor = tgm.image_to_tensor(image)+ tensor = tgm.utils.image_to_tensor(image)assert tensor.shape[-2:] == batch_shape[:2]assert isinstance(tensor, torch.Tensor)@@ -30,7 +30,8 @@ def test_create_meshgrid():normalized_coordinates = False# create the meshgrid and verify shape- grid = tgm.create_meshgrid(height, width, normalized_coordinates)+ grid = tgm.utils.create_meshgrid(+ height, width, normalized_coordinates)assert grid.shape == (1, height, width, 2)# check grid corner values@@ -45,11 +46,11 @@ def test_normalize_pixel_grid():height, width = 2, 4# create points grid- grid_norm = tgm.create_meshgrid(height, width,- normalized_coordinates=True)+ grid_norm = tgm.utils.create_meshgrid(+ height, width, normalized_coordinates=True)grid_norm = torch.unsqueeze(grid_norm, dim=0)- grid_pix = tgm.create_meshgrid(height, width,- normalized_coordinates=False)+ grid_pix = tgm.utils.create_meshgrid(+ height, width, normalized_coordinates=False)grid_pix = torch.unsqueeze(grid_pix, dim=0)# grid from pixel space to normalizeddiff --git a/torchgeometry/__init__.py b/torchgeometry/__init__.pyindex f2ffb8bce..73ab5755e 100644--- a/torchgeometry/__init__.py+++ b/torchgeometry/__init__.py@@ -1,14 +1,17 @@-from .homography_warper import HomographyWarper, homography_warp-from .depth_warper import DepthWarper, depth_warp-from .pinhole import *-from .conversions import *-from .utils import *-from .imgwarp import *-from .transformations import *-+from torchgeometry import corefrom torchgeometry import imagefrom torchgeometry import lossesfrom torchgeometry import contrib+from torchgeometry import utils++# Exposes ``torchgeometry.core`` package to top level+from .core.homography_warper import HomographyWarper, homography_warp+from .core.depth_warper import DepthWarper, depth_warp+from .core.pinhole import *+from .core.conversions import *+from .core.imgwarp import *+from .core.transformations import *+# TODO(edgar): move to a separated file__version__ = '0.1.2rc1' # the current version of the libdiff --git a/torchgeometry/core/__init__.py b/torchgeometry/core/__init__.pynew file mode 100644index 000000000..01976bdb3--- /dev/null+++ b/torchgeometry/core/__init__.py@@ -0,0 +1,6 @@+from .homography_warper import HomographyWarper, homography_warp+from .depth_warper import DepthWarper, depth_warp+from .pinhole import *+from .conversions import *+from .imgwarp import *+from .transformations import *diff --git a/torchgeometry/conversions.py b/torchgeometry/core/conversions.pysimilarity index 100%rename from torchgeometry/conversions.pyrename to torchgeometry/core/conversions.pydiff --git a/torchgeometry/depth_warper.py b/torchgeometry/core/depth_warper.pysimilarity index 100%rename from torchgeometry/depth_warper.pyrename to torchgeometry/core/depth_warper.pydiff --git a/torchgeometry/homography_warper.py b/torchgeometry/core/homography_warper.pysimilarity index 98%rename from torchgeometry/homography_warper.pyrename to torchgeometry/core/homography_warper.pyindex 574f63893..1f41fd0c4 100644--- a/torchgeometry/homography_warper.py+++ b/torchgeometry/core/homography_warper.py@@ -4,8 +4,8 @@ import torchimport torch.nn as nnimport torch.nn.functional as F-from .utils import create_meshgrid-from .conversions import transform_points+from torchgeometry.utils import create_meshgrid+from torchgeometry.core.conversions import transform_points__all__ = [diff --git a/torchgeometry/imgwarp.py b/torchgeometry/core/imgwarp.pysimilarity index 100%rename from torchgeometry/imgwarp.pyrename to torchgeometry/core/imgwarp.pydiff --git a/torchgeometry/pinhole.py b/torchgeometry/core/pinhole.pysimilarity index 100%rename from torchgeometry/pinhole.pyrename to torchgeometry/core/pinhole.pydiff --git a/torchgeometry/transformations.py b/torchgeometry/core/transformations.pysimilarity index 100%rename from torchgeometry/transformations.pyrename to torchgeometry/core/transformations.py