@@ -33,20 +33,33 @@ tasks (image classification, detection, segmentation, video classification).
33
33
from torchvision import tv_tensors
34
34
35
35
img = torch.randint(0 , 256 , size = (3 , H, W), dtype = torch.uint8)
36
- bboxes = torch.randint(0 , H // 2 , size = (3 , 4 ))
37
- bboxes [:, 2 :] += bboxes [:, :2 ]
38
- bboxes = tv_tensors.BoundingBoxes(bboxes , format = " XYXY" , canvas_size = (H, W))
36
+ boxes = torch.randint(0 , H // 2 , size = (3 , 4 ))
37
+ boxes [:, 2 :] += boxes [:, :2 ]
38
+ boxes = tv_tensors.BoundingBoxes(boxes , format = " XYXY" , canvas_size = (H, W))
39
39
40
40
# The same transforms can be used!
41
- img, bboxes = transforms(img, bboxes )
41
+ img, boxes = transforms(img, boxes )
42
42
# And you can pass arbitrary input structures
43
- output_dict = transforms({" image" : img, " bboxes " : bboxes })
43
+ output_dict = transforms({" image" : img, " boxes " : boxes })
44
44
45
45
Transforms are typically passed as the ``transform `` or ``transforms `` argument
46
46
to the :ref: `Datasets <datasets >`.
47
47
48
- .. TODO: Reader guide, i.e. what to read depending on what you're looking for
49
- .. TODO: add link to getting started guide here.
48
+ Start here
49
+ ----------
50
+
51
+ Whether you're new to Torchvision transforms, or you're already experienced with
52
+ them, we encourage you to start with
53
+ :ref: `sphx_glr_auto_examples_transforms_plot_transforms_getting_started.py ` in
54
+ order to learn more about what can be done with the new v2 transforms.
55
+
56
+ Then, browse the sections in below this page for general information and
57
+ performance tips. The available transforms and functionals are listed in the
58
+ :ref: `API reference <v2_api_ref >`.
59
+
60
+ More information and tutorials can also be found in our :ref: `example gallery
61
+ <gallery>`, e.g. :ref: `sphx_glr_auto_examples_transforms_plot_transforms_e2e.py `
62
+ or :ref: `sphx_glr_auto_examples_transforms_plot_custom_transforms.py `.
50
63
51
64
.. _conventions :
52
65
@@ -98,25 +111,21 @@ advantages compared to the v1 ones (in ``torchvision.transforms``):
98
111
99
112
- They can transform images **but also ** bounding boxes, masks, or videos. This
100
113
provides support for tasks beyond image classification: detection, segmentation,
101
- video classification, etc.
114
+ video classification, etc. See
115
+ :ref: `sphx_glr_auto_examples_transforms_plot_transforms_getting_started.py `
116
+ and :ref: `sphx_glr_auto_examples_transforms_plot_transforms_e2e.py `.
102
117
- They support more transforms like :class: `~torchvision.transforms.v2.CutMix `
103
- and :class: `~torchvision.transforms.v2.MixUp `.
118
+ and :class: `~torchvision.transforms.v2.MixUp `. See
119
+ :ref: `sphx_glr_auto_examples_transforms_plot_cutmix_mixup.py `.
104
120
- They're :ref: `faster <transforms_perf >`.
105
121
- They support arbitrary input structures (dicts, lists, tuples, etc.).
106
122
- Future improvements and features will be added to the v2 transforms only.
107
123
108
- .. TODO: Add link to e2e example for first bullet point.
109
-
110
124
These transforms are **fully backward compatible ** with the v1 ones, so if
111
125
you're already using tranforms from ``torchvision.transforms ``, all you need to
112
126
do to is to update the import to ``torchvision.transforms.v2 ``. In terms of
113
127
output, there might be negligible differences due to implementation differences.
114
128
115
- To learn more about the v2 transforms, check out
116
- :ref: `sphx_glr_auto_examples_transforms_plot_transforms_getting_started.py `.
117
-
118
- .. TODO: make sure link is still good!!
119
-
120
129
.. note ::
121
130
122
131
The v2 transforms are still BETA, but at this point we do not expect
@@ -184,7 +193,7 @@ This is very much like the :mod:`torch.nn` package which defines both classes
184
193
and functional equivalents in :mod: `torch.nn.functional `.
185
194
186
195
The functionals support PIL images, pure tensors, or :ref: `TVTensors
187
- <tv_tensors>`, e.g. both ``resize(image_tensor) `` and ``resize(bboxes ) `` are
196
+ <tv_tensors>`, e.g. both ``resize(image_tensor) `` and ``resize(boxes ) `` are
188
197
valid.
189
198
190
199
.. note ::
@@ -248,6 +257,8 @@ be derived from ``torch.nn.Module``.
248
257
249
258
See also: :ref: `sphx_glr_auto_examples_others_plot_scripted_tensor_transforms.py `.
250
259
260
+ .. _v2_api_ref :
261
+
251
262
V2 API reference - Recommended
252
263
------------------------------
253
264
0 commit comments