Skip to content

Update transforms docs sub-structure #7291

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Feb 21, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
87 changes: 36 additions & 51 deletions docs/source/transforms.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,10 @@ transformations.
This is useful if you have to build a more complex transformation pipeline
(e.g. in the case of segmentation tasks).

Most transformations accept both `PIL <https://pillow.readthedocs.io>`_
images and tensor images, although some transformations are :ref:`PIL-only
<transforms_pil_only>` and some are :ref:`tensor-only
<transforms_tensor_only>`. The :ref:`conversion_transforms` may be used to
convert to and from PIL images.
Most transformations accept both `PIL <https://pillow.readthedocs.io>`_ images
and tensor images, although some transformations are PIL-only and some are
tensor-only. The :ref:`conversion_transforms` may be used to convert to and from
PIL images, or for converting dtypes and ranges.

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
Expand Down Expand Up @@ -70,8 +69,10 @@ The following examples illustrate the use of the available transforms:
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`.

Expand All @@ -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``.


Compositions of transforms
--------------------------
Geometry
--------

.. autosummary::
:toctree: generated/
: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::
:toctree: generated/
:template: class.rst

CenterCrop
ColorJitter
FiveCrop
Grayscale
Pad
RandomAffine
RandomApply
RandomCrop
RandomGrayscale
RandomHorizontalFlip
RandomPerspective
RandomResizedCrop
RandomRotation
RandomVerticalFlip
Resize
TenCrop
GaussianBlur
RandomInvert
RandomPosterize
Expand All @@ -130,23 +128,20 @@ Transforms on PIL Image and torch.\*Tensor
RandomAutocontrast
RandomEqualize


.. _transforms_pil_only:

Transforms on PIL Image only
----------------------------
Composition
-----------
Comment on lines +131 to +132
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we rename our file from _container later on as well?


.. autosummary::
:toctree: generated/
:template: class.rst

Compose
RandomApply
RandomChoice
RandomOrder

.. _transforms_tensor_only:

Transforms on torch.\*Tensor only
---------------------------------
Miscellaneous
-------------

.. autosummary::
:toctree: generated/
Expand All @@ -155,12 +150,12 @@ Transforms on torch.\*Tensor only
LinearTransformation
Normalize
RandomErasing
ConvertImageDtype
Lambda

.. _conversion_transforms:

Conversion Transforms
---------------------
Conversion
----------

.. autosummary::
:toctree: generated/
Expand All @@ -169,20 +164,10 @@ Conversion Transforms
ToPILImage
ToTensor
PILToTensor
ConvertImageDtype


Generic Transforms
------------------

.. autosummary::
:toctree: generated/
:template: class.rst

Lambda


Automatic Augmentation Transforms
---------------------------------
Auto-Augmentation
-----------------

`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
Expand Down