Skip to content

🐍 Geometric Computer Vision Library for Spatial AI

link tutorials to docstrings (#1150)

Edgar Riba071839baae6a
diff --git a/docs/source/references.bib b/docs/source/references.bib
index 448a53acb..73cba759f 100644
--- a/docs/source/references.bib
+++ b/docs/source/references.bib
@@ -85,3 +85,12 @@
year={2003},
pages={958-963}
}
+
+@misc{lin2021patch,
+ title={Patch AutoAugment},
+ author={Shiqi Lin and Tao Yu and Ruoyu Feng and Zhibo Chen},
+ year={2021},
+ eprint={2103.11099},
+ archivePrefix={arXiv},
+ primaryClass={cs.CV}
+}
diff --git a/kornia/augmentation/augmentation.py b/kornia/augmentation/augmentation.py
index 5a4511fb7..562769402 100644
--- a/kornia/augmentation/augmentation.py
+++ b/kornia/augmentation/augmentation.py
@@ -68,10 +68,8 @@ class RandomHorizontalFlip(GeometricAugmentationBase2D):
- Input: :math:`(C, H, W)` or :math:`(B, C, H, W)`, Optional: :math:`(B, 3, 3)`
- Output: :math:`(B, C, H, W)`
- Note:
- Input tensor must be float and normalized into [0, 1] for the best differentiability support.
- Additionally, this function accepts another transformation tensor (:math:`(B, 3, 3)`), then the
- applied transformation will be merged int to the input transformation tensor and returned.
+ .. note::
+ This function internally uses :func:`kornia.geometry.transform.hflip`.
Examples:
>>> input = torch.tensor([[[[0., 0., 0.],
@@ -123,10 +121,8 @@ class RandomVerticalFlip(GeometricAugmentationBase2D):
- Input: :math:`(C, H, W)` or :math:`(B, C, H, W)`, Optional: :math:`(B, 3, 3)`
- Output: :math:`(B, C, H, W)`
- Note:
- Input tensor must be float and normalized into [0, 1] for the best differentiability support.
- Additionally, this function accepts another transformation tensor (:math:`(B, 3, 3)`), then the
- applied transformation will be merged int to the input transformation tensor and returned.
+ .. note::
+ This function internally uses :func:`kornia.geometry.transform.vflip`.
Examples:
>>> input = torch.tensor([[[[0., 0., 0.],
@@ -182,10 +178,10 @@ class ColorJitter(IntensityAugmentationBase2D):
- Input: :math:`(C, H, W)` or :math:`(B, C, H, W)`, Optional: :math:`(B, 3, 3)`
- Output: :math:`(B, C, H, W)`
- Note:
- Input tensor must be float and normalized into [0, 1] for the best differentiability support.
- Additionally, this function accepts another transformation tensor (:math:`(B, 3, 3)`), then the
- applied transformation will be merged int to the input transformation tensor and returned.
+ .. note::
+ This function internally uses :func:`kornia.enhance.adjust_brightness`,
+ :func:`kornia.enhance.adjust_contrast`. :func:`kornia.enhance.adjust_saturation`,
+ :func:`kornia.enhance.adjust_hue`.
Examples:
>>> rng = torch.manual_seed(0)
@@ -280,10 +276,8 @@ class RandomGrayscale(IntensityAugmentationBase2D):
- Input: :math:`(C, H, W)` or :math:`(B, C, H, W)`, Optional: :math:`(B, 3, 3)`
- Output: :math:`(B, C, H, W)`
- Note:
- Input tensor must be float and normalized into [0, 1] for the best differentiability support.
- Additionally, this function accepts another transformation tensor (:math:`(B, 3, 3)`), then the
- applied transformation will be merged int to the input transformation tensor and returned.
+ .. note::
+ This function internally uses :func:`kornia.color.rgb_to_grayscale`.
Examples:
>>> rng = torch.manual_seed(0)
@@ -432,10 +426,8 @@ class RandomPerspective(GeometricAugmentationBase2D):
- Input: :math:`(C, H, W)` or :math:`(B, C, H, W)`, Optional: :math:`(B, 3, 3)`
- Output: :math:`(B, C, H, W)`
- Note:
- Input tensor must be float and normalized into [0, 1] for the best differentiability support.
- Additionally, this function accepts another transformation tensor (:math:`(B, 3, 3)`), then the
- applied transformation will be merged int to the input transformation tensor and returned.
+ .. note::
+ This function internally uses :func:`kornia.geometry.transform.warp_pespective`.
Examples:
>>> rng = torch.manual_seed(0)
@@ -543,10 +535,8 @@ class RandomAffine(GeometricAugmentationBase2D):
- Input: :math:`(C, H, W)` or :math:`(B, C, H, W)`, Optional: :math:`(B, 3, 3)`
- Output: :math:`(B, C, H, W)`
- Note:
- Input tensor must be float and normalized into [0, 1] for the best differentiability support.
- Additionally, this function accepts another transformation tensor (:math:`(B, 3, 3)`), then the
- applied transformation will be merged int to the input transformation tensor and returned.
+ .. note::
+ This function internally uses :func:`kornia.geometry.transform.warp_affine`.
Examples:
>>> rng = torch.manual_seed(0)
@@ -726,10 +716,8 @@ class CenterCrop(GeometricAugmentationBase2D):
- Input: :math:`(C, H, W)` or :math:`(B, C, H, W)`, Optional: :math:`(B, 3, 3)`
- Output: :math:`(B, C, out_h, out_w)`
- Note:
- Input tensor must be float and normalized into [0, 1] for the best differentiability support.
- Additionally, this function accepts another transformation tensor (:math:`(B, 3, 3)`), then the
- applied transformation will be merged int to the input transformation tensor and returned.
+ .. note::
+ This function internally uses :func:`kornia.geometry.transform.crop_by_boxes`.
Examples:
>>> rng = torch.manual_seed(0)
@@ -855,10 +843,8 @@ class RandomRotation(GeometricAugmentationBase2D):
- Input: :math:`(C, H, W)` or :math:`(B, C, H, W)`, Optional: :math:`(B, 3, 3)`
- Output: :math:`(B, C, H, W)`
- Note:
- Input tensor must be float and normalized into [0, 1] for the best differentiability support.
- Additionally, this function accepts another transformation tensor (:math:`(B, 3, 3)`), then the
- applied transformation will be merged int to the input transformation tensor and returned.
+ .. note::
+ This function internally uses :func:`kornia.geometry.transform.affine`.
Examples:
>>> rng = torch.manual_seed(0)
@@ -1338,6 +1324,9 @@ class Normalize(IntensityAugmentationBase2D):
Return:
Normalised tensor with same size as input :math:`(*, C, H, W)`.
+ .. note::
+ This function internally uses :func:`kornia.enhance.normalize`.
+
Examples:
>>> norm = Normalize(mean=torch.zeros(4), std=torch.ones(4))
@@ -1396,6 +1385,9 @@ class Denormalize(IntensityAugmentationBase2D):
Return:
Denormalised tensor with same size as input :math:`(*, C, H, W)`.
+ .. note::
+ This function internally uses :func:`kornia.enhance.denormalize`.
+
Examples:
>>> norm = Denormalize(mean=torch.zeros(1, 4), std=torch.ones(1, 4))
@@ -1462,6 +1454,9 @@ class RandomMotionBlur(IntensityAugmentationBase2D):
Please set ``resample`` to ``'bilinear'`` if more meaningful gradients wanted.
+ .. note::
+ This function internally uses :func:`kornia.filters.motion_blur`.
+
Examples:
>>> rng = torch.manual_seed(0)
>>> input = torch.ones(1, 1, 5, 5)
@@ -1558,10 +1553,8 @@ class RandomSolarize(IntensityAugmentationBase2D):
- Input: :math:`(C, H, W)` or :math:`(B, C, H, W)`, Optional: :math:`(B, 3, 3)`
- Output: :math:`(B, C, H, W)`
- Note:
- Input tensor must be float and normalized into [0, 1] for the best differentiability support.
- Additionally, this function accepts another transformation tensor (:math:`(B, 3, 3)`), then the
- applied transformation will be merged int to the input transformation tensor and returned.
+ .. note::
+ This function internally uses :func:`kornia.enhance.solarize`.
Examples:
>>> rng = torch.manual_seed(0)
@@ -1636,10 +1629,8 @@ class RandomPosterize(IntensityAugmentationBase2D):
- Input: :math:`(C, H, W)` or :math:`(B, C, H, W)`, Optional: :math:`(B, 3, 3)`
- Output: :math:`(B, C, H, W)`
- Note:
- Input tensor must be float and normalized into [0, 1] for the best differentiability support.
- Additionally, this function accepts another transformation tensor (:math:`(B, 3, 3)`), then the
- applied transformation will be merged int to the input transformation tensor and returned.
+ .. note::
+ This function internally uses :func:`kornia.enhance.posterize`.
Examples:
>>> rng = torch.manual_seed(0)
@@ -1704,10 +1695,8 @@ class RandomSharpness(IntensityAugmentationBase2D):
- Input: :math:`(C, H, W)` or :math:`(B, C, H, W)`, Optional: :math:`(B, 3, 3)`
- Output: :math:`(B, C, H, W)`
- Note:
- Input tensor must be float and normalized into [0, 1] for the best differentiability support.
- Additionally, this function accepts another transformation tensor (:math:`(B, 3, 3)`), then the
- applied transformation will be merged int to the input transformation tensor and returned.
+ .. note::
+ This function internally uses :func:`kornia.enhance.sharpness`.
Examples:
>>> rng = torch.manual_seed(0)
@@ -1773,10 +1762,8 @@ class RandomEqualize(IntensityAugmentationBase2D):
- Input: :math:`(C, H, W)` or :math:`(B, C, H, W)`, Optional: :math:`(B, 3, 3)`
- Output: :math:`(B, C, H, W)`
- Note:
- Input tensor must be float and normalized into [0, 1] for the best differentiability support.
- Additionally, this function accepts another transformation tensor (:math:`(B, 3, 3)`), then the
- applied transformation will be merged int to the input transformation tensor and returned.
+ .. note::
+ This function internally uses :func:`kornia.enhance.equalize`.
Examples:
>>> rng = torch.manual_seed(0)
@@ -1825,10 +1812,8 @@ class RandomGaussianBlur(IntensityAugmentationBase2D):
- Input: :math:`(C, H, W)` or :math:`(B, C, H, W)`, Optional: :math:`(B, 3, 3)`
- Output: :math:`(B, C, H, W)`
- Note:
- Input tensor must be float and normalized into [0, 1] for the best differentiability support.
- Additionally, this function accepts another transformation tensor (:math:`(B, 3, 3)`), then the
- applied transformation will be merged int to the input transformation tensor and returned.
+ .. note::
+ This function internally uses :func:`kornia.filters.gaussian_blur2d`.
Examples:
>>> rng = torch.manual_seed(0)
@@ -1905,6 +1890,9 @@ class RandomInvert(IntensityAugmentationBase2D):
same_on_batch: apply the same transformation across the batch.
p: probability of applying the transformation.
+ .. note::
+ This function internally uses :func:`kornia.enhance.invert`.
+
Examples:
>>> rng = torch.manual_seed(0)
>>> img = torch.rand(1, 1, 5, 5)
@@ -2130,6 +2118,9 @@ class RandomElasticTransform(GeometricAugmentationBase2D):
same_on_batch: apply the same transformation across the batch.
p: probability of applying the transformation.
+ .. note::
+ This function internally uses :func:`kornia.geometry.transform.elastic_transform2d`.
+
Examples:
>>> img = torch.ones(1, 1, 2, 2)
>>> out = RandomElasticTransform()(img)
@@ -2189,14 +2180,14 @@ class RandomThinPlateSpline(GeometricAugmentationBase2D):
same_on_batch: apply the same transformation across the batch.
p: probability of applying the transformation.
+ .. note::
+ This function internally uses :func:`kornia.geometry.transform.warp_image_tps`.
+
Examples:
>>> img = torch.ones(1, 1, 2, 2)
>>> out = RandomThinPlateSpline()(img)
>>> out.shape
torch.Size([1, 1, 2, 2])
-
- .. note::
- This function internally uses :func:`warp_image_tps` to perform the warping.
"""
def __init__(
@@ -2246,6 +2237,9 @@ class RandomBoxBlur(GeometricAugmentationBase2D):
same_on_batch (bool): apply the same transformation across the batch.
p: probability of applying the transformation.
+ .. note::
+ This function internally uses :func:`kornia.filters.box_blur`.
+
Examples:
>>> img = torch.ones(1, 1, 24, 24)
>>> out = RandomBoxBlur((7, 7))(img)
diff --git a/kornia/augmentation/container/augment.py b/kornia/augmentation/container/augment.py
index 9b2593099..16ef41d87 100644
--- a/kornia/augmentation/container/augment.py
+++ b/kornia/augmentation/container/augment.py
@@ -48,10 +48,14 @@ class AugmentationSequential(ImageSequential):
If True, the whole list of args will be processed as a sequence in a random order.
If False, the whole list of args will be processed as a sequence in original order.
- Note:
+ .. note::
Mix augmentations (e.g. RandomMixUp, RandomCutMix) can only be working with "input" data key.
It is not clear how to deal with the conversions of masks, bounding boxes and keypoints.
+ .. note::
+ See a working example `here <https://kornia-tutorials.readthedocs.io/en/
+ latest/data_augmentation_sequential.html>`__.
+
Examples:
>>> import kornia
>>> input = torch.randn(2, 3, 5, 6)
diff --git a/kornia/augmentation/container/image.py b/kornia/augmentation/container/image.py
index 835acda4e..e4c9d591c 100644
--- a/kornia/augmentation/container/image.py
+++ b/kornia/augmentation/container/image.py
@@ -30,7 +30,7 @@ class ImageSequential(SequentialBase):
If True, the whole list of args will be processed as a sequence in a random order.
If False, the whole list of args will be processed as a sequence in original order.
- Note:
+ .. note::
Transformation matrix returned only considers the transformation applied in ``kornia.augmentation`` module.
Those transformations in ``kornia.geometry`` will not be taken into account.
diff --git a/kornia/augmentation/container/patch.py b/kornia/augmentation/container/patch.py
index 6b84b9ed9..3d0c4d9d5 100644
--- a/kornia/augmentation/container/patch.py
+++ b/kornia/augmentation/container/patch.py
@@ -24,12 +24,15 @@ class PatchParamItem(NamedTuple):
class PatchSequential(ImageSequential):
- r"""Container for performing patch-level image processing.
+ r"""Container for performing patch-level image data augmentation.
.. image:: https://kornia-tutorials.readthedocs.io/en/latest/_images/data_patch_sequential_5_1.png
PatchSequential breaks input images into patches by a given grid size, which will be resembled back
- afterwards. Different image processing and augmentation methods will be performed on each patch region.
+ afterwards.
+
+ Different image processing and augmentation methods will be performed on each patch region as
+ in :cite:`lin2021patch`.
Args:
*args: a list of processing modules.
@@ -42,7 +45,7 @@ class PatchSequential(ImageSequential):
to the batch form (False). If None, it will not overwrite the function-wise settings.
patchwise_apply: apply image processing args will be applied patch-wisely.
if ``True``, the number of args must be equal to grid number.
- if ``False``, the image processing args will be applied as a sequence to all patches. Default: False.
+ if ``False``, the image processing args will be applied as a sequence to all patches.
random_apply: randomly select a sublist (order agnostic) of args to
apply transformation.
If ``int`` (batchwise mode only), a fixed number of transformations will be selected.
@@ -53,10 +56,14 @@ class PatchSequential(ImageSequential):
If ``False`` and ``patchwise_apply``, the whole list of args will be processed in original order
location-wisely.
- Note:
+ .. note::
Transformation matrix returned only considers the transformation applied in ``kornia.augmentation`` module.
Those transformations in ``kornia.geometry`` will not be taken into account.
+ .. note::
+ See a working example `here <https://kornia-tutorials.readthedocs.io/en/
+ latest/data_patch_sequential.html>`__.
+
Examples:
>>> import kornia.augmentation as K
>>> input = torch.randn(2, 3, 224, 224)
diff --git a/kornia/color/gray.py b/kornia/color/gray.py
index 96bb930b4..10bcb8101 100644
--- a/kornia/color/gray.py
+++ b/kornia/color/gray.py
@@ -22,6 +22,10 @@ def rgb_to_grayscale(
Returns:
grayscale version of the image with shape :math:`(*,1,H,W)`.
+ .. note::
+ See a working example `here <https://kornia-tutorials.readthedocs.io/en/latest/
+ color_conversions.html>`__.
+
Example:
>>> input = torch.rand(2, 3, 4, 5)
>>> gray = rgb_to_grayscale(input) # 2x1x4x5
diff --git a/kornia/color/hsv.py b/kornia/color/hsv.py
index 48ade7ef6..43344246e 100644
--- a/kornia/color/hsv.py
+++ b/kornia/color/hsv.py
@@ -19,6 +19,10 @@ def rgb_to_hsv(image: torch.Tensor, eps: float = 1e-6) -> torch.Tensor:
HSV version of the image with shape of :math:`(*, 3, H, W)`.
The H channel values are in the range 0..2pi. S and V are in the range 0..1.
+ .. note::
+ See a working example `here <https://kornia-tutorials.readthedocs.io/en/latest/
+ color_conversions.html>`__.
+
Example:
>>> input = torch.rand(2, 3, 4, 5)
>>> output = rgb_to_hsv(input) # 2x3x4x5
diff --git a/kornia/color/rgb.py b/kornia/color/rgb.py
index 158834290..2c0398ccf 100644
--- a/kornia/color/rgb.py
+++ b/kornia/color/rgb.py
@@ -15,6 +15,10 @@ def rgb_to_bgr(image: torch.Tensor) -> torch.Tensor:
Returns:
BGR version of the image with shape of shape :math:`(*,3,H,W)`.
+ .. note::
+ See a working example `here <https://kornia-tutorials.readthedocs.io/en/latest/
+ hello_world_tutorial.html>`__.
+
Example:
>>> input = torch.rand(2, 3, 4, 5)
>>> output = rgb_to_bgr(input) # 2x3x4x5
@@ -37,6 +41,10 @@ def bgr_to_rgb(image: torch.Tensor) -> torch.Tensor:
Returns:
RGB version of the image with shape of shape :math:`(*,3,H,W)`.
+ .. note::
+ See a working example `here <https://kornia-tutorials.readthedocs.io/en/latest/
+ color_conversions.html>`__.
+
Example:
>>> input = torch.rand(2, 3, 4, 5)
>>> output = bgr_to_rgb(input) # 2x3x4x5
diff --git a/kornia/enhance/adjust.py b/kornia/enhance/adjust.py
index 2208d91bc..bd76fef69 100644
--- a/kornia/enhance/adjust.py
+++ b/kornia/enhance/adjust.py
@@ -82,6 +82,10 @@ def adjust_saturation(input: torch.Tensor, saturation_factor: Union[float, torch
Return:
Adjusted image in the shape of :math:`(*, 3, H, W)`.
+ .. note::
+ See a working example `here <https://kornia-tutorials.readthedocs.io/en/latest/
+ image_enhancement.html>`__.
+
Example:
>>> x = torch.ones(1, 3, 3, 3)
>>> adjust_saturation(x, 2.).shape
@@ -159,6 +163,10 @@ def adjust_hue(input: torch.Tensor, hue_factor: Union[float, torch.Tensor]) -> t
Return:
Adjusted image in the shape of :math:`(*, 3, H, W)`.
+ .. note::
+ See a working example `here <https://kornia-tutorials.readthedocs.io/en/latest/
+ image_enhancement.html>`__.
+
Example:
>>> x = torch.ones(1, 3, 2, 2)
>>> adjust_hue(x, 3.141516).shape
@@ -201,6 +209,10 @@ def adjust_gamma(
Return:
Adjusted image in the shape of :math:`(*, N)`.
+ .. note::
+ See a working example `here <https://kornia-tutorials.readthedocs.io/en/latest/
+ image_enhancement.html>`__.
+
Example:
>>> x = torch.ones(1, 1, 2, 2)
>>> adjust_gamma(x, 1.0, 2.0)
@@ -269,6 +281,10 @@ def adjust_contrast(input: torch.Tensor, contrast_factor: Union[float, torch.Ten
Return:
Adjusted image in the shape of :math:`(*, N)`.
+ .. note::
+ See a working example `here <https://kornia-tutorials.readthedocs.io/en/latest/
+ image_enhancement.html>`__.
+
Example:
>>> x = torch.ones(1, 1, 2, 2)
>>> adjust_contrast(x, 0.5)
@@ -324,6 +340,10 @@ def adjust_brightness(input: torch.Tensor, brightness_factor: Union[float, torch
Return:
Adjusted image in the shape of :math:`(*, N)`.
+ .. note::
+ See a working example `here <https://kornia-tutorials.readthedocs.io/en/latest/
+ image_enhancement.html>`__.
+
Example:
>>> x = torch.ones(1, 1, 2, 2)
>>> adjust_brightness(x, 1.)
diff --git a/kornia/enhance/zca.py b/kornia/enhance/zca.py
index ed6e04851..e0ad580b3 100644
--- a/kornia/enhance/zca.py
+++ b/kornia/enhance/zca.py
@@ -37,6 +37,9 @@ class ZCAWhitening(nn.Module):
- x: :math:`(D_0,...,D_{\text{dim}},...,D_N)` is a batch of N-D tensors.
- x_whiten: :math:`(D_0,...,D_{\text{dim}},...,D_N)` same shape as input.
+ .. note::
+ See a working example `here <https://colab.sandbox.google.com/github/kornia/tutorials/
+ blob/master/source/zca_whitening.ipynb>`__.
Examples:
>>> x = torch.tensor([[0,1],[1,0],[-1,0],[0,-1]], dtype = torch.float32)
@@ -178,6 +181,10 @@ def zca_mean(
A tuple containing the ZCA matrix and the mean vector. If return_inverse is set to True,
then it returns the inverse ZCA matrix, otherwise it returns None.
+ .. note::
+ See a working example `here <https://colab.sandbox.google.com/github/kornia/tutorials/
+ blob/master/source/zca_whitening.ipynb>`__.
+
Examples:
>>> x = torch.tensor([[0,1],[1,0],[-1,0],[0,-1]], dtype = torch.float32)
>>> transform_matrix, mean_vector,_ = zca_mean(x) # Returns transformation matrix and data mean
@@ -264,6 +271,10 @@ def zca_whiten(inp: torch.Tensor, dim: int = 0, unbiased: bool = True, eps: floa
Returns:
Whiten Input data.
+ .. note::
+ See a working example `here <https://colab.sandbox.google.com/github/kornia/tutorials/
+ blob/master/source/zca_whitening.ipynb>`__.
+
Examples:
>>> x = torch.tensor([[0,1],[1,0],[-1,0]], dtype = torch.float32)
>>> zca_whiten(x)
diff --git a/kornia/filters/blur.py b/kornia/filters/blur.py
index 7bdab4be5..a898b791f 100644
--- a/kornia/filters/blur.py
+++ b/kornia/filters/blur.py
@@ -35,6 +35,10 @@ def box_blur(
Returns:
the blurred tensor with shape :math:`(B,C,H,W)`.
+ .. note::
+ See a working example `here <https://kornia-tutorials.readthedocs.io/en/latest/
+ filtering_operators.html>`__.
+
Example:
>>> input = torch.rand(2, 4, 5, 7)
>>> output = box_blur(input, (3, 3)) # 2x4x5x7
diff --git a/kornia/filters/blur_pool.py b/kornia/filters/blur_pool.py
index fd3b1cf13..67ba8b64d 100644
--- a/kornia/filters/blur_pool.py
+++ b/kornia/filters/blur_pool.py
@@ -131,9 +131,13 @@ def blur_pool2d(input: torch.Tensor, kernel_size: int, stride: int = 2):
Returns:
the transformed tensor.
- Note:
+ .. note::
This function is tested against https://github.com/adobe/antialiased-cnns.
+ .. note::
+ See a working example `here <https://kornia-tutorials.readthedocs.io/en/latest/
+ filtering_operators.html>`__.
+
Examples:
>>> input = torch.eye(5)[None, None]
>>> blur_pool2d(input, 3)
@@ -160,9 +164,13 @@ def max_blur_pool2d(
max_pool_size: the kernel size for max pooling.
ceil_mode: should be true to match output size of conv2d with same kernel size.
- Note:
+ .. note::
This function is tested against https://github.com/adobe/antialiased-cnns.
+ .. note::
+ See a working example `here <https://kornia-tutorials.readthedocs.io/en/latest/
+ filtering_operators.html>`__.
+
Examples:
>>> input = torch.eye(5)[None, None]
>>> max_blur_pool2d(input, 3)
diff --git a/kornia/filters/canny.py b/kornia/filters/canny.py
index 59311b2de..785e85edb 100644
--- a/kornia/filters/canny.py
+++ b/kornia/filters/canny.py
@@ -39,6 +39,10 @@ def canny(
- the canny edge magnitudes map, shape of :math:`(B,1,H,W)`.
- the canny edge detection filtered by thresholds and hysteresis, shape of :math:`(B,1,H,W)`.
+ .. note::
+ See a working example `here <https://kornia-tutorials.readthedocs.io/en/latest/
+ canny.html>`__.
+
Example:
>>> input = torch.rand(5, 3, 4, 4)
>>> magnitude, edges = canny(input) # 5x3x4x4
diff --git a/kornia/filters/gaussian.py b/kornia/filters/gaussian.py
index ca70f9d19..f891065c1 100644
--- a/kornia/filters/gaussian.py
+++ b/kornia/filters/gaussian.py
@@ -28,6 +28,10 @@ def gaussian_blur2d(
Returns:
the blurred tensor with shape :math:`(B, C, H, W)`.
+ .. note::
+ See a working example `here <https://kornia-tutorials.readthedocs.io/en/latest/
+ gaussian_blur.html>`__.
+
Examples:
>>> input = torch.rand(2, 4, 5, 5)
>>> output = gaussian_blur2d(input, (3, 3), (1.5, 1.5))
diff --git a/kornia/filters/laplacian.py b/kornia/filters/laplacian.py
index b6150e1a6..2b94dd2ba 100644
--- a/kornia/filters/laplacian.py
+++ b/kornia/filters/laplacian.py
@@ -26,6 +26,10 @@ def laplacian(
Return:
the blurred image with shape :math:`(B, C, H, W)`.
+ .. note::
+ See a working example `here <https://kornia-tutorials.readthedocs.io/en/latest/
+ filtering_edges.html>`__.
+
Examples:
>>> input = torch.rand(2, 4, 5, 5)
>>> output = laplacian(input, 3)
diff --git a/kornia/filters/median.py b/kornia/filters/median.py
index ede4e9637..f338ea31c 100644
--- a/kornia/filters/median.py
+++ b/kornia/filters/median.py
@@ -25,6 +25,10 @@ def median_blur(input: torch.Tensor, kernel_size: Tuple[int, int]) -> torch.Tens
Returns:
the blurred input tensor with shape :math:`(B,C,H,W)`.
+ .. note::
+ See a working example `here <https://kornia-tutorials.readthedocs.io/en/latest/
+ filtering_operators.html>`__.
+
Example:
>>> input = torch.rand(2, 4, 5, 7)
>>> output = median_blur(input, (3, 3))
diff --git a/kornia/filters/sobel.py b/kornia/filters/sobel.py
index 0384c7e52..f1213e009 100644
--- a/kornia/filters/sobel.py
+++ b/kornia/filters/sobel.py
@@ -20,6 +20,10 @@ def spatial_gradient(input: torch.Tensor, mode: str = 'sobel', order: int = 1, n
Return:
the derivatives of the input feature map. with shape :math:`(B, C, 2, H, W)`.
+ .. note::
+ See a working example `here <https://kornia-tutorials.readthedocs.io/en/latest/
+ filtering_edges.html>`__.
+
Examples:
>>> input = torch.rand(1, 3, 4, 4)
>>> output = spatial_gradient(input) # 1x3x2x4x4
@@ -118,6 +122,10 @@ def sobel(input: torch.Tensor, normalized: bool = True, eps: float = 1e-6) -> to
Return:
the sobel edge gradient magnitudes map with shape :math:`(B,C,H,W)`.
+ .. note::
+ See a working example `here <https://kornia-tutorials.readthedocs.io/en/latest/
+ filtering_edges.html>`__.
+
Example:
>>> input = torch.rand(1, 3, 4, 4)
>>> output = sobel(input) # 1x3x4x4
diff --git a/kornia/filters/unsharp.py b/kornia/filters/unsharp.py
index deee5456e..18951381e 100644
--- a/kornia/filters/unsharp.py
+++ b/kornia/filters/unsharp.py
@@ -52,8 +52,11 @@ class UnsharpMask(nn.Module):
- Input: :math:`(B, C, H, W)`
- Output: :math:`(B, C, H, W)`
- Examples:
+ .. note::
+ See a working example `here <https://kornia-tutorials.readthedocs.io/en/latest/
+ unsharp_mask.html>`__.
+ Examples:
>>> input = torch.rand(2, 4, 5, 5)
>>> sharpen = UnsharpMask((3, 3), (1.5, 1.5))
>>> output = sharpen(input)
diff --git a/kornia/geometry/transform/affwarp.py b/kornia/geometry/transform/affwarp.py
index 15bc0cab8..bed641cd8 100644
--- a/kornia/geometry/transform/affwarp.py
+++ b/kornia/geometry/transform/affwarp.py
@@ -250,6 +250,10 @@ def rotate(
Returns:
The rotated tensor with shape as input.
+ .. note::
+ See a working example `here <https://kornia-tutorials.readthedocs.io/en/latest/
+ rotate_affine.html>`__.
+
Example:
>>> img = torch.rand(1, 3, 4, 4)
>>> angle = torch.tensor([90.])
diff --git a/kornia/geometry/transform/imgwarp.py b/kornia/geometry/transform/imgwarp.py
index 2727242a2..f0faa58fb 100644
--- a/kornia/geometry/transform/imgwarp.py
+++ b/kornia/geometry/transform/imgwarp.py
@@ -147,20 +147,20 @@ def warp_affine(
Returns:
the warped tensor with shape :math:`(B, C, H, W)`.
+ .. note::
+ This function is often used in conjuntion with :func:`get_rotation_matrix2d`,
+ :func:`get_shear_matrix2d`, :func:`get_affine_matrix2d`, :func:`invert_affine_transform`.
+
+ .. note::
+ See a working example `here <https://kornia-tutorials.readthedocs.io/en/latest/
+ rotate_affine.html>`__.
+
Example:
>>> img = torch.rand(1, 4, 5, 6)
>>> A = torch.eye(2, 3)[None]
>>> out = warp_affine(img, A, (4, 2), align_corners=True)
>>> print(out.shape)
torch.Size([1, 4, 4, 2])
-
- .. note::
- This function is often used in conjuntion with :func:`get_rotation_matrix2d`,
- :func:`get_shear_matrix2d`, :func:`get_affine_matrix2d`, :func:`invert_affine_transform`.
-
- .. note::
- See a working example `here <https://kornia.readthedocs.io/en/latest/
- tutorials/warp_affine.html>`__.
"""
if not isinstance(src, torch.Tensor):
raise TypeError("Input src type is not a torch.Tensor. Got {}".format(type(src)))
@@ -478,7 +478,7 @@ def remap(
[0., 0.]]]])
.. note::
- This function is often used in conjuntion with :func:`create_meshgrid`.
+ This function is often used in conjuntion with :func:`kornia.utils.create_meshgrid`.
"""
if not isinstance(tensor, torch.Tensor):
raise TypeError("Input tensor type is not a torch.Tensor. Got {}".format(type(tensor)))
diff --git a/kornia/losses/total_variation.py b/kornia/losses/total_variation.py
index ccc4be162..6f86f194c 100644
--- a/kornia/losses/total_variation.py
+++ b/kornia/losses/total_variation.py
@@ -15,6 +15,10 @@ def total_variation(img: torch.Tensor) -> torch.Tensor:
>>> total_variation(torch.ones(3, 4, 4))
tensor(0.)
+ .. note::
+ See a working example `here <https://kornia-tutorials.readthedocs.io/en/latest/
+ total_variation_denoising.html>`__.
+
Reference:
[1] https://en.wikipedia.org/wiki/Total_variation
"""
diff --git a/kornia/morphology/morphology.py b/kornia/morphology/morphology.py
index 86697d6f7..ee4a74cac 100644
--- a/kornia/morphology/morphology.py
+++ b/kornia/morphology/morphology.py
@@ -37,6 +37,10 @@ def dilation(
Returns:
Dilated image with shape :math:`(B, C, H, W)`.
+ .. note::
+ See a working example `here <https://kornia-tutorials.readthedocs.io/en/latest/
+ morphology_101.html>`__.
+
Example:
>>> tensor = torch.rand(1, 3, 5, 5)
>>> kernel = torch.ones(3, 3)
@@ -115,6 +119,10 @@ def erosion(
Returns:
Eroded image with shape :math:`(B, C, H, W)`.
+ .. note::
+ See a working example `here <https://kornia-tutorials.readthedocs.io/en/latest/
+ morphology_101.html>`__.
+
Example:
>>> tensor = torch.rand(1, 3, 5, 5)
>>> kernel = torch.ones(5, 5)
@@ -193,6 +201,10 @@ def opening(
Returns:
torch.Tensor: Opened image with shape :math:`(B, C, H, W)`.
+ .. note::
+ See a working example `here <https://kornia-tutorials.readthedocs.io/en/latest/
+ morphology_101.html>`__.
+
Example:
>>> tensor = torch.rand(1, 3, 5, 5)
>>> kernel = torch.ones(3, 3)
@@ -263,6 +275,10 @@ def closing(
Returns:
Closed image with shape :math:`(B, C, H, W)`.
+ .. note::
+ See a working example `here <https://kornia-tutorials.readthedocs.io/en/latest/
+ morphology_101.html>`__.
+
Example:
>>> tensor = torch.rand(1, 3, 5, 5)
>>> kernel = torch.ones(3, 3)
@@ -335,6 +351,10 @@ def gradient(
Returns:
Gradient image with shape :math:`(B, C, H, W)`.
+ .. note::
+ See a working example `here <https://kornia-tutorials.readthedocs.io/en/latest/
+ morphology_101.html>`__.
+
Example:
>>> tensor = torch.rand(1, 3, 5, 5)
>>> kernel = torch.ones(3, 3)
@@ -396,6 +416,10 @@ def top_hat(
Returns:
Top hat transformated image with shape :math:`(B, C, H, W)`.
+ .. note::
+ See a working example `here <https://kornia-tutorials.readthedocs.io/en/latest/
+ morphology_101.html>`__.
+
Example:
>>> tensor = torch.rand(1, 3, 5, 5)
>>> kernel = torch.ones(3, 3)
@@ -461,6 +485,10 @@ def bottom_hat(
Returns:
Top hat transformated image with shape :math:`(B, C, H, W)`.
+ .. note::
+ See a working example `here <https://kornia-tutorials.readthedocs.io/en/latest/
+ morphology_101.html>`__.
+
Example:
>>> tensor = torch.rand(1, 3, 5, 5)
>>> kernel = torch.ones(3, 3)