transforms.rst 18.7 KB
Newer Older
1
2
.. _transforms:

limm's avatar
limm committed
3
4
Transforming and augmenting images
==================================
Sasank Chilamkurthy's avatar
Sasank Chilamkurthy committed
5
6
7

.. currentmodule:: torchvision.transforms

limm's avatar
limm committed
8
9
10
11
Torchvision supports common computer vision transformations in the
``torchvision.transforms`` and ``torchvision.transforms.v2`` modules. Transforms
can be used to transform or augment data for training or inference of different
tasks (image classification, detection, segmentation, video classification).
12

limm's avatar
limm committed
13
.. code:: python
14

limm's avatar
limm committed
15
16
17
    # Image Classification
    import torch
    from torchvision.transforms import v2
18

limm's avatar
limm committed
19
20
    H, W = 32, 32
    img = torch.randint(0, 256, size=(3, H, W), dtype=torch.uint8)
21

limm's avatar
limm committed
22
23
24
25
26
27
28
    transforms = v2.Compose([
        v2.RandomResizedCrop(size=(224, 224), antialias=True),
        v2.RandomHorizontalFlip(p=0.5),
        v2.ToDtype(torch.float32, scale=True),
        v2.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225]),
    ])
    img = transforms(img)
29

limm's avatar
limm committed
30
.. code:: python
31

limm's avatar
limm committed
32
33
    # Detection (re-using imports and transforms from above)
    from torchvision import tv_tensors
34

