π Geometric Computer Vision Library for Spatial AI
Python artificial-intelligencecomputer-visiondeep-learninghacktoberfestimage-processingmachine-learningneural-networkpythonpytorchroboticsspatial-ai
apply autopep
edgarriba14bef6fd11e2
diff --git a/Makefile b/Makefileindex 9f1d70dc6..7c1d6e79e 100644--- a/Makefile+++ b/Makefile@@ -15,7 +15,7 @@ lint: FORCEpython verify.py --check lintautopep8: FORCE- autopep8 --in-place --aggressive --recursive kornia/ test/+ autopep8 --in-place --aggressive --recursive kornia/ test/ examples/mypy: FORCEpython verify.py --check mypydiff --git a/docs/source/faqs.rst b/docs/source/faqs.rstindex 9202871bb..272329142 100644--- a/docs/source/faqs.rst+++ b/docs/source/faqs.rst@@ -13,6 +13,17 @@ How to ContributeSee `How to Contribute <http://docs.kornia.org/contriute/>`_+Kornia relation to Pytorch Geometry/Geometric+---------------------------------------------++This project started as a small differentiable geometric computer+vision package called `PyTorch Geometry <https://pypi.org/project/torchgeometry>`_+released during the PyTorch devcon 2018 (see the presented+`poster <https://drive.google.com/file/d/1xiao1Xj9WzjJ08YY_nYwsthE-wxfyfhG/view?usp=sharing>`_).+The project evolved to a more generic computer vision library and due to the naming+conflict between `Pytorch Geometric <https://pytorch-geometric.readthedocs.io/en/latest>`_+we decided to rename the whole package and focus to more generic vision functionalities.+Kornia relation to Other Computer Vision Projects-------------------------------------------------diff --git a/docs/source/installation.rst b/docs/source/installation.rstindex 96f4e8d83..351dc5480 100644--- a/docs/source/installation.rst+++ b/docs/source/installation.rst@@ -2,7 +2,7 @@ Installation============To install *Kornia*, you can do it in two different ways: using the provided `PyPi-<https://pypi.org/project/kornia//>`_ wheels or directly from source.+<https://pypi.org/project/kornia/>`_ wheels or directly from source... note::*Kornia only has as a dependency Pytorch.*diff --git a/kornia/feature/affine_shape.py b/kornia/feature/affine_shape.pyindex 6b4c34684..864ba38e0 100644--- a/kornia/feature/affine_shape.py+++ b/kornia/feature/affine_shape.py@@ -19,6 +19,7 @@ class PatchAffineShapeEstimator(nn.Module):Args:patch_size: int, default = 19eps: float, for safe division, default is 1e-10"""+def __init__(self, patch_size: int = 19, eps: float = 1e-10):super(PatchAffineShapeEstimator, self).__init__()self.patch_size: int = patch_size@@ -77,6 +78,7 @@ class LAFAffineShapeEstimator(nn.Module):Args:patch_size: int, default = 32"""+def __init__(self,patch_size: int = 32) -> None:super(LAFAffineShapeEstimator, self).__init__()diff --git a/kornia/feature/laf.py b/kornia/feature/laf.pyindex 1bb6b442b..b354889be 100644--- a/kornia/feature/laf.py+++ b/kornia/feature/laf.py@@ -145,7 +145,7 @@ def ellipse_to_laf(ells: torch.Tensor) -> torch.Tensor:"Got {}".format(ells.size()))ell_shape = torch.cat([torch.cat([ells[..., 2:3], ells[..., 3:4]], dim=2).unsqueeze(2),- torch.cat([ells[..., 3:4], ells[..., 4:5]], dim=2).unsqueeze(2)], dim=2).view(-1, 2, 2)+ torch.cat([ells[..., 3:4], ells[..., 4:5]], dim=2).unsqueeze(2)], dim=2).view(-1, 2, 2)out = torch.matrix_power(torch.cholesky(ell_shape, False), -1).view(B, N, 2, 2)out = torch.cat([out, ells[..., :2].view(B, N, 2, 1)], dim=3)return outdiff --git a/kornia/feature/orientation.py b/kornia/feature/orientation.pyindex cfaf6893f..6953c1e90 100644--- a/kornia/feature/orientation.py+++ b/kornia/feature/orientation.py@@ -14,6 +14,7 @@ from kornia.geometry import rad2degclass PassLAF(nn.Module):"""Dummy module to use instead of local feature orientation or affine shape estimator"""+def forward(self, laf: torch.Tensor, img: torch.Tensor) -> torch.Tensor: # type: ignore"""Args:@@ -33,6 +34,7 @@ class PatchDominantGradientOrientation(nn.Module):patch_size: int, default = 32num_angular_bins: int, default is 36eps: float, for safe division, and arctan, default is 1e-8"""+def __init__(self,patch_size: int = 32,num_angular_bins: int = 36, eps: float = 1e-8):@@ -106,6 +108,7 @@ class LAFOrienter(nn.Module):Args:patch_size: int, default = 32num_angular_bins: int, default is 36"""+def __init__(self,patch_size: int = 32,num_angular_bins: int = 36):diff --git a/kornia/feature/responses.py b/kornia/feature/responses.pyindex 2974e7e5b..e28577c63 100644--- a/kornia/feature/responses.py+++ b/kornia/feature/responses.py@@ -263,6 +263,7 @@ class CornerHarris(nn.Module):r"""nn.Module that calculates Harris cornersSee :func:`~kornia.feature.harris_response` for details."""+def __init__(self, k: Union[float, torch.Tensor],grads_mode='sobel') -> None:super(CornerHarris, self).__init__()@@ -287,6 +288,7 @@ class CornerGFTT(nn.Module):r"""nn.Module that calculates Shi-Tomasi cornersSee :func:`~kornia.feature.gfft_response` for details."""+def __init__(self, grads_mode='sobel') -> None:super(CornerGFTT, self).__init__()self.grads_mode: str = grads_mode@@ -305,6 +307,7 @@ class BlobHessian(nn.Module):r"""nn.Module that calculates Hessian blobsSee :func:`~kornia.feature.hessian_response` for details."""+def __init__(self, grads_mode='sobel') -> None:super(BlobHessian, self).__init__()self.grads_mode: str = grads_modediff --git a/kornia/feature/scale_space_detector.py b/kornia/feature/scale_space_detector.pyindex 89cb8e073..a118c05c6 100644--- a/kornia/feature/scale_space_detector.py+++ b/kornia/feature/scale_space_detector.py@@ -74,6 +74,7 @@ class ScaleSpaceDetector(nn.Module):aff_module: (nn.Module) for local feature affine shape estimation. Default is :class:`~kornia.feature.PassLAF`,which does nothing. See :class:`~kornia.feature.LAFAffineShapeEstimator` for details."""+def __init__(self,num_features: int = 500,mr_size: float = 6.0,diff --git a/kornia/geometry/spatial_soft_argmax.py b/kornia/geometry/spatial_soft_argmax.pyindex 7ae26fae8..b022e95ac 100644--- a/kornia/geometry/spatial_soft_argmax.py+++ b/kornia/geometry/spatial_soft_argmax.py@@ -110,6 +110,7 @@ class ConvSoftArgmax2d(nn.Module):r"""Module that calculates soft argmax 2d per windowSee :func:`~kornia.geometry.conv_soft_argmax2d` for details."""+def __init__(self,kernel_size: Tuple[int, int] = (3, 3),stride: Tuple[int, int] = (1, 1),@@ -153,6 +154,7 @@ class ConvSoftArgmax3d(nn.Module):r"""Module that calculates soft argmax 3d per windowSee :func:`~kornia.geometry.conv_soft_argmax3d` for details."""+def __init__(self,kernel_size: Tuple[int, int, int] = (3, 3, 3),stride: Tuple[int, int, int] = (1, 1, 1),@@ -472,6 +474,7 @@ class SpatialSoftArgmax2d(nn.Module):See :func:`~kornia.contrib.spatial_soft_argmax2d` for details."""+def __init__(self,temperature: torch.Tensor = torch.tensor(1.0),normalized_coordinates: bool = True,diff --git a/test/geometry/test_spatial_softargmax.py b/test/geometry/test_spatial_softargmax.pyindex e5d2ab8e1..51d17aab4 100644--- a/test/geometry/test_spatial_softargmax.py+++ b/test/geometry/test_spatial_softargmax.py@@ -397,7 +397,7 @@ class TestConvSoftArgmax3d:normalized_coordinates=False,output_value=True)expected_val = torch.tensor([[[[[1., 0.],- [0., 1.]]]]])+ [0., 1.]]]]])expected_coord = torch.tensor([[[[[[0., 0.],[0., 0.]]],@@ -422,7 +422,7 @@ class TestConvSoftArgmax3d:normalized_coordinates=False,output_value=True)expected_val = torch.tensor([[[[[0.1214, 0.],- [0., 0.1214]]]]])+ [0., 0.1214]]]]])expected_coord = torch.tensor([[[[[[0., 0.],[0., 0.]]],@@ -447,7 +447,7 @@ class TestConvSoftArgmax3d:normalized_coordinates=True,output_value=True)expected_val = torch.tensor([[[[[1., 0.],- [0., 1.]]]]])+ [0., 1.]]]]])expected_coord = torch.tensor([[[[[[-1., -1.],[-1., -1.]]],@@ -472,7 +472,7 @@ class TestConvSoftArgmax3d:normalized_coordinates=True,output_value=True)expected_val = torch.tensor([[[[[0.1214, 0.],- [0., 0.1214]]]]])+ [0., 0.1214]]]]])expected_coord = torch.tensor([[[[[[-1., -1.],[-1., -1.]]],