This is useful if you have to build a more complex transformation pipeline
This is useful if you have to build a more complex transformation pipeline
(e.g. in the case of segmentation tasks).
(e.g. in the case of segmentation tasks).
Most transformations accept both `PIL <https://pillow.readthedocs.io>`_
Most transformations accept both `PIL <https://pillow.readthedocs.io>`_ images
images and tensor images, although some transformations are :ref:`PIL-only
and tensor images, although some transformations are PIL-only and some are
<transforms_pil_only>` and some are :ref:`tensor-only
tensor-only. The :ref:`conversion_transforms` may be used to convert to and from
<transforms_tensor_only>`. The :ref:`conversion_transforms` may be used to
PIL images, or for converting dtypes and ranges.
convert to and from PIL images.
The transformations that accept tensor images also accept batches of tensor
The transformations that accept tensor images also accept batches of tensor
images. A Tensor Image is a tensor with ``(C, H, W)`` shape, where ``C`` is a
images. A Tensor Image is a tensor with ``(C, H, W)`` shape, where ``C`` is a
...
@@ -70,8 +69,10 @@ The following examples illustrate the use of the available transforms:
...
@@ -70,8 +69,10 @@ The following examples illustrate the use of the available transforms:
produce the same results.
produce the same results.
Scriptable transforms
Transforms scriptability
---------------------
------------------------
.. TODO: Add note about v2 scriptability (in next PR)
In order to script the transformations, please use ``torch.nn.Sequential`` instead of :class:`Compose`.
In order to script the transformations, please use ``torch.nn.Sequential`` instead of :class:`Compose`.
...
@@ -89,39 +90,36 @@ Make sure to use only scriptable transformations, i.e. that work with ``torch.Te
...
@@ -89,39 +90,36 @@ Make sure to use only scriptable transformations, i.e. that work with ``torch.Te
For any custom transformations to be used with ``torch.jit.script``, they should be derived from ``torch.nn.Module``.
For any custom transformations to be used with ``torch.jit.script``, they should be derived from ``torch.nn.Module``.
Compositions of transforms
Geometry
--------------------------
--------
.. autosummary::
.. autosummary::
:toctree: generated/
:toctree: generated/
:template: class.rst
:template: class.rst
Compose
Resize
RandomCrop
RandomResizedCrop
CenterCrop
FiveCrop
TenCrop
Pad
RandomAffine
RandomPerspective
RandomRotation
RandomHorizontalFlip
RandomVerticalFlip
Transforms on PIL Image and torch.\*Tensor
Color
------------------------------------------
-----
.. autosummary::
.. autosummary::
:toctree: generated/
:toctree: generated/
:template: class.rst
:template: class.rst
CenterCrop
ColorJitter
ColorJitter
FiveCrop
Grayscale
Grayscale
Pad
RandomAffine
RandomApply
RandomCrop
RandomGrayscale
RandomGrayscale
RandomHorizontalFlip
RandomPerspective
RandomResizedCrop
RandomRotation
RandomVerticalFlip
Resize
TenCrop
GaussianBlur
GaussianBlur
RandomInvert
RandomInvert
RandomPosterize
RandomPosterize
...
@@ -130,23 +128,20 @@ Transforms on PIL Image and torch.\*Tensor
...
@@ -130,23 +128,20 @@ Transforms on PIL Image and torch.\*Tensor
RandomAutocontrast
RandomAutocontrast
RandomEqualize
RandomEqualize
Composition
.. _transforms_pil_only:
-----------
Transforms on PIL Image only
----------------------------
.. autosummary::
.. autosummary::
:toctree: generated/
:toctree: generated/
:template: class.rst
:template: class.rst
Compose
RandomApply
RandomChoice
RandomChoice
RandomOrder
RandomOrder
.. _transforms_tensor_only:
Miscellaneous
-------------
Transforms on torch.\*Tensor only
---------------------------------
.. autosummary::
.. autosummary::
:toctree: generated/
:toctree: generated/
...
@@ -155,12 +150,12 @@ Transforms on torch.\*Tensor only
...
@@ -155,12 +150,12 @@ Transforms on torch.\*Tensor only
LinearTransformation
LinearTransformation
Normalize
Normalize
RandomErasing
RandomErasing
ConvertImageDtype
Lambda
.. _conversion_transforms:
.. _conversion_transforms:
Conversion Transforms
Conversion
---------------------
----------
.. autosummary::
.. autosummary::
:toctree: generated/
:toctree: generated/
...
@@ -169,20 +164,10 @@ Conversion Transforms
...
@@ -169,20 +164,10 @@ Conversion Transforms
ToPILImage
ToPILImage
ToTensor
ToTensor
PILToTensor
PILToTensor
ConvertImageDtype
Auto-Augmentation
Generic Transforms
-----------------
------------------
.. autosummary::
:toctree: generated/
:template: class.rst
Lambda
Automatic Augmentation Transforms
---------------------------------
`AutoAugment <https://arxiv.org/pdf/1805.09501.pdf>`_ is a common Data Augmentation technique that can improve the accuracy of Image Classification models.
`AutoAugment <https://arxiv.org/pdf/1805.09501.pdf>`_ is a common Data Augmentation technique that can improve the accuracy of Image Classification models.
Though the data augmentation policies are directly linked to their trained dataset, empirical studies show that
Though the data augmentation policies are directly linked to their trained dataset, empirical studies show that