limm's avatar
limm committed
35
36
37
38
    img = torch.randint(0, 256, size=(3, H, W), dtype=torch.uint8)
    boxes = torch.randint(0, H // 2, size=(3, 4))
    boxes[:, 2:] += boxes[:, :2]
    boxes = tv_tensors.BoundingBoxes(boxes, format="XYXY", canvas_size=(H, W))
39

limm's avatar
limm committed
40
41
42
43
    # The same transforms can be used!
    img, boxes = transforms(img, boxes)
    # And you can pass arbitrary input structures
    output_dict = transforms({"image": img, "boxes": boxes})
44

limm's avatar
limm committed
45
46
Transforms are typically passed as the ``transform`` or ``transforms`` argument
to the :ref:`Datasets <datasets>`.
47

limm's avatar
limm committed
48
49
Start here
----------
50

limm's avatar
limm committed
51
52
53
54
Whether you're new to Torchvision transforms, or you're already experienced with
them, we encourage you to start with
:ref:`sphx_glr_auto_examples_transforms_plot_transforms_getting_started.py` in
order to learn more about what can be done with the new v2 transforms.
55

limm's avatar
limm committed
56
57
58
Then, browse the sections in below this page for general information and
performance tips. The available transforms and functionals are listed in the
:ref:`API reference <v2_api_ref>`.
59

limm's avatar
limm committed
60
61
62
More information and tutorials can also be found in our :ref:`example gallery
<gallery>`, e.g. :ref:`sphx_glr_auto_examples_transforms_plot_transforms_e2e.py`
or :ref:`sphx_glr_auto_examples_transforms_plot_custom_transforms.py`.
63

limm's avatar
limm committed
64
.. _conventions:
65

limm's avatar
limm committed
66
67
Supported input types and conventions
-------------------------------------
68

limm's avatar
limm committed
69
70
71
72
73
74
75
Most transformations accept both `PIL <https://pillow.readthedocs.io>`_ images
and tensor inputs. Both CPU and CUDA tensors are supported.
The result of both backends (PIL or Tensors) should be very
close. In general, we recommend relying on the tensor backend :ref:`for
performance <transforms_perf>`.  The :ref:`conversion transforms
<conversion_transforms>` may be used to convert to and from PIL images, or for
converting dtypes and ranges.
76

limm's avatar
limm committed
77
78
79
80
81
82
Tensor image are expected to be of shape ``(C, H, W)``, where ``C`` is the
number of channels, and ``H`` and ``W`` refer to height and width. Most
transforms support batched tensor input. A batch of Tensor images is a tensor of
shape ``(N, C, H, W)``, where ``N`` is a number of images in the batch. The
:ref:`v2 <v1_or_v2>` transforms generally accept an arbitrary number of leading
dimensions ``(..., C, H, W)`` and can handle batched images or batched videos.
83

limm's avatar
limm committed
84
.. _range_and_dtype:
85

limm's avatar
limm committed
86
87
Dtype and expected value range
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Sasank Chilamkurthy's avatar
Sasank Chilamkurthy committed
88

limm's avatar
limm committed
89
90
91
92
93
94
The expected range of the values of a tensor image is implicitly defined by
the tensor dtype. Tensor images with a float dtype are expected to have
values in ``[0, 1]``. Tensor images with an integer dtype are expected to
have values in ``[0, MAX_DTYPE]`` where ``MAX_DTYPE`` is the largest value
that can be represented in that dtype. Typically, images of dtype
``torch.uint8`` are expected to have values in ``[0, 255]``.
95

limm's avatar
limm committed
96
97
Use :class:`~torchvision.transforms.v2.ToDtype` to convert both the dtype and
range of the inputs.
Sasank Chilamkurthy's avatar
Sasank Chilamkurthy committed
98

limm's avatar
limm committed
99
.. _v1_or_v2:
100

limm's avatar
limm committed
101
102
V1 or V2? Which one should I use?
---------------------------------
Sasank Chilamkurthy's avatar
Sasank Chilamkurthy committed
103

limm's avatar
limm committed
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
**TL;DR** We recommending using the ``torchvision.transforms.v2`` transforms
instead of those in ``torchvision.transforms``. They're faster and they can do
more things. Just change the import and you should be good to go. Moving
forward, new features and improvements will only be considered for the v2
transforms.

In Torchvision 0.15 (March 2023), we released a new set of transforms available
in the ``torchvision.transforms.v2`` namespace. These transforms have a lot of
advantages compared to the v1 ones (in ``torchvision.transforms``):

- They can transform images **but also** bounding boxes, masks, or videos. This
  provides support for tasks beyond image classification: detection, segmentation,
  video classification, etc. See
  :ref:`sphx_glr_auto_examples_transforms_plot_transforms_getting_started.py`
  and :ref:`sphx_glr_auto_examples_transforms_plot_transforms_e2e.py`.
- They support more transforms like :class:`~torchvision.transforms.v2.CutMix`
  and :class:`~torchvision.transforms.v2.MixUp`. See
  :ref:`sphx_glr_auto_examples_transforms_plot_cutmix_mixup.py`.
- They're :ref:`faster <transforms_perf>`.
- They support arbitrary input structures (dicts, lists, tuples, etc.).
- Future improvements and features will be added to the v2 transforms only.

These transforms are **fully backward compatible** with the v1 ones, so if
you're already using tranforms from ``torchvision.transforms``, all you need to
do to is to update the import to ``torchvision.transforms.v2``. In terms of
output, there might be negligible differences due to implementation differences.

.. _transforms_perf:

Performance considerations
--------------------------
Sasank Chilamkurthy's avatar
Sasank Chilamkurthy committed
135

limm's avatar
limm committed
136
137
We recommend the following guidelines to get the best performance out of the
transforms:
Sasank Chilamkurthy's avatar
Sasank Chilamkurthy committed
138

limm's avatar
limm committed
139
140
141
142
- Rely on the v2 transforms from ``torchvision.transforms.v2``
- Use tensors instead of PIL images
- Use ``torch.uint8`` dtype, especially for resizing
- Resize with bilinear or bicubic mode
143

limm's avatar
limm committed
144
This is what a typical transform pipeline could look like:
145

limm's avatar
limm committed
146
.. code:: python
Sasank Chilamkurthy's avatar
Sasank Chilamkurthy committed
147

limm's avatar
limm committed
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
    from torchvision.transforms import v2
    transforms = v2.Compose([
        v2.ToImage(),  # Convert to tensor, only needed if you had a PIL image
        v2.ToDtype(torch.uint8, scale=True),  # optional, most input are already uint8 at this point
        # ...
        v2.RandomResizedCrop(size=(224, 224), antialias=True),  # Or Resize(antialias=True)
        # ...
        v2.ToDtype(torch.float32, scale=True),  # Normalize expects float input
        v2.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225]),
    ])

