π Geometric Computer Vision Library for Spatial AI
Python artificial-intelligencecomputer-visiondeep-learninghacktoberfestimage-processingmachine-learningneural-networkpythonpytorchroboticsspatial-ai
deprecate filter2D/filter3D (#1725)
Edgar Riba9156867947a2
diff --git a/kornia/filters/__tmp__.py b/kornia/__tmp__.pysimilarity index 100%rename from kornia/filters/__tmp__.pyrename to kornia/__tmp__.pydiff --git a/kornia/contrib/diamond_square.py b/kornia/contrib/diamond_square.pyindex cae8912a6..7f0753823 100644--- a/kornia/contrib/diamond_square.py+++ b/kornia/contrib/diamond_square.py@@ -6,7 +6,7 @@ import torchfrom torch import Tensorfrom kornia.enhance import normalize_min_max-from kornia.filters import filter2D+from kornia.filters import filter2dfrom kornia.testing import KORNIA_CHECK, KORNIA_CHECK_IS_TENSOR, KORNIA_CHECK_SHAPE# the default kernels for the diamond square@@ -122,13 +122,13 @@ def _one_diamond_one_square(# TODO(edgar): use kornia.filter2d# diamond- diamond_regions = filter2D(new_img, diamond_kernel)+ diamond_regions = filter2d(new_img, diamond_kernel)diamond_centers = (diamond_regions > 0).to(img.dtype)# TODO (anguelos) make sure diamond_regions*diamond_centers is needednew_img = new_img + (1 - random_scale) * diamond_regions * diamond_centers + diamond_centers * random_img# square- square_regions = filter2D(new_img, square_kernel) * pad_compencate+ square_regions = filter2d(new_img, square_kernel) * pad_compencatesquare_centers = (square_regions > 0).to(img.dtype)# TODO (anguelos) make sure square_centers*square_regions is neededdiff --git a/kornia/filters/__init__.py b/kornia/filters/__init__.pyindex 04d57a398..83891b0ed 100644--- a/kornia/filters/__init__.py+++ b/kornia/filters/__init__.py@@ -1,7 +1,7 @@from .blur import BoxBlur, box_blurfrom .blur_pool import BlurPool2D, MaxBlurPool2D, blur_pool2d, max_blur_pool2dfrom .canny import Canny, canny-from .filter import filter2d, filter2D, filter2d_separable, filter3d, filter3D+from .filter import filter2d, filter2d_separable, filter3dfrom .gaussian import GaussianBlur2d, gaussian_blur2dfrom .kernels import (gaussian,@@ -62,8 +62,6 @@ __all__ = ["filter2d","filter2d_separable","filter3d",- "filter2D",- "filter3D","GaussianBlur2d","Laplacian","SpatialGradient",diff --git a/kornia/filters/filter.py b/kornia/filters/filter.pyindex 40f7870be..6efe9fa75 100644--- a/kornia/filters/filter.py+++ b/kornia/filters/filter.py@@ -3,7 +3,6 @@ from typing import Listimport torchimport torch.nn.functional as F-from .__tmp__ import _deprecation_wrapperfrom .kernels import normalize_kernel2d@@ -31,8 +30,11 @@ def _compute_padding(kernel_size: List[int]) -> List[int]:def filter2d(- input: torch.Tensor, kernel: torch.Tensor, border_type: str = 'reflect', normalized: bool = False,- padding: str = 'same'+ input: torch.Tensor,+ kernel: torch.Tensor,+ border_type: str = 'reflect',+ normalized: bool = False,+ padding: str = 'same',) -> torch.Tensor:r"""Convolve a tensor with a 2d kernel.@@ -82,8 +84,10 @@ def filter2d(raise TypeError(f"Input border_type is not string. Got {type(border_type)}")if border_type not in ['constant', 'reflect', 'replicate', 'circular']:- raise ValueError(f"Invalid border type, we expect 'constant', \- 'reflect', 'replicate', 'circular'. Got:{border_type}")+ raise ValueError(+ f"Invalid border type, we expect 'constant', \+ 'reflect', 'replicate', 'circular'. Got:{border_type}"+ )if not isinstance(padding, str):raise TypeError(f"Input padding is not string. Got {type(padding)}")@@ -128,12 +132,14 @@ def filter2d(return out-def filter2d_separable(input: torch.Tensor,- kernel_x: torch.Tensor,- kernel_y: torch.Tensor,- border_type: str = 'reflect',- normalized: bool = False,- padding: str = 'same') -> torch.Tensor:+def filter2d_separable(+ input: torch.Tensor,+ kernel_x: torch.Tensor,+ kernel_y: torch.Tensor,+ border_type: str = 'reflect',+ normalized: bool = False,+ padding: str = 'same',+) -> torch.Tensor:r"""Convolve a tensor with two 1d kernels, in x and y directions.The function applies a given kernel to a tensor. The kernel is applied@@ -280,8 +286,3 @@ def filter3d(output = F.conv3d(input_pad, tmp_kernel, groups=tmp_kernel.size(0), padding=0, stride=1)return output.view(b, c, d, h, w)---# for backward compatibility.-filter2D = _deprecation_wrapper(filter2d, 'filter2D')-filter3D = _deprecation_wrapper(filter3d, 'filter3D')