π Geometric Computer Vision Library for Spatial AI
Python artificial-intelligencecomputer-visiondeep-learninghacktoberfestimage-processingmachine-learningneural-networkpythonpytorchroboticsspatial-ai
create kornia.geometry.subpix (#610)
Edgar Riba7c7aae5f12fd
diff --git a/docs/source/geometry.homography.rst b/docs/source/geometry.homography.rstindex d14dd37a4..8c7015817 100644--- a/docs/source/geometry.homography.rst+++ b/docs/source/geometry.homography.rst@@ -3,6 +3,5 @@ kornia.geometry.homographyModule with useful functionalities for homographies manipulation.-.. automodule:: kornia.geometry.homography:members:diff --git a/docs/source/geometry.rst b/docs/source/geometry.rstindex d4a715522..b006b1cc7 100644--- a/docs/source/geometry.rst+++ b/docs/source/geometry.rst@@ -12,24 +12,6 @@ kornia.geometrygeometry.epipolargeometry.homographygeometry.linalg+ geometry.subpixgeometry.transformgeometry.warp--Coordinates Subpixel-----------------------.. autofunction:: spatial_soft_argmax2d-.. autofunction:: conv_soft_argmax2d-.. autofunction:: conv_soft_argmax3d-.. autofunction:: conv_quad_interp3d-.. autofunction:: spatial_softmax2d-.. autofunction:: spatial_expectation2d-.. autofunction:: render_gaussian2d--Module---------.. autoclass:: SpatialSoftArgmax2d-.. autoclass:: ConvSoftArgmax2d-.. autoclass:: ConvSoftArgmax3d-.. autoclass:: ConvQuadInterp3ddiff --git a/docs/source/geometry.subpix.rst b/docs/source/geometry.subpix.rstnew file mode 100644index 000000000..ed990d165--- /dev/null+++ b/docs/source/geometry.subpix.rst@@ -0,0 +1,22 @@+kornia.geometry.subpix+======================++.. currentmodule:: kornia.geometry.subpix++Module with useful functionalities to extract coordinates sub=pixel accuracy.++.. autofunction:: spatial_soft_argmax2d+.. autofunction:: conv_soft_argmax2d+.. autofunction:: conv_soft_argmax3d+.. autofunction:: conv_quad_interp3d+.. autofunction:: spatial_softmax2d+.. autofunction:: spatial_expectation2d+.. autofunction:: render_gaussian2d++Module+------++.. autoclass:: SpatialSoftArgmax2d+.. autoclass:: ConvSoftArgmax2d+.. autoclass:: ConvSoftArgmax3d+.. autoclass:: ConvQuadInterp3ddiff --git a/kornia/geometry/__init__.py b/kornia/geometry/__init__.pyindex ab3384430..adbd7c690 100644--- a/kornia/geometry/__init__.py+++ b/kornia/geometry/__init__.py@@ -4,7 +4,6 @@ from kornia.geometry.linalg import *from kornia.geometry.transform import *from kornia.geometry.warp import *from kornia.geometry.depth import *-from kornia.geometry.dsnt import *-from kornia.geometry.spatial_soft_argmax import *+from kornia.geometry.subpix import *from kornia.geometry.epipolar import *from kornia.geometry.homography import *diff --git a/kornia/geometry/subpix/__init__.py b/kornia/geometry/subpix/__init__.pynew file mode 100644index 000000000..a963a37e5--- /dev/null+++ b/kornia/geometry/subpix/__init__.py@@ -0,0 +1,2 @@+from .dsnt import *+from .spatial_soft_argmax import *diff --git a/kornia/geometry/dsnt.py b/kornia/geometry/subpix/dsnt.pysimilarity index 100%rename from kornia/geometry/dsnt.pyrename to kornia/geometry/subpix/dsnt.pydiff --git a/kornia/geometry/spatial_soft_argmax.py b/kornia/geometry/subpix/spatial_soft_argmax.pysimilarity index 98%rename from kornia/geometry/spatial_soft_argmax.pyrename to kornia/geometry/subpix/spatial_soft_argmax.pyindex 21e8826ec..1be8f4305 100644--- a/kornia/geometry/spatial_soft_argmax.py+++ b/kornia/geometry/subpix/spatial_soft_argmax.py@@ -1,12 +1,13 @@+from typing import Tuple, Union+import torchimport torch.nn as nnimport torch.nn.functional as Fimport kornia-from kornia.geometry import dsnt+from kornia.geometry.subpix import dsntfrom kornia.utils import create_meshgrid, create_meshgrid3dfrom kornia.geometry import normalize_pixel_coordinates, normalize_pixel_coordinates3d-from typing import Tuple, Uniondef _get_window_grid_kernel2d(h: int, w: int,@@ -126,7 +127,7 @@ def _get_window_grid_kernel3d(d: int, h: int, w: int,class ConvSoftArgmax2d(nn.Module):r"""Module that calculates soft argmax 2d per window.- See :func:`~kornia.geometry.conv_soft_argmax2d` for details.+ See :func:`~kornia.geometry.subpix.conv_soft_argmax2d` for details."""def __init__(self,@@ -170,7 +171,7 @@ class ConvSoftArgmax2d(nn.Module):class ConvSoftArgmax3d(nn.Module):r"""Module that calculates soft argmax 3d per window.- See :func:`~kornia.geometry.conv_soft_argmax3d` for details.+ See :func:`~kornia.geometry.subpix.conv_soft_argmax3d` for details."""def __init__(self,@@ -519,7 +520,7 @@ def spatial_soft_argmax2d(class SpatialSoftArgmax2d(nn.Module):r"""Module that computes the Spatial Soft-Argmax 2D of a given heatmap.- See :func:`~kornia.contrib.spatial_soft_argmax2d` for details.+ See :func:`~kornia.geometry.subpix.spatial_soft_argmax2d` for details."""def __init__(self,@@ -625,7 +626,7 @@ def conv_quad_interp3d(input: torch.Tensor, strict_maxima_bonus: float = 10.0, eclass ConvQuadInterp3d(nn.Module):r"""Module that calculates soft argmax 3d per window- See :func:`~kornia.geometry.conv_quad_interp3d` for details.+ See :func:`~kornia.geometry.subpix.conv_quad_interp3d` for details."""def __init__(self,diff --git a/test/geometry/test_dsnt.py b/test/geometry/subpix/test_dsnt.pysimilarity index 100%rename from test/geometry/test_dsnt.pyrename to test/geometry/subpix/test_dsnt.pydiff --git a/test/geometry/test_spatial_softargmax.py b/test/geometry/subpix/test_spatial_softargmax.pysimilarity index 99%rename from test/geometry/test_spatial_softargmax.pyrename to test/geometry/subpix/test_spatial_softargmax.pyindex e95771989..9f1a0c029 100644--- a/test/geometry/test_spatial_softargmax.py+++ b/test/geometry/subpix/test_spatial_softargmax.py@@ -1,13 +1,13 @@import pytest-import kornia as kornia-import kornia.testing as utils # test utils-import torchfrom torch.nn.functional import mse_lossfrom torch.autograd import gradcheckfrom torch.testing import assert_allclose-from kornia.geometry.spatial_soft_argmax import _get_center_kernel2d, _get_center_kernel3d++import kornia as kornia+import kornia.testing as utils # test utils+from kornia.geometry.subpix.spatial_soft_argmax import _get_center_kernel2d, _get_center_kernel3dclass TestCenterKernel2d: