π Geometric Computer Vision Library for Spatial AI
Python artificial-intelligencecomputer-visiondeep-learninghacktoberfestimage-processingmachine-learningneural-networkpythonpytorchroboticsspatial-ai
improve augmentations docs and remove warnings (#681)
Edgar Riba843185fa7417
diff --git a/docs/source/augmentation.rst b/docs/source/augmentation.rstindex 785b04b4b..d9243ba9c 100644--- a/docs/source/augmentation.rst+++ b/docs/source/augmentation.rst@@ -70,8 +70,8 @@ Create your own transformation:output = K.warp_affine(input, transform, (H, W))return (output, transform)-Module-------+Module API+----------Kornia augmentation implementations can be easily used in a TorchVision style using `nn.Sequential`.@@ -130,6 +130,11 @@ Example for semantic segmentation using low-level randomness control:mask = self.jit(mask, jit_params)return input, mask+Transforms2D+------------++Set of operators to perform data augmentation on 2D image tensors.+.. autoclass:: CenterCrop.. autoclass:: ColorJitter.. autoclass:: Denormalize@@ -150,6 +155,12 @@ Example for semantic segmentation using low-level randomness control:.. autoclass:: RandomEqualize.. autoclass:: RandomMixUp.. autoclass:: RandomCutMix++Transforms3D+------------++Set of operators to perform data augmentation on 3D image tensors and volumetric data.+.. autoclass:: RandomDepthicalFlip3D.. autoclass:: RandomHorizontalFlip3D.. autoclass:: RandomVerticalFlip3Ddiff --git a/docs/source/contrib.rst b/docs/source/contrib.rstindex 11e9bc940..10de0a6d6 100644--- a/docs/source/contrib.rst+++ b/docs/source/contrib.rst@@ -11,5 +11,3 @@ Module.. autoclass:: ExtractTensorPatches.. autoclass:: MaxBlurPool2d--.. bibliography:: references.bibdiff --git a/docs/source/contribute.rst b/docs/source/contribute.rstindex 3f7709bd3..c3208a636 100644--- a/docs/source/contribute.rst+++ b/docs/source/contribute.rst@@ -3,10 +3,8 @@ Contribute to KorniaEveryone is welcomed to get involved with the project. There are different ways in how you can put your two cents:-1. Ask/Answer questions in the #kornia PyTorch Slack channel:+1. Ask/Answer questions in the #kornia tag in `PyTorch Discuss <https://discuss.pytorch.org/c/vision/kornia>`_:- - We suggest you to join the channel in order to get more involved to the PyTorch ecosystem.- - Send an email to [email protected] in order to get access.- Please, don't use GitHub issues for Q&A.2. Report bugs through GitHub issues:@@ -15,6 +13,8 @@ Everyone is welcomed to get involved with the project. There are different ways- In case you find an unreported bug, please open a new ticket.- Try to provide as much information as possible.+3. Join our slack workspace `[HERE] <https://join.slack.com/t/kornia/shared_invite/zt-csobk21g-CnydWe5fmvkcktIeRFGCEQ>`_+3. Fix a bug or develop a feature from the roadmap:- We will always have an open ticket showing the current roadmap.@@ -24,8 +24,8 @@ Everyone is welcomed to get involved with the project. There are different ways- Run the test framework locally and make sure all works as expected before sending a pull request.- Open a Pull Request, get the green light from the CI and get your code merged.-4. Donate resources to the project.+4. Donate resources to the project. Reach us !For more information about our development process, see our `Developers corner <https://github.com/arraiyopensource/kornia/blob/master/CONTRIBUTING.rst#developing-kornia>`_.-**Happy coding !**\ No newline at end of file+**Happy coding !**diff --git a/docs/source/feature.rst b/docs/source/feature.rstindex 3861e5814..9cdd09489 100644--- a/docs/source/feature.rst+++ b/docs/source/feature.rst@@ -81,5 +81,3 @@ Module:members: forward.. autoclass:: PatchDominantGradientOrientation:members: forward--.. bibliography:: references.bibdiff --git a/docs/source/index.rst b/docs/source/index.rstindex 36123d6f6..de68af325 100644--- a/docs/source/index.rst+++ b/docs/source/index.rst@@ -39,3 +39,5 @@ Indices and tables* :ref:`genindex`* :ref:`modindex`* :ref:`search`++.. bibliography:: references.bibdiff --git a/docs/source/introduction.rst b/docs/source/introduction.rstindex b27f0e7ba..7a1cccf43 100644--- a/docs/source/introduction.rst+++ b/docs/source/introduction.rst@@ -29,22 +29,57 @@ Hightlighted FeaturesAt a granular level, Kornia is a library that consists of the following components:-+----------------------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------+-| **Component** | **Description** |-+----------------------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------+-| `kornia <https://kornia.readthedocs.io/en/latest/index.html>`_ | a Differentiable Computer Vision library like OpenCV, with strong GPU support |-+----------------------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------+-| `kornia.color <https://kornia.readthedocs.io/en/latest/color.html>`_ | a set of routines to perform color space conversions |-+----------------------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------+-| `kornia.contrib <https://kornia.readthedocs.io/en/latest/contrib.html>`_ | a compilation of user contrib and experimental operators |-+----------------------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------+-| `kornia.feature <https://kornia.readthedocs.io/en/latest/feature.html>`_ | a module to perform feature detection |-+----------------------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------+-| `kornia.filters <https://kornia.readthedocs.io/en/latest/filters.html>`_ | a module to perform image filtering and edge detection |-+----------------------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------+-| `kornia.geometry <https://kornia.readthedocs.io/en/latest/geometry.html>`_ | a geometric computer vision library to perform image transformations, 3D linear algebra and conversions using different camera models |-+----------------------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------+-| `kornia.losses <https://kornia.readthedocs.io/en/latest/losses.html>`_ | a stack of loss functions to solve different vision tasks |-+----------------------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------+-| `kornia.utils <https://kornia.readthedocs.io/en/latest/utils.html>`_ | image to tensor utilities and metrics for vision problems |-+----------------------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------+++-----------------------------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------++| **Component** | **Description** |++-----------------------------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------++| `kornia <https://kornia.readthedocs.io/en/latest/index.html>`_ | a Differentiable Computer Vision library like OpenCV, with strong GPU support |++-----------------------------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------++| `kornia.augmentation <https://kornia.readthedocs.io/en/latest/augmentation.html>`_| a module to perform data augmentation in the GPU |++-----------------------------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------++| `kornia.color <https://kornia.readthedocs.io/en/latest/color.html>`_ | a set of routines to perform color space conversions |++-----------------------------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------++| `kornia.contrib <https://kornia.readthedocs.io/en/latest/contrib.html>`_ | a compilation of user contrib and experimental operators |++-----------------------------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------++| `kornia.enhance <https://kornia.readthedocs.io/en/latest/enhance.html>`_ | a module to perform normalization and intensity transformations |++-----------------------------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------++| `kornia.feature <https://kornia.readthedocs.io/en/latest/feature.html>`_ | a module to perform feature detection |++-----------------------------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------++| `kornia.filters <https://kornia.readthedocs.io/en/latest/filters.html>`_ | a module to perform image filtering and edge detection |++-----------------------------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------++| `kornia.geometry <https://kornia.readthedocs.io/en/latest/geometry.html>`_ | a geometric computer vision library to perform image transformations, 3D linear algebra and conversions using different camera models |++-----------------------------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------++| `kornia.losses <https://kornia.readthedocs.io/en/latest/losses.html>`_ | a stack of loss functions to solve different vision tasks |++-----------------------------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------++| `kornia.utils <https://kornia.readthedocs.io/en/latest/utils.html>`_ | image to tensor utilities and metrics for vision problems |++-----------------------------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------+++Cite us+-------++.. code-block:: bash++ @inproceedings{eriba2020kornia,+ author = {E. Riba, D. Mishkin, J. Shi, D. Ponsa, F. Moreno-Noguer and G. Bradski},+ title = {A survey on Kornia: an Open Source Differentiable Computer Vision Library for PyTorch},+ year = {2020},+ }++.. code-block:: bash++ @inproceedings{eriba2019kornia,+ author = {E. Riba, D. Mishkin, D. Ponsa, E. Rublee and G. Bradski},+ title = {Kornia: an Open Source Differentiable Computer Vision Library for PyTorch},+ booktitle = {Winter Conference on Applications of Computer Vision},+ year = {2020},+ url = {https://arxiv.org/pdf/1910.02190.pdf}+ }++.. code-block:: bash++ @misc{Arraiy2018,+ author = {E. Riba, M. Fathollahi, W. Chaney, E. Rublee and G. Bradski},+ title = {torchgeometry: when PyTorch meets geometry},+ booktitle = {PyTorch Developer Conference},+ year = {2018},+ url = {https://drive.google.com/file/d/1xiao1Xj9WzjJ08YY_nYwsthE-wxfyfhG/view?usp=sharing}+ }diff --git a/docs/source/references.bib b/docs/source/references.bibindex 3f3aab3c2..9993eaf74 100644--- a/docs/source/references.bib+++ b/docs/source/references.bib@@ -4,15 +4,32 @@booktitle={ICML},year={2019}}+@inproceedings{baumberg2000,title={Reliable feature matching across widely separated views},author={A. {Baumberg}},booktitle={CVPR},year={2000}}+@inproceedings{HardNet2017,title={Working hard to know your neighbor's margins: Local descriptor learning loss},author={Anastasiya Mishchuk and Dmytro Mishkin and Filip Radenovic and Jiri Matas},booktitle={Proceedings of NIPS},year={2017}}++@article{zhang2018mixup,+ title={mixup: Beyond Empirical Risk Minimization},+ author={Hongyi Zhang and Moustapha Cisse nad Yann N. Dauphin and David Lopez-Paz},+ journal={International Conference on Learning Representations},+ year={2018},+ url={https://openreview.net/forum?id=r1Ddp1-Rb},+}++@inproceedings{yun2019cutmix,+ title={CutMix: Regularization Strategy to Train Strong Classifiers with Localizable Features},+ author={Yun, Sangdoo and Han, Dongyoon and Oh, Seong Joon and Chun, Sanghyuk and Choe, Junsuk and Yoo, Youngjoon},+ booktitle = {International Conference on Computer Vision (ICCV)},+ year={2019},+}diff --git a/kornia/augmentation/augmentation.py b/kornia/augmentation/augmentation.pyindex 516697c07..9f57eff9a 100644--- a/kornia/augmentation/augmentation.py+++ b/kornia/augmentation/augmentation.py@@ -71,7 +71,8 @@ class AugmentationBase(nn.Module):class RandomHorizontalFlip(AugmentationBase):- r"""Horizontally flip a tensor image or a batch of tensor images randomly with a given probability.+ r"""Applies a random horizontal flip to a tensor image or a batch of tensor images randomly with a given probability.+Input should be a tensor of shape (C, H, W) or a batch of tensors :math:`(B, C, H, W)`.If Input is a tuple it is assumed that the first element contains the aforementioned tensors and the second,the corresponding transformation matrix that has been applied to them. In this case the module@@ -82,8 +83,8 @@ class RandomHorizontalFlip(AugmentationBase):p (float): probability of the image being flipped. Default value is 0.5return_transform (bool): if ``True`` return the matrix describing the transformation applied to eachinput tensor. If ``False`` and the input is a tuple the applied transformation- wont be concatenated- same_on_batch (bool): apply the same transformation across the batch. Default: False+ wont be concatenated.+ same_on_batch (bool): apply the same transformation across the batch. Default: False.Examples:>>> input = torch.tensor([[[[0., 0., 0.],@@ -121,7 +122,8 @@ class RandomHorizontalFlip(AugmentationBase):class RandomVerticalFlip(AugmentationBase):- r"""Vertically flip a tensor image or a batch of tensor images randomly with a given probability.+ r"""Applies a random vertical flip to a tensor image or a batch of tensor images randomly with a given probability.+Input should be a tensor of shape (C, H, W) or a batch of tensors :math:`(B, C, H, W)`.If Input is a tuple it is assumed that the first element contains the aforementioned tensors and the second,the corresponding transformation matrix that has been applied to them. In this case the module@@ -132,8 +134,8 @@ class RandomVerticalFlip(AugmentationBase):p (float): probability of the image being flipped. Default value is 0.5return_transform (bool): if ``True`` return the matrix describing the transformation applied to eachinput tensor. If ``False`` and the input is a tuple the applied transformation- wont be concatenated- same_on_batch (bool): apply the same transformation across the batch. Default: False+ wont be concatenated.+ same_on_batch (bool): apply the same transformation across the batch. Default: False.Examples:>>> input = torch.tensor([[[[0., 0., 0.],@@ -170,7 +172,8 @@ class RandomVerticalFlip(AugmentationBase):class ColorJitter(AugmentationBase):- r"""Change the brightness, contrast, saturation and hue randomly given tensor image or a batch of tensor images.+ r"""Applies a random transformation to the brightness, contrast, saturation and hue of a tensor image.+Input should be a tensor of shape (C, H, W) or a batch of tensors :math:`(B, C, H, W)`.Args:@@ -232,14 +235,14 @@ class ColorJitter(AugmentationBase):class RandomGrayscale(AugmentationBase):- r"""Random Grayscale transformation according to a probability p value+ r"""Applies random transformation to Grayscale according to a probability p value.Args:p (float): probability of the image to be transformed to grayscale. Default value is 0.1return_transform (bool): if ``True`` return the matrix describing the transformation applied to eachinput tensor. If ``False`` and the input is a tuple the applied transformation- wont be concatenated- same_on_batch (bool): apply the same transformation across the batch. Default: False+ wont be concatenated.+ same_on_batch (bool): apply the same transformation across the batch. Default: False.Examples:>>> rng = torch.manual_seed(0)@@ -279,8 +282,11 @@ class RandomGrayscale(AugmentationBase):class RandomErasing(AugmentationBase):- r"""- Erases a random selected rectangle for each image in the batch, putting the value to zero.+ r"""Erases a random rectangle of a tensor image according to a probability p value.++ The operator removes image parts and fills them with zero values at a selected rectangle+ for each of the images in the batch.+The rectangle will have an area equal to the original image area multiplied by a value uniformlysampled between the range [scale[0], scale[1]) and an aspect ratio sampledbetween [ratio[0], ratio[1])@@ -332,12 +338,12 @@ class RandomErasing(AugmentationBase):class RandomPerspective(AugmentationBase):- r"""Performs Perspective transformation of the given torch.Tensor randomly with a given probability.+ r"""Applies a random perspective transformation to an image tensor with a given probability.Args:- p (float): probability of the image being perspectively transformed. Default value is 0.5+ p (float): probability of the image being perspectively transformed. Default value is 0.5.distortion_scale(float): it controls the degree of distortion and ranges from 0 to 1. Default value is 0.5.- resample (int, str or kornia.Resample): Default: Resample.BILINEAR+ resample (int, str or kornia.Resample): Default: Resample.BILINEAR.return_transform (bool): if ``True`` return the matrix describing the transformationapplied to each. Default: False.same_on_batch (bool): apply the same transformation across the batch. Default: False@@ -393,7 +399,9 @@ class RandomPerspective(AugmentationBase):class RandomAffine(AugmentationBase):- r"""Random affine transformation of the image keeping center invariant.+ r"""Applies a random 2D affine transformation to a tensor image.++ The transformation is computed so that the image center is kept invariant.Args:degrees (float or tuple): Range of degrees to select from.@@ -490,7 +498,7 @@ class RandomAffine(AugmentationBase):class CenterCrop(AugmentationBase):- r"""Crops the given torch.Tensor at the center.+ r"""Crops a given image tensor at the center.Args:size (sequence or int): Desired output size of the crop. If size is an@@ -536,7 +544,8 @@ class CenterCrop(AugmentationBase):class RandomRotation(AugmentationBase):- r"""Rotate a tensor image or a batch of tensor images a random amount of degrees.+ r"""Applies a random rotation to a tensor image or a batch of tensor images given an amount of degrees.+Input should be a tensor of shape (C, H, W) or a batch of tensors :math:`(B, C, H, W)`.If Input is a tuple it is assumed that the first element contains the aforementioned tensors and the second,the corresponding transformation matrix that has been applied to them. In this case the module@@ -545,12 +554,12 @@ class RandomRotation(AugmentationBase):Args:degrees (sequence or float or tensor): range of degrees to select from. If degrees is a number the- range of degrees to select from will be (-degrees, +degrees)- interpolation (int, str or kornia.Resample): Default: Resample.BILINEAR+ range of degrees to select from will be (-degrees, +degrees).+ interpolation (int, str or kornia.Resample): Default: Resample.BILINEAR.return_transform (bool): if ``True`` return the matrix describing the transformation applied to eachinput tensor. If ``False`` and the input is a tuple the applied transformation- wont be concatenated- same_on_batch (bool): apply the same transformation across the batch. Default: False+ wont be concatenated.+ same_on_batch (bool): apply the same transformation across the batch. Default: False.align_corners(bool): interpolation flag. Default: False.Examples:@@ -605,7 +614,7 @@ class RandomRotation(AugmentationBase):class RandomCrop(AugmentationBase):- r"""Random Crop on given size.+ r"""Crops random patches of a tensor image on a given size.Args:size (tuple): Desired output size of the crop, like (h, w).@@ -702,17 +711,17 @@ class RandomCrop(AugmentationBase):class RandomResizedCrop(AugmentationBase):- r"""Random Crop on given size and resizing the cropped patch to another.+ r"""Crops random patches in an image tensor and resizes to a given size.Args:- size (Tuple[int, int]): expected output size of each edge- scale: range of size of the origin size cropped- ratio: range of aspect ratio of the origin aspect ratio cropped- resample (int, str or kornia.Resample): Default: Resample.BILINEAR+ size (Tuple[int, int]): expected output size of each edge.+ scale: range of size of the origin size cropped.+ ratio: range of aspect ratio of the origin aspect ratio cropped.+ resample (int, str or kornia.Resample): Default: Resample.BILINEAR.return_transform (bool): if ``True`` return the matrix describing the transformation applied to eachinput tensor. If ``False`` and the input is a tuple the applied transformation- wont be concatenated- same_on_batch (bool): apply the same transformation across the batch. Default: False+ wont be concatenated.+ same_on_batch (bool): apply the same transformation across the batch. Default: False.align_corners(bool): interpolation flag. Default: False.Example:@@ -768,7 +777,9 @@ class RandomResizedCrop(AugmentationBase):class RandomMotionBlur(AugmentationBase):- r"""Blurs a tensor using the motion filter. Same transformation happens across batches.+ r"""Blurs a tensor image or batch of tensor images using a motion filter.++ The same transformation can be applied across different batches.Args:kernel_size (int or Tuple[int, int]): motion kernel width and height (odd and positive).@@ -789,7 +800,7 @@ class RandomMotionBlur(AugmentationBase):- Input: :math:`(B, C, H, W)`- Output: :math:`(B, C, H, W)`- Examples::+ Examples:>>> rng = torch.manual_seed(0)>>> input = torch.rand(1, 1, 5, 5)>>> motion_blur = RandomMotionBlur(3, 35., 0.5)diff --git a/kornia/augmentation/augmentation3d.py b/kornia/augmentation/augmentation3d.pyindex 05b9657df..24dd7a223 100644--- a/kornia/augmentation/augmentation3d.py+++ b/kornia/augmentation/augmentation3d.py@@ -25,8 +25,8 @@ class AugmentationBase3D(AugmentationBase):class RandomHorizontalFlip3D(AugmentationBase3D):+ r"""Applies a random horizontal flip to a 3D image tensor with a given probability.- r"""Horizontally flip a tensor image or a batch of tensor images randomly with a given probability.Input should be a tensor of shape :math:`(C, D, H, W)` or a batch of tensors :math:`(*, C, D, H, W)`.If Input is a tuple it is assumed that the first element contains the aforementioned tensors and the second,the corresponding transformation matrix that has been applied to them. In this case the module@@ -34,11 +34,11 @@ class RandomHorizontalFlip3D(AugmentationBase3D):previous one. This is especially useful when using this functionality as part of an ``nn.Sequential`` module.Args:- p (float): probability of the image being flipped. Default value is 0.5+ p (float): probability of the image being flipped. Default value is 0.5.return_transform (bool): if ``True`` return the matrix describing the transformation applied to eachinput tensor. If ``False`` and the input is a tuple the applied transformation- wont be concatenated- same_on_batch (bool): apply the same transformation across the batch. Default: False+ wont be concatenated.+ same_on_batch (bool): apply the same transformation across the batch. Default: False.Examples:>>> x = torch.eye(3).repeat(3, 1, 1)@@ -81,8 +81,8 @@ class RandomHorizontalFlip3D(AugmentationBase3D):class RandomVerticalFlip3D(AugmentationBase3D):+ r"""Applies a random vertical flip to a 3D image tensor with a given probability.- r"""Vertically flip a tensor image or a batch of tensor images randomly with a given probability.Input should be a tensor of shape :math:`(C, D, H, W)` or a batch of tensors :math:`(*, C, D, H, W)`.If Input is a tuple it is assumed that the first element contains the aforementioned tensors and the second,the corresponding transformation matrix that has been applied to them. In this case the module@@ -90,11 +90,11 @@ class RandomVerticalFlip3D(AugmentationBase3D):previous one. This is especially useful when using this functionality as part of an ``nn.Sequential`` module.Args:- p (float): probability of the image being flipped. Default value is 0.5+ p (float): probability of the image being flipped. Default value is 0.5.return_transform (bool): if ``True`` return the matrix describing the transformation applied to eachinput tensor. If ``False`` and the input is a tuple the applied transformation- wont be concatenated- same_on_batch (bool): apply the same transformation across the batch. Default: False+ wont be concatenated.+ same_on_batch (bool): apply the same transformation across the batch. Default: False.Examples:>>> x = torch.eye(3).repeat(3, 1, 1)@@ -136,8 +136,8 @@ class RandomVerticalFlip3D(AugmentationBase3D):class RandomDepthicalFlip3D(AugmentationBase3D):+ r"""Applies a random flip along the depth axis of a 3D image tensor with a given probability.- r"""Depthically flip a tensor image or a batch of tensor images randomly with a given probability.Input should be a tensor of shape :math:`(C, D, H, W)` or a batch of tensors :math:`(*, C, D, H, W)`.If Input is a tuple it is assumed that the first element contains the aforementioned tensors and the second,the corresponding transformation matrix that has been applied to them. In this case the module@@ -145,11 +145,11 @@ class RandomDepthicalFlip3D(AugmentationBase3D):previous one. This is especially useful when using this functionality as part of an ``nn.Sequential`` module.Args:- p (float): probability of the image being flipped. Default value is 0.5+ p (float): probability of the image being flipped. Default value is 0.5.return_transform (bool): if ``True`` return the matrix describing the transformation applied to eachinput tensor. If ``False`` and the input is a tuple the applied transformation- wont be concatenated- same_on_batch (bool): apply the same transformation across the batch. Default: False+ wont be concatenated.+ same_on_batch (bool): apply the same transformation across the batch. Default: False.Examples:>>> x = torch.eye(3).repeat(3, 1, 1)@@ -192,7 +192,9 @@ class RandomDepthicalFlip3D(AugmentationBase3D):class RandomAffine3D(AugmentationBase3D):- r"""Random 3D affine transformation of the image keeping center invariant.+ r"""Applies a 3D affine transformation to a 3D image tensor with a given probability.++ The transformation is computed so that the center is kept invariant.Args:degrees (float or tuple or list): Range of yaw (x-axis), pitch (y-axis), roll (z-axis) to select from.@@ -220,10 +222,10 @@ class RandomAffine3D(AugmentationBase3D):will be applied.If shear is a tuple of 6 tuples, a shear to the i-th facet in the range (-shear[i, 0], shear[i, 1])will be applied.- resample (int, str or kornia.Resample): Default: Resample.BILINEAR+ resample (int, str or kornia.Resample): Default: Resample.BILINEAR.return_transform (bool): if ``True`` return the matrix describing the transformationapplied to each. Default: False.- same_on_batch (bool): apply the same transformation across the batch. Default: False+ same_on_batch (bool): apply the same transformation across the batch. Default: False.align_corners(bool): interpolation flag. Default: False.Examples:@@ -307,7 +309,8 @@ class RandomAffine3D(AugmentationBase3D):class RandomRotation3D(AugmentationBase3D):- r"""Rotate a tensor image or a batch of tensor images a random amount of degrees.+ r"""Applies a random rotation to a 3D tensor image or a batch of tensor images given an amount of degrees.+Input should be a tensor of shape (C, D, H, W) or a batch of tensors :math:`(B, C, D, H, W)`.If Input is a tuple it is assumed that the first element contains the aforementioned tensors and the second,the corresponding transformation matrix that has been applied to them. In this case the module@@ -326,8 +329,8 @@ class RandomRotation3D(AugmentationBase3D):interpolation (int, str or kornia.Resample): Default: Resample.BILINEARreturn_transform (bool): if ``True`` return the matrix describing the transformation applied to eachinput tensor. If ``False`` and the input is a tuple the applied transformation- wont be concatenated- same_on_batch (bool): apply the same transformation across the batch. Default: False+ wont be concatenated.+ same_on_batch (bool): apply the same transformation across the batch. Default: False.align_corners(bool): interpolation flag. Default: False.Examples:diff --git a/kornia/augmentation/mix_augmentation.py b/kornia/augmentation/mix_augmentation.pyindex 5969e12ee..c71f8340b 100644--- a/kornia/augmentation/mix_augmentation.py+++ b/kornia/augmentation/mix_augmentation.py@@ -14,17 +14,18 @@ from .utils import (class MixAugmentation(AugmentationBase):- r"""MixAugmentation base class for customized augmentation implementations. For any augmentation,- the implementation of "generate_parameters" and "apply_transform" are required while the- "compute_transformation" is only required when passing "return_transform" as True.+ r"""MixAugmentation base class for customized augmentation implementations.++ For any augmentation, the implementation of "generate_parameters" and "apply_transform"+ are required while the"compute_transformation" is only required when passing "return_transform"+ as True.In "apply_transform", both input and label tensors are required.Args:- return_transform (bool): if ``True`` return the matrix describing the geometric transformation applied to each- input tensor. If ``False`` and the input is a tuple the applied transformation- wont be concatenated.-+ return_transform (bool): if ``True`` return the matrix describing the geometric+ transformation applied to each input tensor. If ``False`` and the input is a tuple the+ applied transformation wont be concatenated."""def __init__(self):@@ -52,13 +53,20 @@ class MixAugmentation(AugmentationBase):class RandomMixUp(MixAugmentation):- r"""Implemention for `mixup: BEYOND EMPIRICAL RISK MINIMIZATION <https://arxiv.org/pdf/1710.09412.pdf>`.+ r"""Implemention for `mixup: BEYOND EMPIRICAL RISK MINIMIZATION` :cite:`zhang2018mixup`.The function returns (inputs, labels), in which the inputs is the tensor that contains the mixup imageswhile the labels is a :math:`(B, 3)` tensor that contains (label_batch, label_permuted_batch, lambda) for- each image. The implementation is on top of `https://github.com/hongyi-zhang/mixup/blob/master/cifar/utils.py`.+ each image.++ The implementation is on top of the following repository:+ `https://github.com/hongyi-zhang/mixup/blob/master/cifar/utils.py+ <https://github.com/hongyi-zhang/mixup/blob/master/cifar/utils.py>`_.+The loss and accuracy are computed as:- ```++ .. code-block:: python+def loss_mixup(y, logits):criterion = F.cross_entropyloss_a = criterion(logits, y[:, 0].long(), reduction='none')@@ -68,7 +76,6 @@ class RandomMixUp(MixAugmentation):def acc_mixup(y, logits):pred = torch.argmax(logits, dim=1).to(y.device)return (1 - y[:, 2]) * pred.eq(y[:, 0]).float() + y[:, 2] * pred.eq(y[:, 1]).float()- ```Args:p (float): probability for performing mixup. Default is 0.5.@@ -77,9 +84,8 @@ class RandomMixUp(MixAugmentation):This flag will not maintain permutation order. Default: False.Inputs:- Tuple[torch.Tensor, torch.Tensor]:- Input image tensors, shape of :math:`(B, C, H, W)`.- - Label: raw labels, shape of :math:`(B,)`.+ - Label: raw labels, shape of :math:`(B)`.Returns:Tuple[torch.Tensor, torch.Tensor]:@@ -129,15 +135,20 @@ class RandomMixUp(MixAugmentation):class RandomCutMix(MixAugmentation):- r"""Implemention for `CutMix: Regularization Strategy to Train Strong Classifiers with Localizable Features- <https://arxiv.org/pdf/1905.04899.pdf>`.+ r"""Implemention for `CutMix: Regularization Strategy to Train Strong Classifiers with+ Localizable Features` :cite:`yun2019cutmix`.The function returns (inputs, labels), in which the inputs is the tensor that contains the mixup images- while the labels is a :math:`(num_mixes, B, 3)` tensor that contains (label_permuted_batch, lambda)- for each cutmix. The implementation referred to `https://github.com/clovaai/CutMix-PyTorch`.+ while the labels is a :math:`(\text{num_mixes}, B, 3)` tensor that contains (label_permuted_batch, lambda)+ for each cutmix.++ The implementation referred to the following repository: `https://github.com/clovaai/CutMix-PyTorch+ <https://github.com/clovaai/CutMix-PyTorch>`_.++ The onehot label may be computed as:++ .. code-block:: python- The onehot label may be computed as :- ```def onehot(size, target):vec = torch.zeros(size, dtype=torch.float32)vec[target] = 1.@@ -150,7 +161,6 @@ class RandomCutMix(MixAugmentation):label_permuted_onehot = onehot(size, label_permuted_batch)lb_onehot = lb_onehot * lam + label_permuted_onehot * (1. - lam)return lb_onehot- ```Args:height (int): the width of the input image.@@ -165,9 +175,8 @@ class RandomCutMix(MixAugmentation):This flag will not maintain permutation order. Default: False.Inputs:- Tuple[torch.Tensor, torch.Tensor]:- Input image tensors, shape of :math:`(B, C, H, W)`.- - Raw labels, shape of :math:`(B,)`+ - Raw labels, shape of :math:`(B)`.Returns:Tuple[torch.Tensor, torch.Tensor]:diff --git a/kornia/geometry/transform/crop.py b/kornia/geometry/transform/crop.pyindex a6f2c0b75..233aac7ee 100644--- a/kornia/geometry/transform/crop.py+++ b/kornia/geometry/transform/crop.py@@ -11,7 +11,8 @@ __all__ = ["crop_by_boxes","center_crop","bbox_to_mask",- "infer_box_shape"+ "infer_box_shape",+ "validate_bboxes",]