π Geometric Computer Vision Library for Spatial AI
Python artificial-intelligencecomputer-visiondeep-learninghacktoberfestimage-processingmachine-learningneural-networkpythonpytorchroboticsspatial-ai
refactor repo
edgarribaa53915a93eaa
diff --git a/dev_env.sh b/dev_env.shindex 57ff35bd8..ed1e5eefa 100755--- a/dev_env.sh+++ b/dev_env.sh@@ -20,7 +20,7 @@ if [[ -z "$DATA_DIR" ]] ; thendocker_data_volume="-v $(pwd):$(pwd)"fi-docker_command=nvidia-docker+docker_command=dockerrepo=${ARRAIY_REPO:=arraiy/torchgeometry}diff --git a/setup.py b/setup.pyindex a49274ccd..aed0b399a 100644--- a/setup.py+++ b/setup.py@@ -48,7 +48,7 @@ setup(tests_require=['pytest'],# Package info- packages=find_packages(exclude=('test', 'examples',)),+ packages=find_packages(exclude=('docs', 'test', 'examples',)),zip_safe=True,install_requires=requirements,diff --git a/test/test_transforms.py b/test/test_convertions.pysimilarity index 82%rename from test/test_transforms.pyrename to test/test_convertions.pyindex 69f4ee27f..d7de0728a 100644--- a/test/test_transforms.py+++ b/test/test_convertions.py@@ -2,7 +2,7 @@ import unittestimport numpy as npimport torch-import torchgeometry.transforms as tf+import torchgeometry as dgmfrom torch.autograd import gradcheckimport utils # test utils@@ -18,7 +18,7 @@ class Tester(unittest.TestCase):eye_batch = utils.create_eye_batch(batch_size, 4)# apply transform- rotation_matrix = tf.angle_axis_to_rotation_matrix(angle_axis)+ rotation_matrix = dgm.angle_axis_to_rotation_matrix(angle_axis)rotation_matrix_eye = torch.matmul(rotation_matrix, rotation_matrix.transpose(1, 2))@@ -29,7 +29,7 @@ class Tester(unittest.TestCase):angle_axis = np.random.rand(3)# apply transform- rotation_matrix = tf.angle_axis_to_rotation_matrix(angle_axis)+ rotation_matrix = dgm.angle_axis_to_rotation_matrix(angle_axis)rotation_matrix_eye = rotation_matrix.dot(rotation_matrix.T)self.assertTrue(check_equal_numpy(rotation_matrix_eye, np.eye(4)))@@ -41,10 +41,10 @@ class Tester(unittest.TestCase):angle_axis = utils.tensor_to_gradcheck_var(angle_axis) # to var# apply transform- rotation_matrix = tf.angle_axis_to_rotation_matrix(angle_axis)+ rotation_matrix = dgm.angle_axis_to_rotation_matrix(angle_axis)# evaluate function gradient- res = gradcheck(tf.angle_axis_to_rotation_matrix, (angle_axis,),+ res = gradcheck(dgm.angle_axis_to_rotation_matrix, (angle_axis,),raise_exception=True)self.assertTrue(res)@@ -55,7 +55,7 @@ class Tester(unittest.TestCase):rtvec = utils.tensor_to_gradcheck_var(rtvec) # to var# evaluate function gradient- res = gradcheck(tf.rtvec_to_pose, (rtvec,), raise_exception=True)+ res = gradcheck(dgm.rtvec_to_pose, (rtvec,), raise_exception=True)self.assertTrue(res)def test_rotation_matrix_to_angle_axis_torch(self):@@ -66,9 +66,10 @@ class Tester(unittest.TestCase):rvec = torch.tensor([1.50485376, -2.10737739, 0.7214174])self.assertTrue(check_equal_torch(- tf.rotation_matrix_to_angle_axis(rmat),+ dgm.rotation_matrix_to_angle_axis(rmat),rvec))+ @unittest.skip('')def test_rotation_matrix_to_angle_axis_gradcheck(self):print('test_rotation_matrix_to_angle_axis_gradcheck to be implemented :)') # noqaself.assertTrue(True)diff --git a/test/test_utils.py b/test/test_utils.pyindex 878de3977..8ddcebcfd 100644--- a/test/test_utils.py+++ b/test/test_utils.py@@ -9,14 +9,14 @@ class Tester(unittest.TestCase):def test_tensor_to_image(self):tensor = torch.ones(3, 4, 4)- image = dgm.utils.tensor_to_image(tensor)+ image = dgm.tensor_to_image(tensor)self.assertTrue(image.shape == (4, 4, 3))self.assertIsInstance(image, np.ndarray)def test_image_to_tensor(self):image = np.ones((4, 4, 3))- tensor = dgm.utils.image_to_tensor(image)+ tensor = dgm.image_to_tensor(image)self.assertTrue(tensor.shape == (3, 4, 4))self.assertIsInstance(tensor, torch.Tensor)diff --git a/torchgeometry/__init__.py b/torchgeometry/__init__.pyindex 0f4141ff9..e5121459d 100644--- a/torchgeometry/__init__.py+++ b/torchgeometry/__init__.py@@ -1,9 +1,8 @@from .functional import *+from .convertions import *+from .utils import *from .homography_warper import HomographyWarperfrom .depth_warper import DepthWarper-from torchgeometry import utils-from torchgeometry import transforms--__version__ = '0.0.1' # the current version of the lib+__version__ = '0.1.0' # the current version of the libdiff --git a/torchgeometry/transforms/functional.py b/torchgeometry/convertions.pysimilarity index 97%rename from torchgeometry/transforms/functional.pyrename to torchgeometry/convertions.pyindex 92d6318b9..355b0f9b9 100644--- a/torchgeometry/transforms/functional.py+++ b/torchgeometry/convertions.py@@ -2,6 +2,15 @@ import torchimport numpy as np+__all__ = [+ "angle_axis_to_rotation_matrix",+ "rotation_matrix_to_angle_axis",+ "rotation_matrix_to_quaternion",+ "quaternion_to_angle_axis",+ "rtvec_to_pose",+]++def angle_axis_to_rotation_matrix_numpy(angle_axis):"""Convert 3d vector of axis-angle rotation to 4x4 rotation matrixdiff --git a/torchgeometry/functional.py b/torchgeometry/functional.pyindex 7a68f14e5..0556fba22 100644--- a/torchgeometry/functional.py+++ b/torchgeometry/functional.py@@ -1,6 +1,6 @@import torch-from .transforms import rtvec_to_pose+from .convertions import rtvec_to_pose__all__ = [diff --git a/torchgeometry/transforms/__init__.py b/torchgeometry/transforms/__init__.pydeleted file mode 100644index 85557dad4..000000000--- a/torchgeometry/transforms/__init__.py+++ /dev/null@@ -1,8 +0,0 @@-from .functional import angle_axis_to_rotation_matrix, rtvec_to_pose-from .functional import rotation_matrix_to_angle_axis--__all__ = [- 'angle_axis_to_rotation_matrix',- 'rtvec_to_pose',- 'rotation_matrix_to_angle_axis'-]diff --git a/torchgeometry/utils/functional.py b/torchgeometry/utils.pysimilarity index 92%rename from torchgeometry/utils/functional.pyrename to torchgeometry/utils.pyindex b901b3bd3..d856545e6 100644--- a/torchgeometry/utils/functional.py+++ b/torchgeometry/utils.py@@ -1,5 +1,10 @@import torch+__all__ = [+ "tensor_to_image",+ "image_to_tensor",+]+def image_to_tensor(image):"""Converts a numpy image to a torch.Tensor image.diff --git a/torchgeometry/utils/__init__.py b/torchgeometry/utils/__init__.pydeleted file mode 100644index cccce87ac..000000000--- a/torchgeometry/utils/__init__.py+++ /dev/null@@ -1,6 +0,0 @@-from .functional import tensor_to_image, image_to_tensor--__all__ = [- 'tensor_to_image',- 'image_to_tensor',-]