You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Note that these transforms are still BETA, and while we don't expect major
18
+
breaking changes in the future, some APIs may still change according to user
19
+
feedback. Please submit any feedback you may have `here
20
+
<https://github.com/pytorch/vision/issues/6753>`_, and you can also check
21
+
out `this issue <https://github.com/pytorch/vision/issues/7319>`_ to learn
22
+
more about the APIs that we suspect might involve future changes.
23
+
8
24
Transforms are common image transformations available in the
9
25
``torchvision.transforms`` module. They can be chained together using
10
26
:class:`Compose`.
@@ -14,11 +30,10 @@ transformations.
14
30
This is useful if you have to build a more complex transformation pipeline
15
31
(e.g. in the case of segmentation tasks).
16
32
17
-
Most transformations accept both `PIL <https://pillow.readthedocs.io>`_
18
-
images and tensor images, although some transformations are :ref:`PIL-only
19
-
<transforms_pil_only>` and some are :ref:`tensor-only
20
-
<transforms_tensor_only>`. The :ref:`conversion_transforms` may be used to
21
-
convert to and from PIL images.
33
+
Most transformations accept both `PIL <https://pillow.readthedocs.io>`_ images
34
+
and tensor images, although some transformations are PIL-only and some are
35
+
tensor-only. The :ref:`conversion_transforms` may be used to convert to and from
36
+
PIL images, or for converting dtypes and ranges.
22
37
23
38
The transformations that accept tensor images also accept batches of tensor
24
39
images. A Tensor Image is a tensor with ``(C, H, W)`` shape, where ``C`` is a
@@ -70,8 +85,10 @@ The following examples illustrate the use of the available transforms:
70
85
produce the same results.
71
86
72
87
73
-
Scriptable transforms
74
-
---------------------
88
+
Transforms scriptability
89
+
------------------------
90
+
91
+
.. TODO: Add note about v2 scriptability (in next PR)
75
92
76
93
In order to script the transformations, please use ``torch.nn.Sequential`` instead of :class:`Compose`.
77
94
@@ -89,100 +106,141 @@ Make sure to use only scriptable transformations, i.e. that work with ``torch.Te
89
106
For any custom transformations to be used with ``torch.jit.script``, they should be derived from ``torch.nn.Module``.
90
107
91
108
92
-
Compositions of transforms
93
-
--------------------------
109
+
Geometry
110
+
--------
94
111
95
112
.. autosummary::
96
113
:toctree: generated/
97
114
:template: class.rst
98
115
99
-
Compose
116
+
Resize
117
+
v2.Resize
118
+
v2.ScaleJitter
119
+
v2.RandomShortestSize
120
+
v2.RandomResize
121
+
RandomCrop
122
+
v2.RandomCrop
123
+
RandomResizedCrop
124
+
v2.RandomResizedCrop
125
+
v2.RandomIoUCrop
126
+
CenterCrop
127
+
v2.CenterCrop
128
+
FiveCrop
129
+
v2.FiveCrop
130
+
TenCrop
131
+
v2.TenCrop
132
+
Pad
133
+
v2.Pad
134
+
v2.RandomZoomOut
135
+
RandomRotation
136
+
v2.RandomRotation
137
+
RandomAffine
138
+
v2.RandomAffine
139
+
RandomPerspective
140
+
v2.RandomPerspective
141
+
ElasticTransform
142
+
v2.ElasticTransform
143
+
RandomHorizontalFlip
144
+
v2.RandomHorizontalFlip
145
+
RandomVerticalFlip
146
+
v2.RandomVerticalFlip
100
147
101
148
102
-
Transforms on PIL Image and torch.\*Tensor
103
-
------------------------------------------
149
+
Color
150
+
-----
104
151
105
152
.. autosummary::
106
153
:toctree: generated/
107
154
:template: class.rst
108
155
109
-
CenterCrop
110
156
ColorJitter
111
-
FiveCrop
157
+
v2.ColorJitter
158
+
v2.RandomPhotometricDistort
112
159
Grayscale
113
-
Pad
114
-
RandomAffine
115
-
RandomApply
116
-
RandomCrop
160
+
v2.Grayscale
117
161
RandomGrayscale
118
-
RandomHorizontalFlip
119
-
RandomPerspective
120
-
RandomResizedCrop
121
-
RandomRotation
122
-
RandomVerticalFlip
123
-
Resize
124
-
TenCrop
162
+
v2.RandomGrayscale
125
163
GaussianBlur
164
+
v2.GaussianBlur
126
165
RandomInvert
166
+
v2.RandomInvert
127
167
RandomPosterize
168
+
v2.RandomPosterize
128
169
RandomSolarize
170
+
v2.RandomSolarize
129
171
RandomAdjustSharpness
172
+
v2.RandomAdjustSharpness
130
173
RandomAutocontrast
174
+
v2.RandomAutocontrast
131
175
RandomEqualize
176
+
v2.RandomEqualize
132
177
133
-
134
-
.. _transforms_pil_only:
135
-
136
-
Transforms on PIL Image only
137
-
----------------------------
178
+
Composition
179
+
-----------
138
180
139
181
.. autosummary::
140
182
:toctree: generated/
141
183
:template: class.rst
142
184
185
+
Compose
186
+
v2.Compose
187
+
RandomApply
188
+
v2.RandomApply
143
189
RandomChoice
190
+
v2.RandomChoice
144
191
RandomOrder
192
+
v2.RandomOrder
145
193
146
-
.. _transforms_tensor_only:
147
-
148
-
Transforms on torch.\*Tensor only
149
-
---------------------------------
194
+
Miscellaneous
195
+
-------------
150
196
151
197
.. autosummary::
152
198
:toctree: generated/
153
199
:template: class.rst
154
200
155
201
LinearTransformation
202
+
v2.LinearTransformation
156
203
Normalize
204
+
v2.Normalize
157
205
RandomErasing
158
-
ConvertImageDtype
206
+
v2.RandomErasing
207
+
Lambda
208
+
v2.Lambda
209
+
v2.SanitizeBoundingBox
210
+
v2.ClampBoundingBox
211
+
v2.UniformTemporalSubsample
159
212
160
213
.. _conversion_transforms:
161
214
162
-
Conversion Transforms
163
-
---------------------
215
+
Conversion
216
+
----------
164
217
218
+
.. note::
219
+
Beware, some of these conversion transforms below will scale the values
220
+
while performing the conversion, while some may not do any scaling. By
221
+
scaling, we mean e.g. that a ``uint8`` -> ``float32`` would map the [0,
222
+
255] range into [0, 1] (and vice-versa).
223
+
165
224
.. autosummary::
166
225
:toctree: generated/
167
226
:template: class.rst
168
227
169
228
ToPILImage
229
+
v2.ToPILImage
230
+
v2.ToImagePIL
170
231
ToTensor
232
+
v2.ToTensor
171
233
PILToTensor
234
+
v2.PILToTensor
235
+
v2.ToImageTensor
236
+
ConvertImageDtype
237
+
v2.ConvertDtype
238
+
v2.ConvertImageDtype
239
+
v2.ToDtype
240
+
v2.ConvertBoundingBoxFormat
172
241
173
-
174
-
Generic Transforms
175
-
------------------
176
-
177
-
.. autosummary::
178
-
:toctree: generated/
179
-
:template: class.rst
180
-
181
-
Lambda
182
-
183
-
184
-
Automatic Augmentation Transforms
185
-
---------------------------------
242
+
Auto-Augmentation
243
+
-----------------
186
244
187
245
`AutoAugment <https://arxiv.org/pdf/1805.09501.pdf>`_ is a common Data Augmentation technique that can improve the accuracy of Image Classification models.
188
246
Though the data augmentation policies are directly linked to their trained dataset, empirical studies show that
@@ -196,9 +254,13 @@ The new transform can be used standalone or mixed-and-matched with existing tran
0 commit comments