The above should give you the best performance in a typical training environment
that relies on the :class:`torch.utils.data.DataLoader` with ``num_workers >
0``.

Transforms tend to be sensitive to the input strides / memory format. Some
transforms will be faster with channels-first images while others prefer
channels-last. Like ``torch`` operators, most transforms will preserve the
memory format of the input, but this may not always be respected due to
implementation details. You may want to experiment a bit if you're chasing the
very best performance.  Using :func:`torch.compile` on individual transforms may
also help factoring out the memory format variable (e.g. on
:class:`~torchvision.transforms.v2.Normalize`). Note that we're talking about
**memory format**, not :ref:`tensor shape <conventions>`.

Note that resize transforms like :class:`~torchvision.transforms.v2.Resize`
and :class:`~torchvision.transforms.v2.RandomResizedCrop` typically prefer
channels-last input and tend **not** to benefit from :func:`torch.compile` at
this time.
177

limm's avatar
limm committed
178
.. _functional_transforms:
179

limm's avatar
limm committed
180
181
Transform classes, functionals, and kernels
-------------------------------------------
Sasank Chilamkurthy's avatar
Sasank Chilamkurthy committed
182

limm's avatar
limm committed
183
184
185
186
187
188
Transforms are available as classes like
:class:`~torchvision.transforms.v2.Resize`, but also as functionals like
:func:`~torchvision.transforms.v2.functional.resize` in the
``torchvision.transforms.v2.functional`` namespace.
This is very much like the :mod:`torch.nn` package which defines both classes
and functional equivalents in :mod:`torch.nn.functional`.
189

limm's avatar
limm committed
190
191
192
The functionals support PIL images, pure tensors, or :ref:`TVTensors
<tv_tensors>`, e.g. both ``resize(image_tensor)`` and ``resize(boxes)`` are
valid.
193

limm's avatar
limm committed
194
.. note::
195

limm's avatar
limm committed
196
197
198
199
200
201
    Random transforms like :class:`~torchvision.transforms.v2.RandomCrop` will
    randomly sample some parameter each time they're called. Their functional
    counterpart (:func:`~torchvision.transforms.v2.functional.crop`) does not do
    any kind of random sampling and thus have a slighlty different
    parametrization. The ``get_params()`` class method of the transforms class
    can be used to perform parameter sampling when using the functional APIs.
202
203


limm's avatar
limm committed
204
205
206
207
208
209
210
211
212
213
The ``torchvision.transforms.v2.functional`` namespace also contains what we
call the "kernels". These are the low-level functions that implement the
core functionalities for specific types, e.g. ``resize_bounding_boxes`` or
```resized_crop_mask``. They are public, although not documented. Check the
`code
<https://github.com/pytorch/vision/blob/main/torchvision/transforms/v2/functional/__init__.py>`_
to see which ones are available (note that those starting with a leading
underscore are **not** public!). Kernels are only really useful if you want
:ref:`torchscript support <transforms_torchscript>` for types like bounding
boxes or masks.
214

limm's avatar
limm committed
215
.. _transforms_torchscript:
216

limm's avatar
limm committed
217
218
Torchscript support
-------------------
219

limm's avatar
limm committed
220
221
222
Most transform classes and functionals support torchscript. For composing
transforms, use :class:`torch.nn.Sequential` instead of
:class:`~torchvision.transforms.v2.Compose`:
223

limm's avatar
limm committed
224
.. code:: python
225

limm's avatar
limm committed
226
227
228
229
230
    transforms = torch.nn.Sequential(
        CenterCrop(10),
        Normalize((0.485, 0.456, 0.406), (0.229, 0.224, 0.225)),
    )
    scripted_transforms = torch.jit.script(transforms)
231

limm's avatar
limm committed
232
.. warning::
233

limm's avatar
limm committed
234
235
236
237
238
    v2 transforms support torchscript, but if you call ``torch.jit.script()`` on
    a v2 **class** transform, you'll actually end up with its (scripted) v1
    equivalent.  This may lead to slightly different results between the
    scripted and eager executions due to implementation differences between v1
    and v2.
239

limm's avatar
limm committed
240
241
242
    If you really need torchscript support for the v2 transforms, we recommend
    scripting the **functionals** from the
    ``torchvision.transforms.v2.functional`` namespace to avoid surprises.
243
244


limm's avatar
limm committed
245
246
247
248
Also note that the functionals only support torchscript for pure tensors, which
are always treated as images. If you need torchscript support for other types
like bounding boxes or masks, you can rely on the :ref:`low-level kernels
<functional_transforms>`.
249

limm's avatar
limm committed
250
251
For any custom transformations to be used with ``torch.jit.script``, they should
be derived from ``torch.nn.Module``.
Sasank Chilamkurthy's avatar
Sasank Chilamkurthy committed
252

limm's avatar
limm committed
253
See also: :ref:`sphx_glr_auto_examples_others_plot_scripted_tensor_transforms.py`.
vfdev's avatar
vfdev committed
254

limm's avatar
limm committed
255
256
257
258
259
260
261
.. _v2_api_ref:

V2 API reference - Recommended
------------------------------

Geometry
^^^^^^^^
vfdev's avatar
vfdev committed
262

limm's avatar
limm committed
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
Resizing
""""""""

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

    v2.Resize
    v2.ScaleJitter
    v2.RandomShortestSize
    v2.RandomResize

Functionals

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

    v2.functional.resize

Cropping
""""""""

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

    v2.RandomCrop
    v2.RandomResizedCrop
    v2.RandomIoUCrop
    v2.CenterCrop
    v2.FiveCrop
    v2.TenCrop

Functionals

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

    v2.functional.crop
    v2.functional.resized_crop
    v2.functional.ten_crop
    v2.functional.center_crop
    v2.functional.five_crop

Others
""""""

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

    v2.RandomHorizontalFlip
    v2.RandomVerticalFlip
    v2.Pad
    v2.RandomZoomOut
    v2.RandomRotation
    v2.RandomAffine
    v2.RandomPerspective
    v2.ElasticTransform

Functionals

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

    v2.functional.horizontal_flip
    v2.functional.vertical_flip
    v2.functional.pad
    v2.functional.rotate
    v2.functional.affine
    v2.functional.perspective
    v2.functional.elastic

Color
^^^^^

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

    v2.ColorJitter
    v2.RandomChannelPermutation
    v2.RandomPhotometricDistort
    v2.Grayscale
    v2.RGB
    v2.RandomGrayscale
    v2.GaussianBlur
    v2.GaussianNoise
    v2.RandomInvert
    v2.RandomPosterize
    v2.RandomSolarize
    v2.RandomAdjustSharpness
    v2.RandomAutocontrast
    v2.RandomEqualize

Functionals

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

    v2.functional.permute_channels
    v2.functional.rgb_to_grayscale
    v2.functional.grayscale_to_rgb
    v2.functional.to_grayscale
    v2.functional.gaussian_blur
    v2.functional.gaussian_noise
    v2.functional.invert
    v2.functional.posterize
    v2.functional.solarize
    v2.functional.adjust_sharpness
    v2.functional.autocontrast
    v2.functional.adjust_contrast
    v2.functional.equalize
    v2.functional.adjust_brightness
    v2.functional.adjust_saturation
    v2.functional.adjust_hue
    v2.functional.adjust_gamma


Composition
^^^^^^^^^^^

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

    v2.Compose
    v2.RandomApply
    v2.RandomChoice
    v2.RandomOrder

Miscellaneous
^^^^^^^^^^^^^

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

    v2.LinearTransformation
    v2.Normalize
    v2.RandomErasing
    v2.Lambda
    v2.SanitizeBoundingBoxes
    v2.ClampBoundingBoxes
    v2.UniformTemporalSubsample
    v2.JPEG

Functionals

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

    v2.functional.normalize
    v2.functional.erase
    v2.functional.sanitize_bounding_boxes
    v2.functional.clamp_bounding_boxes
    v2.functional.uniform_temporal_subsample
    v2.functional.jpeg
vfdev's avatar
vfdev committed
426

limm's avatar
limm committed
427
.. _conversion_transforms:
surgan12's avatar
surgan12 committed
428

limm's avatar
limm committed
429
430
Conversion
^^^^^^^^^^
Sasank Chilamkurthy's avatar
Sasank Chilamkurthy committed
431

limm's avatar
limm committed
432
433
434
435
436
.. note::
    Beware, some of these conversion transforms below will scale the values
    while performing the conversion, while some may not do any scaling. By
    scaling, we mean e.g. that a ``uint8`` -> ``float32`` would map the [0,
    255] range into [0, 1] (and vice-versa). See :ref:`range_and_dtype`.
vfdev's avatar
vfdev committed
437

limm's avatar
limm committed
438
439
440
.. autosummary::
    :toctree: generated/
    :template: class.rst
vfdev's avatar
vfdev committed
441

limm's avatar
limm committed
442
443
444
445
446
447
    v2.ToImage
    v2.ToPureTensor
    v2.PILToTensor
    v2.ToPILImage
    v2.ToDtype
    v2.ConvertBoundingBoxFormat
448

limm's avatar
limm committed
449
functionals
Sasank Chilamkurthy's avatar
Sasank Chilamkurthy committed
450

limm's avatar
limm committed
451
452
453
.. autosummary::
    :toctree: generated/
    :template: functional.rst
Sasank Chilamkurthy's avatar
Sasank Chilamkurthy committed
454

limm's avatar
limm committed
455
456
457
458
459
    v2.functional.to_image
    v2.functional.pil_to_tensor
    v2.functional.to_pil_image
    v2.functional.to_dtype
    v2.functional.convert_bounding_box_format
vfdev's avatar
vfdev committed
460

Sasank Chilamkurthy's avatar
Sasank Chilamkurthy committed
461

limm's avatar
limm committed
462
Deprecated
Sasank Chilamkurthy's avatar
Sasank Chilamkurthy committed
463

limm's avatar
limm committed
464
465
466
.. autosummary::
    :toctree: generated/
    :template: class.rst
Sasank Chilamkurthy's avatar
Sasank Chilamkurthy committed
467

limm's avatar
limm committed
468
469
470
471
    v2.ToTensor
    v2.functional.to_tensor
    v2.ConvertImageDtype
    v2.functional.convert_image_dtype
472

limm's avatar
limm committed
473
474
Auto-Augmentation
^^^^^^^^^^^^^^^^^
475
476
477
478
479
480
481

`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
ImageNet policies provide significant improvements when applied to other datasets.
In TorchVision we implemented 3 policies learned on the following datasets: ImageNet, CIFAR10 and SVHN.
The new transform can be used standalone or mixed-and-matched with existing transforms:

limm's avatar
limm committed
482
483
484
.. autosummary::
    :toctree: generated/
    :template: class.rst
485

limm's avatar
limm committed
486
487
488
489
    v2.AutoAugment
    v2.RandAugment
    v2.TrivialAugmentWide
    v2.AugMix
490
491


limm's avatar
limm committed
492
493
CutMix - MixUp
^^^^^^^^^^^^^^
494

limm's avatar
limm committed
495
496
497
498
499
500
501
502
503
504
505
506
CutMix and MixUp are special transforms that
are meant to be used on batches rather than on individual images, because they
are combining pairs of images together. These can be used after the dataloader
(once the samples are batched), or part of a collation function. See
:ref:`sphx_glr_auto_examples_transforms_plot_cutmix_mixup.py` for detailed usage examples.

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

    v2.CutMix
    v2.MixUp
507

limm's avatar
limm committed
508
509
Developer tools
^^^^^^^^^^^^^^^
510

limm's avatar
limm committed
511
512
513
.. autosummary::
    :toctree: generated/
    :template: function.rst
514

limm's avatar
limm committed
515
    v2.functional.register_kernel
516
517


limm's avatar
limm committed
518
519
V1 API Reference
----------------
520

limm's avatar
limm committed
521
522
Geometry
^^^^^^^^
523

limm's avatar
limm committed
524
525
526
.. autosummary::
    :toctree: generated/
    :template: class.rst
527

limm's avatar
limm committed
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
    Resize
    RandomCrop
    RandomResizedCrop
    CenterCrop
    FiveCrop
    TenCrop
    Pad
    RandomRotation
    RandomAffine
    RandomPerspective
    ElasticTransform
    RandomHorizontalFlip
    RandomVerticalFlip


Color
^^^^^

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

    ColorJitter
    Grayscale
    RandomGrayscale
    GaussianBlur
    RandomInvert
    RandomPosterize
    RandomSolarize
    RandomAdjustSharpness
    RandomAutocontrast
    RandomEqualize

Composition
^^^^^^^^^^^
563

limm's avatar
limm committed
564
565
566
.. autosummary::
    :toctree: generated/
    :template: class.rst
567

limm's avatar
limm committed
568
569
570
571
    Compose
    RandomApply
    RandomChoice
    RandomOrder
572

limm's avatar
limm committed
573
574
Miscellaneous
^^^^^^^^^^^^^
575

limm's avatar
limm committed
576
577
578
.. autosummary::
    :toctree: generated/
    :template: class.rst
579

limm's avatar
limm committed
580
581
582
583
    LinearTransformation
    Normalize
    RandomErasing
    Lambda
584

limm's avatar
limm committed
585
586
Conversion
^^^^^^^^^^
587

limm's avatar
limm committed
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
.. note::
    Beware, some of these conversion transforms below will scale the values
    while performing the conversion, while some may not do any scaling. By
    scaling, we mean e.g. that a ``uint8`` -> ``float32`` would map the [0,
    255] range into [0, 1] (and vice-versa). See :ref:`range_and_dtype`.

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

    ToPILImage
    ToTensor
    PILToTensor
    ConvertImageDtype

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
ImageNet policies provide significant improvements when applied to other datasets.
In TorchVision we implemented 3 policies learned on the following datasets: ImageNet, CIFAR10 and SVHN.
The new transform can be used standalone or mixed-and-matched with existing transforms:

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

    AutoAugmentPolicy
    AutoAugment
    RandAugment
    TrivialAugmentWide
    AugMix



Functional Transforms
^^^^^^^^^^^^^^^^^^^^^

.. currentmodule:: torchvision.transforms.functional

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

    adjust_brightness
    adjust_contrast
    adjust_gamma
    adjust_hue
    adjust_saturation
    adjust_sharpness
    affine
    autocontrast
    center_crop
    convert_image_dtype
    crop
    equalize
    erase
    five_crop
    gaussian_blur
    get_dimensions
    get_image_num_channels
    get_image_size
    hflip
    invert
    normalize
    pad
    perspective
    pil_to_tensor
    posterize
    resize
    resized_crop
    rgb_to_grayscale
    rotate
    solarize
    ten_crop
    to_grayscale
    to_pil_image
    to_tensor
    vflip