forked from pytorch/pytorch.github.io
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtransforms.html
1640 lines (1424 loc) · 105 KB
/
transforms.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
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
135
136
137
138
139
140
141
142
143
144
145
146
147
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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
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
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
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
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
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
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>torchvision.transforms — PyTorch master documentation</title>
<link rel="canonical" href="https://pytorch.org/docs/stable/torchvision/transforms.html"/>
<link rel="stylesheet" href="../_static/css/theme.css" type="text/css" />
<!-- <link rel="stylesheet" href="../_static/pygments.css" type="text/css" /> -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/katex.min.css" type="text/css" />
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/katex.min.css" type="text/css" />
<link rel="stylesheet" href="../_static/katex-math.css" type="text/css" />
<link rel="index" title="Index" href="../genindex.html" />
<link rel="search" title="Search" href="../search.html" />
<link rel="next" title="torchvision.utils" href="utils.html" />
<link rel="prev" title="torchvision.models" href="models.html" />
<script src="../_static/js/modernizr.min.js"></script>
</head>
<div class="container-fluid header-holder tutorials-header" id="header-holder">
<div class="container">
<div class="header-container">
<a class="header-logo" href="https://pytorch.org/" aria-label="PyTorch"></a>
<div class="main-menu">
<ul>
<li>
<a href="https://pytorch.org/get-started">Get Started</a>
</li>
<li>
<a href="https://pytorch.org/features">Features</a>
</li>
<li>
<a href="https://pytorch.org/ecosystem">Ecosystem</a>
</li>
<li>
<a href="https://pytorch.org/blog/">Blog</a>
</li>
<li>
<a href="https://pytorch.org/tutorials">Tutorials</a>
</li>
<li class="active">
<a href="https://pytorch.org/docs/stable/index.html">Docs</a>
</li>
<li>
<a href="https://pytorch.org/resources">Resources</a>
</li>
<li>
<a href="https://github.com/pytorch/pytorch">Github</a>
</li>
</ul>
</div>
<a class="main-menu-open-button" href="#" data-behavior="open-mobile-menu"></a>
</div>
</div>
</div>
<body class="pytorch-body">
<div class="table-of-contents-link-wrapper">
<span>Table of Contents</span>
<a href="#" class="toggle-table-of-contents" data-behavior="toggle-table-of-contents"></a>
</div>
<nav data-toggle="wy-nav-shift" class="pytorch-left-menu" id="pytorch-left-menu">
<div class="pytorch-side-scroll">
<div class="pytorch-menu pytorch-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
<div class="pytorch-left-menu-search">
<div class="version">
<a href="http://pytorch.org/docs/versions.html"> 1.0.0 ▼</a>
</div>
<div role="search">
<form id="rtd-search-form" class="wy-form" action="../search.html" method="get">
<input type="text" name="q" placeholder="Search Docs" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
</div>
<p class="caption"><span class="caption-text">Notes</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../notes/autograd.html">Autograd mechanics</a></li>
<li class="toctree-l1"><a class="reference internal" href="../notes/broadcasting.html">Broadcasting semantics</a></li>
<li class="toctree-l1"><a class="reference internal" href="../notes/cuda.html">CUDA semantics</a></li>
<li class="toctree-l1"><a class="reference internal" href="../notes/extending.html">Extending PyTorch</a></li>
<li class="toctree-l1"><a class="reference internal" href="../notes/faq.html">Frequently Asked Questions</a></li>
<li class="toctree-l1"><a class="reference internal" href="../notes/multiprocessing.html">Multiprocessing best practices</a></li>
<li class="toctree-l1"><a class="reference internal" href="../notes/randomness.html">Reproducibility</a></li>
<li class="toctree-l1"><a class="reference internal" href="../notes/serialization.html">Serialization semantics</a></li>
<li class="toctree-l1"><a class="reference internal" href="../notes/windows.html">Windows FAQ</a></li>
</ul>
<p class="caption"><span class="caption-text">Package Reference</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../torch.html">torch</a></li>
<li class="toctree-l1"><a class="reference internal" href="../tensors.html">torch.Tensor</a></li>
<li class="toctree-l1"><a class="reference internal" href="../tensor_attributes.html">Tensor Attributes</a></li>
<li class="toctree-l1"><a class="reference internal" href="../type_info.html">Type Info</a></li>
<li class="toctree-l1"><a class="reference internal" href="../sparse.html">torch.sparse</a></li>
<li class="toctree-l1"><a class="reference internal" href="../cuda.html">torch.cuda</a></li>
<li class="toctree-l1"><a class="reference internal" href="../storage.html">torch.Storage</a></li>
<li class="toctree-l1"><a class="reference internal" href="../nn.html">torch.nn</a></li>
<li class="toctree-l1"><a class="reference internal" href="../nn.html#torch-nn-functional">torch.nn.functional</a></li>
<li class="toctree-l1"><a class="reference internal" href="../nn.html#torch-nn-init">torch.nn.init</a></li>
<li class="toctree-l1"><a class="reference internal" href="../optim.html">torch.optim</a></li>
<li class="toctree-l1"><a class="reference internal" href="../autograd.html">torch.autograd</a></li>
<li class="toctree-l1"><a class="reference internal" href="../distributed.html">torch.distributed</a></li>
<li class="toctree-l1"><a class="reference internal" href="../distributions.html">torch.distributions</a></li>
<li class="toctree-l1"><a class="reference internal" href="../jit.html">torch.jit</a></li>
<li class="toctree-l1"><a class="reference internal" href="../multiprocessing.html">torch.multiprocessing</a></li>
<li class="toctree-l1"><a class="reference internal" href="../bottleneck.html">torch.utils.bottleneck</a></li>
<li class="toctree-l1"><a class="reference internal" href="../checkpoint.html">torch.utils.checkpoint</a></li>
<li class="toctree-l1"><a class="reference internal" href="../cpp_extension.html">torch.utils.cpp_extension</a></li>
<li class="toctree-l1"><a class="reference internal" href="../data.html">torch.utils.data</a></li>
<li class="toctree-l1"><a class="reference internal" href="../dlpack.html">torch.utils.dlpack</a></li>
<li class="toctree-l1"><a class="reference internal" href="../ffi.html">torch.utils.ffi</a></li>
<li class="toctree-l1"><a class="reference internal" href="../hub.html">torch.hub</a></li>
<li class="toctree-l1"><a class="reference internal" href="../model_zoo.html">torch.utils.model_zoo</a></li>
<li class="toctree-l1"><a class="reference internal" href="../onnx.html">torch.onnx</a></li>
<li class="toctree-l1"><a class="reference internal" href="../distributed_deprecated.html">torch.distributed.deprecated</a></li>
<li class="toctree-l1"><a class="reference internal" href="../legacy.html">torch.legacy</a></li>
</ul>
<p class="caption"><span class="caption-text">torchvision Reference</span></p>
<ul class="current">
<li class="toctree-l1 current"><a class="reference internal" href="index.html">torchvision</a></li>
</ul>
</div>
</div>
</nav>
<div class="pytorch-container">
<div class="pytorch-page-level-bar" id="pytorch-page-level-bar">
<div class="pytorch-breadcrumbs-wrapper">
<div role="navigation" aria-label="breadcrumbs navigation">
<ul class="pytorch-breadcrumbs">
<li>
<a href="../index.html">
Docs
</a> >
</li>
<li><a href="index.html">torchvision</a> ></li>
<li>torchvision.transforms</li>
<li class="pytorch-breadcrumbs-aside">
<a href="../_sources/torchvision/transforms.rst.txt" rel="nofollow"><img src="../_static/images/view-page-source-icon.svg"></a>
</li>
</ul>
</div>
</div>
<div class="pytorch-shortcuts-wrapper" id="pytorch-shortcuts-wrapper">
Shortcuts
</div>
</div>
<section data-toggle="wy-nav-shift" id="pytorch-content-wrap" class="pytorch-content-wrap">
<div class="pytorch-content-left">
<div class="rst-content">
<div role="main" class="main-content" itemscope="itemscope" itemtype="http://schema.org/Article">
<article itemprop="articleBody" id="pytorch-article" class="pytorch-article">
<div class="section" id="torchvision-transforms">
<h1>torchvision.transforms<a class="headerlink" href="#torchvision-transforms" title="Permalink to this headline">¶</a></h1>
<p>Transforms are common image transformations. They can be chained together using <a class="reference internal" href="#torchvision.transforms.Compose" title="torchvision.transforms.Compose"><code class="xref py py-class docutils literal notranslate"><span class="pre">Compose</span></code></a>.
Additionally, there is the <a class="reference internal" href="#module-torchvision.transforms.functional" title="torchvision.transforms.functional"><code class="xref py py-mod docutils literal notranslate"><span class="pre">torchvision.transforms.functional</span></code></a> module.
Functional transforms give fine-grained control over the transformations.
This is useful if you have to build a more complex transformation pipeline
(e.g. in the case of segmentation tasks).</p>
<dl class="class">
<dt id="torchvision.transforms.Compose">
<em class="property">class </em><code class="descclassname">torchvision.transforms.</code><code class="descname">Compose</code><span class="sig-paren">(</span><em>transforms</em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/torchvision/transforms/transforms.html#Compose"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torchvision.transforms.Compose" title="Permalink to this definition">¶</a></dt>
<dd><p>Composes several transforms together.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>transforms</strong> (list of <code class="docutils literal notranslate"><span class="pre">Transform</span></code> objects) – list of transforms to compose.</td>
</tr>
</tbody>
</table>
<p class="rubric">Example</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">transforms</span><span class="o">.</span><span class="n">Compose</span><span class="p">([</span>
<span class="gp">>>> </span> <span class="n">transforms</span><span class="o">.</span><span class="n">CenterCrop</span><span class="p">(</span><span class="mi">10</span><span class="p">),</span>
<span class="gp">>>> </span> <span class="n">transforms</span><span class="o">.</span><span class="n">ToTensor</span><span class="p">(),</span>
<span class="gp">>>> </span><span class="p">])</span>
</pre></div>
</div>
</dd></dl>
<div class="section" id="transforms-on-pil-image">
<h2>Transforms on PIL Image<a class="headerlink" href="#transforms-on-pil-image" title="Permalink to this headline">¶</a></h2>
<dl class="class">
<dt id="torchvision.transforms.CenterCrop">
<em class="property">class </em><code class="descclassname">torchvision.transforms.</code><code class="descname">CenterCrop</code><span class="sig-paren">(</span><em>size</em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/torchvision/transforms/transforms.html#CenterCrop"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torchvision.transforms.CenterCrop" title="Permalink to this definition">¶</a></dt>
<dd><p>Crops the given PIL Image at the center.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>size</strong> (<em>sequence</em><em> or </em><a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.7)"><em>int</em></a>) – Desired output size of the crop. If size is an
int instead of sequence like (h, w), a square crop (size, size) is
made.</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="class">
<dt id="torchvision.transforms.ColorJitter">
<em class="property">class </em><code class="descclassname">torchvision.transforms.</code><code class="descname">ColorJitter</code><span class="sig-paren">(</span><em>brightness=0</em>, <em>contrast=0</em>, <em>saturation=0</em>, <em>hue=0</em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/torchvision/transforms/transforms.html#ColorJitter"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torchvision.transforms.ColorJitter" title="Permalink to this definition">¶</a></dt>
<dd><p>Randomly change the brightness, contrast and saturation of an image.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>brightness</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#float" title="(in Python v3.7)"><em>float</em></a>) – How much to jitter brightness. brightness_factor
is chosen uniformly from [max(0, 1 - brightness), 1 + brightness].</li>
<li><strong>contrast</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#float" title="(in Python v3.7)"><em>float</em></a>) – How much to jitter contrast. contrast_factor
is chosen uniformly from [max(0, 1 - contrast), 1 + contrast].</li>
<li><strong>saturation</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#float" title="(in Python v3.7)"><em>float</em></a>) – How much to jitter saturation. saturation_factor
is chosen uniformly from [max(0, 1 - saturation), 1 + saturation].</li>
<li><strong>hue</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#float" title="(in Python v3.7)"><em>float</em></a>) – How much to jitter hue. hue_factor is chosen uniformly from
[-hue, hue]. Should be >=0 and <= 0.5.</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="class">
<dt id="torchvision.transforms.FiveCrop">
<em class="property">class </em><code class="descclassname">torchvision.transforms.</code><code class="descname">FiveCrop</code><span class="sig-paren">(</span><em>size</em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/torchvision/transforms/transforms.html#FiveCrop"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torchvision.transforms.FiveCrop" title="Permalink to this definition">¶</a></dt>
<dd><p>Crop the given PIL Image into four corners and the central crop</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">This transform returns a tuple of images and there may be a mismatch in the number of
inputs and targets your Dataset returns. See below for an example of how to deal with
this.</p>
</div>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>size</strong> (<em>sequence</em><em> or </em><a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.7)"><em>int</em></a>) – Desired output size of the crop. If size is an <code class="docutils literal notranslate"><span class="pre">int</span></code>
instead of sequence like (h, w), a square crop of size (size, size) is made.</td>
</tr>
</tbody>
</table>
<p class="rubric">Example</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">transform</span> <span class="o">=</span> <span class="n">Compose</span><span class="p">([</span>
<span class="gp">>>> </span> <span class="n">FiveCrop</span><span class="p">(</span><span class="n">size</span><span class="p">),</span> <span class="c1"># this is a list of PIL Images</span>
<span class="gp">>>> </span> <span class="n">Lambda</span><span class="p">(</span><span class="k">lambda</span> <span class="n">crops</span><span class="p">:</span> <span class="n">torch</span><span class="o">.</span><span class="n">stack</span><span class="p">([</span><span class="n">ToTensor</span><span class="p">()(</span><span class="n">crop</span><span class="p">)</span> <span class="k">for</span> <span class="n">crop</span> <span class="ow">in</span> <span class="n">crops</span><span class="p">]))</span> <span class="c1"># returns a 4D tensor</span>
<span class="gp">>>> </span><span class="p">])</span>
<span class="gp">>>> </span><span class="c1">#In your test loop you can do the following:</span>
<span class="gp">>>> </span><span class="nb">input</span><span class="p">,</span> <span class="n">target</span> <span class="o">=</span> <span class="n">batch</span> <span class="c1"># input is a 5d tensor, target is 2d</span>
<span class="gp">>>> </span><span class="n">bs</span><span class="p">,</span> <span class="n">ncrops</span><span class="p">,</span> <span class="n">c</span><span class="p">,</span> <span class="n">h</span><span class="p">,</span> <span class="n">w</span> <span class="o">=</span> <span class="nb">input</span><span class="o">.</span><span class="n">size</span><span class="p">()</span>
<span class="gp">>>> </span><span class="n">result</span> <span class="o">=</span> <span class="n">model</span><span class="p">(</span><span class="nb">input</span><span class="o">.</span><span class="n">view</span><span class="p">(</span><span class="o">-</span><span class="mi">1</span><span class="p">,</span> <span class="n">c</span><span class="p">,</span> <span class="n">h</span><span class="p">,</span> <span class="n">w</span><span class="p">))</span> <span class="c1"># fuse batch size and ncrops</span>
<span class="gp">>>> </span><span class="n">result_avg</span> <span class="o">=</span> <span class="n">result</span><span class="o">.</span><span class="n">view</span><span class="p">(</span><span class="n">bs</span><span class="p">,</span> <span class="n">ncrops</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span><span class="o">.</span><span class="n">mean</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span> <span class="c1"># avg over crops</span>
</pre></div>
</div>
</dd></dl>
<dl class="class">
<dt id="torchvision.transforms.Grayscale">
<em class="property">class </em><code class="descclassname">torchvision.transforms.</code><code class="descname">Grayscale</code><span class="sig-paren">(</span><em>num_output_channels=1</em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/torchvision/transforms/transforms.html#Grayscale"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torchvision.transforms.Grayscale" title="Permalink to this definition">¶</a></dt>
<dd><p>Convert image to grayscale.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>num_output_channels</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.7)"><em>int</em></a>) – (1 or 3) number of channels desired for output image</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">Grayscale version of the input.
- If num_output_channels == 1 : returned image is single channel
- If num_output_channels == 3 : returned image is 3 channel with r == g == b</td>
</tr>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body">PIL Image</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="class">
<dt id="torchvision.transforms.LinearTransformation">
<em class="property">class </em><code class="descclassname">torchvision.transforms.</code><code class="descname">LinearTransformation</code><span class="sig-paren">(</span><em>transformation_matrix</em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/torchvision/transforms/transforms.html#LinearTransformation"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torchvision.transforms.LinearTransformation" title="Permalink to this definition">¶</a></dt>
<dd><p>Transform a tensor image with a square transformation matrix computed
offline.</p>
<p>Given transformation_matrix, will flatten the torch.*Tensor, compute the dot
product with the transformation matrix and reshape the tensor to its
original shape.</p>
<p>Applications:
- whitening: zero-center the data, compute the data covariance matrix</p>
<blockquote>
<div>[D x D] with np.dot(X.T, X), perform SVD on this matrix and
pass it as transformation_matrix.</div></blockquote>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>transformation_matrix</strong> (<a class="reference internal" href="../tensors.html#torch.Tensor" title="torch.Tensor"><em>Tensor</em></a>) – tensor [D x D], D = C x H x W</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="class">
<dt id="torchvision.transforms.Pad">
<em class="property">class </em><code class="descclassname">torchvision.transforms.</code><code class="descname">Pad</code><span class="sig-paren">(</span><em>padding</em>, <em>fill=0</em>, <em>padding_mode='constant'</em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/torchvision/transforms/transforms.html#Pad"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torchvision.transforms.Pad" title="Permalink to this definition">¶</a></dt>
<dd><p>Pad the given PIL Image on all sides with the given “pad” value.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>padding</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.7)"><em>int</em></a><em> or </em><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#tuple" title="(in Python v3.7)"><em>tuple</em></a>) – Padding on each border. If a single int is provided this
is used to pad all borders. If tuple of length 2 is provided this is the padding
on left/right and top/bottom respectively. If a tuple of length 4 is provided
this is the padding for the left, top, right and bottom borders
respectively.</li>
<li><strong>fill</strong> – Pixel fill value for constant fill. Default is 0. If a tuple of
length 3, it is used to fill R, G, B channels respectively.
This value is only used when the padding_mode is constant</li>
<li><strong>padding_mode</strong> – <p>Type of padding. Should be: constant, edge, reflect or symmetric. Default is constant.
constant: pads with a constant value, this value is specified with fill
edge: pads with the last value at the edge of the image
reflect: pads with reflection of image (without repeating the last value on the edge)</p>
<blockquote>
<div>padding [1, 2, 3, 4] with 2 elements on both sides in reflect mode
will result in [3, 2, 1, 2, 3, 4, 3, 2]</div></blockquote>
<dl class="docutils">
<dt>symmetric: pads with reflection of image (repeating the last value on the edge)</dt>
<dd>padding [1, 2, 3, 4] with 2 elements on both sides in symmetric mode
will result in [2, 1, 1, 2, 3, 4, 4, 3]</dd>
</dl>
</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="class">
<dt id="torchvision.transforms.RandomAffine">
<em class="property">class </em><code class="descclassname">torchvision.transforms.</code><code class="descname">RandomAffine</code><span class="sig-paren">(</span><em>degrees</em>, <em>translate=None</em>, <em>scale=None</em>, <em>shear=None</em>, <em>resample=False</em>, <em>fillcolor=0</em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/torchvision/transforms/transforms.html#RandomAffine"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torchvision.transforms.RandomAffine" title="Permalink to this definition">¶</a></dt>
<dd><p>Random affine transformation of the image keeping center invariant</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>degrees</strong> (<em>sequence</em><em> or </em><a class="reference external" href="https://docs.python.org/3/library/functions.html#float" title="(in Python v3.7)"><em>float</em></a><em> or </em><a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.7)"><em>int</em></a>) – Range of degrees to select from.
If degrees is a number instead of sequence like (min, max), the range of degrees
will be (-degrees, +degrees). Set to 0 to desactivate rotations.</li>
<li><strong>translate</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#tuple" title="(in Python v3.7)"><em>tuple</em></a><em>, </em><em>optional</em>) – tuple of maximum absolute fraction for horizontal
and vertical translations. For example translate=(a, b), then horizontal shift
is randomly sampled in the range -img_width * a < dx < img_width * a and vertical shift is
randomly sampled in the range -img_height * b < dy < img_height * b. Will not translate by default.</li>
<li><strong>scale</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#tuple" title="(in Python v3.7)"><em>tuple</em></a><em>, </em><em>optional</em>) – scaling factor interval, e.g (a, b), then scale is
randomly sampled from the range a <= scale <= b. Will keep original scale by default.</li>
<li><strong>shear</strong> (<em>sequence</em><em> or </em><a class="reference external" href="https://docs.python.org/3/library/functions.html#float" title="(in Python v3.7)"><em>float</em></a><em> or </em><a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.7)"><em>int</em></a><em>, </em><em>optional</em>) – Range of degrees to select from.
If degrees is a number instead of sequence like (min, max), the range of degrees
will be (-degrees, +degrees). Will not apply shear by default</li>
<li><strong>resample</strong> (<em>{PIL.Image.NEAREST</em><em>, </em><em>PIL.Image.BILINEAR</em><em>, </em><em>PIL.Image.BICUBIC}</em><em>, </em><em>optional</em>) – An optional resampling filter.
See <a class="reference external" href="http://pillow.readthedocs.io/en/latest/handbook/concepts.html#filters">http://pillow.readthedocs.io/en/latest/handbook/concepts.html#filters</a>
If omitted, or if the image has mode “1” or “P”, it is set to PIL.Image.NEAREST.</li>
<li><strong>fillcolor</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.7)"><em>int</em></a>) – Optional fill color for the area outside the transform in the output image. (Pillow>=5.0.0)</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="class">
<dt id="torchvision.transforms.RandomApply">
<em class="property">class </em><code class="descclassname">torchvision.transforms.</code><code class="descname">RandomApply</code><span class="sig-paren">(</span><em>transforms</em>, <em>p=0.5</em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/torchvision/transforms/transforms.html#RandomApply"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torchvision.transforms.RandomApply" title="Permalink to this definition">¶</a></dt>
<dd><p>Apply randomly a list of transformations with a given probability</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>transforms</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#list" title="(in Python v3.7)"><em>list</em></a><em> or </em><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#tuple" title="(in Python v3.7)"><em>tuple</em></a>) – list of transformations</li>
<li><strong>p</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#float" title="(in Python v3.7)"><em>float</em></a>) – probability</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="class">
<dt id="torchvision.transforms.RandomChoice">
<em class="property">class </em><code class="descclassname">torchvision.transforms.</code><code class="descname">RandomChoice</code><span class="sig-paren">(</span><em>transforms</em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/torchvision/transforms/transforms.html#RandomChoice"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torchvision.transforms.RandomChoice" title="Permalink to this definition">¶</a></dt>
<dd><p>Apply single transformation randomly picked from a list</p>
</dd></dl>
<dl class="class">
<dt id="torchvision.transforms.RandomCrop">
<em class="property">class </em><code class="descclassname">torchvision.transforms.</code><code class="descname">RandomCrop</code><span class="sig-paren">(</span><em>size</em>, <em>padding=0</em>, <em>pad_if_needed=False</em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/torchvision/transforms/transforms.html#RandomCrop"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torchvision.transforms.RandomCrop" title="Permalink to this definition">¶</a></dt>
<dd><p>Crop the given PIL Image at a random location.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>size</strong> (<em>sequence</em><em> or </em><a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.7)"><em>int</em></a>) – Desired output size of the crop. If size is an
int instead of sequence like (h, w), a square crop (size, size) is
made.</li>
<li><strong>padding</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.7)"><em>int</em></a><em> or </em><em>sequence</em><em>, </em><em>optional</em>) – Optional padding on each border
of the image. Default is 0, i.e no padding. If a sequence of length
4 is provided, it is used to pad left, top, right, bottom borders
respectively.</li>
<li><strong>pad_if_needed</strong> (<em>boolean</em>) – It will pad the image if smaller than the
desired size to avoid raising an exception.</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="class">
<dt id="torchvision.transforms.RandomGrayscale">
<em class="property">class </em><code class="descclassname">torchvision.transforms.</code><code class="descname">RandomGrayscale</code><span class="sig-paren">(</span><em>p=0.1</em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/torchvision/transforms/transforms.html#RandomGrayscale"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torchvision.transforms.RandomGrayscale" title="Permalink to this definition">¶</a></dt>
<dd><p>Randomly convert image to grayscale with a probability of p (default 0.1).</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>p</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#float" title="(in Python v3.7)"><em>float</em></a>) – probability that image should be converted to grayscale.</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">Grayscale version of the input image with probability p and unchanged
with probability (1-p).
- If input image is 1 channel: grayscale version is 1 channel
- If input image is 3 channel: grayscale version is 3 channel with r == g == b</td>
</tr>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body">PIL Image</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="class">
<dt id="torchvision.transforms.RandomHorizontalFlip">
<em class="property">class </em><code class="descclassname">torchvision.transforms.</code><code class="descname">RandomHorizontalFlip</code><span class="sig-paren">(</span><em>p=0.5</em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/torchvision/transforms/transforms.html#RandomHorizontalFlip"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torchvision.transforms.RandomHorizontalFlip" title="Permalink to this definition">¶</a></dt>
<dd><p>Horizontally flip the given PIL Image randomly with a given probability.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>p</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#float" title="(in Python v3.7)"><em>float</em></a>) – probability of the image being flipped. Default value is 0.5</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="class">
<dt id="torchvision.transforms.RandomOrder">
<em class="property">class </em><code class="descclassname">torchvision.transforms.</code><code class="descname">RandomOrder</code><span class="sig-paren">(</span><em>transforms</em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/torchvision/transforms/transforms.html#RandomOrder"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torchvision.transforms.RandomOrder" title="Permalink to this definition">¶</a></dt>
<dd><p>Apply a list of transformations in a random order</p>
</dd></dl>
<dl class="class">
<dt id="torchvision.transforms.RandomResizedCrop">
<em class="property">class </em><code class="descclassname">torchvision.transforms.</code><code class="descname">RandomResizedCrop</code><span class="sig-paren">(</span><em>size</em>, <em>scale=(0.08</em>, <em>1.0)</em>, <em>ratio=(0.75</em>, <em>1.3333333333333333)</em>, <em>interpolation=2</em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/torchvision/transforms/transforms.html#RandomResizedCrop"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torchvision.transforms.RandomResizedCrop" title="Permalink to this definition">¶</a></dt>
<dd><p>Crop the given PIL Image to random size and aspect ratio.</p>
<p>A crop of random size (default: of 0.08 to 1.0) of the original size and a random
aspect ratio (default: of 3/4 to 4/3) of the original aspect ratio is made. This crop
is finally resized to given size.
This is popularly used to train the Inception networks.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>size</strong> – expected output size of each edge</li>
<li><strong>scale</strong> – range of size of the origin size cropped</li>
<li><strong>ratio</strong> – range of aspect ratio of the origin aspect ratio cropped</li>
<li><strong>interpolation</strong> – Default: PIL.Image.BILINEAR</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="class">
<dt id="torchvision.transforms.RandomRotation">
<em class="property">class </em><code class="descclassname">torchvision.transforms.</code><code class="descname">RandomRotation</code><span class="sig-paren">(</span><em>degrees</em>, <em>resample=False</em>, <em>expand=False</em>, <em>center=None</em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/torchvision/transforms/transforms.html#RandomRotation"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torchvision.transforms.RandomRotation" title="Permalink to this definition">¶</a></dt>
<dd><p>Rotate the image by angle.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>degrees</strong> (<em>sequence</em><em> or </em><a class="reference external" href="https://docs.python.org/3/library/functions.html#float" title="(in Python v3.7)"><em>float</em></a><em> or </em><a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.7)"><em>int</em></a>) – Range of degrees to select from.
If degrees is a number instead of sequence like (min, max), the range of degrees
will be (-degrees, +degrees).</li>
<li><strong>resample</strong> (<em>{PIL.Image.NEAREST</em><em>, </em><em>PIL.Image.BILINEAR</em><em>, </em><em>PIL.Image.BICUBIC}</em><em>, </em><em>optional</em>) – An optional resampling filter.
See <a class="reference external" href="http://pillow.readthedocs.io/en/latest/handbook/concepts.html#filters">http://pillow.readthedocs.io/en/latest/handbook/concepts.html#filters</a>
If omitted, or if the image has mode “1” or “P”, it is set to PIL.Image.NEAREST.</li>
<li><strong>expand</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#bool" title="(in Python v3.7)"><em>bool</em></a><em>, </em><em>optional</em>) – Optional expansion flag.
If true, expands the output to make it large enough to hold the entire rotated image.
If false or omitted, make the output image the same size as the input image.
Note that the expand flag assumes rotation around the center and no translation.</li>
<li><strong>center</strong> (<em>2-tuple</em><em>, </em><em>optional</em>) – Optional center of rotation.
Origin is the upper left corner.
Default is the center of the image.</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="class">
<dt id="torchvision.transforms.RandomSizedCrop">
<em class="property">class </em><code class="descclassname">torchvision.transforms.</code><code class="descname">RandomSizedCrop</code><span class="sig-paren">(</span><em>*args</em>, <em>**kwargs</em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/torchvision/transforms/transforms.html#RandomSizedCrop"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torchvision.transforms.RandomSizedCrop" title="Permalink to this definition">¶</a></dt>
<dd><p>Note: This transform is deprecated in favor of RandomResizedCrop.</p>
</dd></dl>
<dl class="class">
<dt id="torchvision.transforms.RandomVerticalFlip">
<em class="property">class </em><code class="descclassname">torchvision.transforms.</code><code class="descname">RandomVerticalFlip</code><span class="sig-paren">(</span><em>p=0.5</em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/torchvision/transforms/transforms.html#RandomVerticalFlip"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torchvision.transforms.RandomVerticalFlip" title="Permalink to this definition">¶</a></dt>
<dd><p>Vertically flip the given PIL Image randomly with a given probability.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>p</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#float" title="(in Python v3.7)"><em>float</em></a>) – probability of the image being flipped. Default value is 0.5</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="class">
<dt id="torchvision.transforms.Resize">
<em class="property">class </em><code class="descclassname">torchvision.transforms.</code><code class="descname">Resize</code><span class="sig-paren">(</span><em>size</em>, <em>interpolation=2</em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/torchvision/transforms/transforms.html#Resize"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torchvision.transforms.Resize" title="Permalink to this definition">¶</a></dt>
<dd><p>Resize the input PIL Image to the given size.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>size</strong> (<em>sequence</em><em> or </em><a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.7)"><em>int</em></a>) – Desired output size. If size is a sequence like
(h, w), output size will be matched to this. If size is an int,
smaller edge of the image will be matched to this number.
i.e, if height > width, then image will be rescaled to
(size * height / width, size)</li>
<li><strong>interpolation</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.7)"><em>int</em></a><em>, </em><em>optional</em>) – Desired interpolation. Default is
<code class="docutils literal notranslate"><span class="pre">PIL.Image.BILINEAR</span></code></li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="class">
<dt id="torchvision.transforms.Scale">
<em class="property">class </em><code class="descclassname">torchvision.transforms.</code><code class="descname">Scale</code><span class="sig-paren">(</span><em>*args</em>, <em>**kwargs</em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/torchvision/transforms/transforms.html#Scale"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torchvision.transforms.Scale" title="Permalink to this definition">¶</a></dt>
<dd><p>Note: This transform is deprecated in favor of Resize.</p>
</dd></dl>
<dl class="class">
<dt id="torchvision.transforms.TenCrop">
<em class="property">class </em><code class="descclassname">torchvision.transforms.</code><code class="descname">TenCrop</code><span class="sig-paren">(</span><em>size</em>, <em>vertical_flip=False</em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/torchvision/transforms/transforms.html#TenCrop"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torchvision.transforms.TenCrop" title="Permalink to this definition">¶</a></dt>
<dd><p>Crop the given PIL Image into four corners and the central crop plus the flipped version of
these (horizontal flipping is used by default)</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">This transform returns a tuple of images and there may be a mismatch in the number of
inputs and targets your Dataset returns. See below for an example of how to deal with
this.</p>
</div>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>size</strong> (<em>sequence</em><em> or </em><a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.7)"><em>int</em></a>) – Desired output size of the crop. If size is an
int instead of sequence like (h, w), a square crop (size, size) is
made.</li>
<li><strong>vertical_flip</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#bool" title="(in Python v3.7)"><em>bool</em></a>) – Use vertical flipping instead of horizontal</li>
</ul>
</td>
</tr>
</tbody>
</table>
<p class="rubric">Example</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">transform</span> <span class="o">=</span> <span class="n">Compose</span><span class="p">([</span>
<span class="gp">>>> </span> <span class="n">TenCrop</span><span class="p">(</span><span class="n">size</span><span class="p">),</span> <span class="c1"># this is a list of PIL Images</span>
<span class="gp">>>> </span> <span class="n">Lambda</span><span class="p">(</span><span class="k">lambda</span> <span class="n">crops</span><span class="p">:</span> <span class="n">torch</span><span class="o">.</span><span class="n">stack</span><span class="p">([</span><span class="n">ToTensor</span><span class="p">()(</span><span class="n">crop</span><span class="p">)</span> <span class="k">for</span> <span class="n">crop</span> <span class="ow">in</span> <span class="n">crops</span><span class="p">]))</span> <span class="c1"># returns a 4D tensor</span>
<span class="gp">>>> </span><span class="p">])</span>
<span class="gp">>>> </span><span class="c1">#In your test loop you can do the following:</span>
<span class="gp">>>> </span><span class="nb">input</span><span class="p">,</span> <span class="n">target</span> <span class="o">=</span> <span class="n">batch</span> <span class="c1"># input is a 5d tensor, target is 2d</span>
<span class="gp">>>> </span><span class="n">bs</span><span class="p">,</span> <span class="n">ncrops</span><span class="p">,</span> <span class="n">c</span><span class="p">,</span> <span class="n">h</span><span class="p">,</span> <span class="n">w</span> <span class="o">=</span> <span class="nb">input</span><span class="o">.</span><span class="n">size</span><span class="p">()</span>
<span class="gp">>>> </span><span class="n">result</span> <span class="o">=</span> <span class="n">model</span><span class="p">(</span><span class="nb">input</span><span class="o">.</span><span class="n">view</span><span class="p">(</span><span class="o">-</span><span class="mi">1</span><span class="p">,</span> <span class="n">c</span><span class="p">,</span> <span class="n">h</span><span class="p">,</span> <span class="n">w</span><span class="p">))</span> <span class="c1"># fuse batch size and ncrops</span>
<span class="gp">>>> </span><span class="n">result_avg</span> <span class="o">=</span> <span class="n">result</span><span class="o">.</span><span class="n">view</span><span class="p">(</span><span class="n">bs</span><span class="p">,</span> <span class="n">ncrops</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span><span class="o">.</span><span class="n">mean</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span> <span class="c1"># avg over crops</span>
</pre></div>
</div>
</dd></dl>
</div>
<div class="section" id="transforms-on-torch-tensor">
<h2>Transforms on torch.*Tensor<a class="headerlink" href="#transforms-on-torch-tensor" title="Permalink to this headline">¶</a></h2>
<dl class="class">
<dt id="torchvision.transforms.Normalize">
<em class="property">class </em><code class="descclassname">torchvision.transforms.</code><code class="descname">Normalize</code><span class="sig-paren">(</span><em>mean</em>, <em>std</em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/torchvision/transforms/transforms.html#Normalize"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torchvision.transforms.Normalize" title="Permalink to this definition">¶</a></dt>
<dd><p>Normalize a tensor image with mean and standard deviation.
Given mean: <code class="docutils literal notranslate"><span class="pre">(M1,...,Mn)</span></code> and std: <code class="docutils literal notranslate"><span class="pre">(S1,..,Sn)</span></code> for <code class="docutils literal notranslate"><span class="pre">n</span></code> channels, this transform
will normalize each channel of the input <code class="docutils literal notranslate"><span class="pre">torch.*Tensor</span></code> i.e.
<code class="docutils literal notranslate"><span class="pre">input[channel]</span> <span class="pre">=</span> <span class="pre">(input[channel]</span> <span class="pre">-</span> <span class="pre">mean[channel])</span> <span class="pre">/</span> <span class="pre">std[channel]</span></code></p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>mean</strong> (<em>sequence</em>) – Sequence of means for each channel.</li>
<li><strong>std</strong> (<em>sequence</em>) – Sequence of standard deviations for each channel.</li>
</ul>
</td>
</tr>
</tbody>
</table>
<dl class="method">
<dt id="torchvision.transforms.Normalize.__call__">
<code class="descname">__call__</code><span class="sig-paren">(</span><em>tensor</em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/torchvision/transforms/transforms.html#Normalize.__call__"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torchvision.transforms.Normalize.__call__" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>tensor</strong> (<a class="reference internal" href="../tensors.html#torch.Tensor" title="torch.Tensor"><em>Tensor</em></a>) – Tensor image of size (C, H, W) to be normalized.</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">Normalized Tensor image.</td>
</tr>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><a class="reference internal" href="../tensors.html#torch.Tensor" title="torch.Tensor">Tensor</a></td>
</tr>
</tbody>
</table>
</dd></dl>
</dd></dl>
</div>
<div class="section" id="conversion-transforms">
<h2>Conversion Transforms<a class="headerlink" href="#conversion-transforms" title="Permalink to this headline">¶</a></h2>
<dl class="class">
<dt id="torchvision.transforms.ToPILImage">
<em class="property">class </em><code class="descclassname">torchvision.transforms.</code><code class="descname">ToPILImage</code><span class="sig-paren">(</span><em>mode=None</em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/torchvision/transforms/transforms.html#ToPILImage"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torchvision.transforms.ToPILImage" title="Permalink to this definition">¶</a></dt>
<dd><p>Convert a tensor or an ndarray to PIL Image.</p>
<p>Converts a torch.*Tensor of shape C x H x W or a numpy ndarray of shape
H x W x C to a PIL Image while preserving the value range.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>mode</strong> (<a class="reference external" href="http://pillow.readthedocs.io/en/latest/handbook/concepts.html#modes">PIL.Image mode</a>) – color space and pixel depth of input data (optional).
If <code class="docutils literal notranslate"><span class="pre">mode</span></code> is <code class="docutils literal notranslate"><span class="pre">None</span></code> (default) there are some assumptions made about the input data:
1. If the input has 3 channels, the <code class="docutils literal notranslate"><span class="pre">mode</span></code> is assumed to be <code class="docutils literal notranslate"><span class="pre">RGB</span></code>.
2. If the input has 4 channels, the <code class="docutils literal notranslate"><span class="pre">mode</span></code> is assumed to be <code class="docutils literal notranslate"><span class="pre">RGBA</span></code>.
3. If the input has 1 channel, the <code class="docutils literal notranslate"><span class="pre">mode</span></code> is determined by the data type (i,e,
<code class="docutils literal notranslate"><span class="pre">int</span></code>, <code class="docutils literal notranslate"><span class="pre">float</span></code>, <code class="docutils literal notranslate"><span class="pre">short</span></code>).</td>
</tr>
</tbody>
</table>
<dl class="method">
<dt id="torchvision.transforms.ToPILImage.__call__">
<code class="descname">__call__</code><span class="sig-paren">(</span><em>pic</em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/torchvision/transforms/transforms.html#ToPILImage.__call__"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torchvision.transforms.ToPILImage.__call__" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>pic</strong> (<a class="reference internal" href="../tensors.html#torch.Tensor" title="torch.Tensor"><em>Tensor</em></a><em> or </em><a class="reference external" href="https://docs.scipy.org/doc/numpy/reference/generated/numpy.ndarray.html#numpy.ndarray" title="(in NumPy v1.15)"><em>numpy.ndarray</em></a>) – Image to be converted to PIL Image.</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">Image converted to PIL Image.</td>
</tr>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body">PIL Image</td>
</tr>
</tbody>
</table>
</dd></dl>
</dd></dl>
<dl class="class">
<dt id="torchvision.transforms.ToTensor">
<em class="property">class </em><code class="descclassname">torchvision.transforms.</code><code class="descname">ToTensor</code><a class="reference internal" href="../_modules/torchvision/transforms/transforms.html#ToTensor"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torchvision.transforms.ToTensor" title="Permalink to this definition">¶</a></dt>
<dd><p>Convert a <code class="docutils literal notranslate"><span class="pre">PIL</span> <span class="pre">Image</span></code> or <code class="docutils literal notranslate"><span class="pre">numpy.ndarray</span></code> to tensor.</p>
<p>Converts a PIL Image or numpy.ndarray (H x W x C) in the range
[0, 255] to a torch.FloatTensor of shape (C x H x W) in the range [0.0, 1.0].</p>
<dl class="method">
<dt id="torchvision.transforms.ToTensor.__call__">
<code class="descname">__call__</code><span class="sig-paren">(</span><em>pic</em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/torchvision/transforms/transforms.html#ToTensor.__call__"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torchvision.transforms.ToTensor.__call__" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>pic</strong> (<em>PIL Image</em><em> or </em><a class="reference external" href="https://docs.scipy.org/doc/numpy/reference/generated/numpy.ndarray.html#numpy.ndarray" title="(in NumPy v1.15)"><em>numpy.ndarray</em></a>) – Image to be converted to tensor.</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">Converted image.</td>
</tr>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><a class="reference internal" href="../tensors.html#torch.Tensor" title="torch.Tensor">Tensor</a></td>
</tr>
</tbody>
</table>
</dd></dl>
</dd></dl>
</div>
<div class="section" id="generic-transforms">
<h2>Generic Transforms<a class="headerlink" href="#generic-transforms" title="Permalink to this headline">¶</a></h2>
<dl class="class">
<dt id="torchvision.transforms.Lambda">
<em class="property">class </em><code class="descclassname">torchvision.transforms.</code><code class="descname">Lambda</code><span class="sig-paren">(</span><em>lambd</em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/torchvision/transforms/transforms.html#Lambda"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torchvision.transforms.Lambda" title="Permalink to this definition">¶</a></dt>
<dd><p>Apply a user-defined lambda as a transform.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>lambd</strong> (<em>function</em>) – Lambda/function to be used for transform.</td>
</tr>
</tbody>
</table>
</dd></dl>
</div>
<div class="section" id="functional-transforms">
<h2>Functional Transforms<a class="headerlink" href="#functional-transforms" title="Permalink to this headline">¶</a></h2>
<p>Functional transforms give you fine-grained control of the transformation pipeline.
As opposed to the transformations above, functional transforms don’t contain a random number
generator for their parameters.
That means you have to specify/generate all parameters, but you can reuse the functional transform.
For example, you can apply a functional transform to multiple images like this:</p>
<div class="code python highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">torchvision.transforms.functional</span> <span class="k">as</span> <span class="nn">TF</span>
<span class="kn">import</span> <span class="nn">random</span>
<span class="k">def</span> <span class="nf">my_segmentation_transforms</span><span class="p">(</span><span class="n">image</span><span class="p">,</span> <span class="n">segmentation</span><span class="p">):</span>
<span class="k">if</span> <span class="n">random</span><span class="o">.</span><span class="n">random</span><span class="p">()</span> <span class="o">></span> <span class="mi">5</span><span class="p">:</span>
<span class="n">angle</span> <span class="o">=</span> <span class="n">random</span><span class="o">.</span><span class="n">randint</span><span class="p">(</span><span class="o">-</span><span class="mi">30</span><span class="p">,</span> <span class="mi">30</span><span class="p">)</span>
<span class="n">image</span> <span class="o">=</span> <span class="n">TF</span><span class="o">.</span><span class="n">rotate</span><span class="p">(</span><span class="n">image</span><span class="p">,</span> <span class="n">angle</span><span class="p">)</span>
<span class="n">segmentation</span> <span class="o">=</span> <span class="n">TF</span><span class="o">.</span><span class="n">rotate</span><span class="p">(</span><span class="n">segmentation</span><span class="p">,</span> <span class="n">angle</span><span class="p">)</span>
<span class="c1"># more transforms ...</span>
<span class="k">return</span> <span class="n">image</span><span class="p">,</span> <span class="n">segmentation</span>
</pre></div>
</div>
<span class="target" id="module-torchvision.transforms.functional"></span><dl class="function">
<dt id="torchvision.transforms.functional.adjust_brightness">
<code class="descclassname">torchvision.transforms.functional.</code><code class="descname">adjust_brightness</code><span class="sig-paren">(</span><em>img</em>, <em>brightness_factor</em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/torchvision/transforms/functional.html#adjust_brightness"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torchvision.transforms.functional.adjust_brightness" title="Permalink to this definition">¶</a></dt>
<dd><p>Adjust brightness of an Image.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
<li><strong>img</strong> (<em>PIL Image</em>) – PIL Image to be adjusted.</li>
<li><strong>brightness_factor</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#float" title="(in Python v3.7)"><em>float</em></a>) – How much to adjust the brightness. Can be
any non negative number. 0 gives a black image, 1 gives the
original image while 2 increases the brightness by a factor of 2.</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">Brightness adjusted image.</p>
</td>
</tr>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">PIL Image</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="function">
<dt id="torchvision.transforms.functional.adjust_contrast">
<code class="descclassname">torchvision.transforms.functional.</code><code class="descname">adjust_contrast</code><span class="sig-paren">(</span><em>img</em>, <em>contrast_factor</em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/torchvision/transforms/functional.html#adjust_contrast"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torchvision.transforms.functional.adjust_contrast" title="Permalink to this definition">¶</a></dt>
<dd><p>Adjust contrast of an Image.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
<li><strong>img</strong> (<em>PIL Image</em>) – PIL Image to be adjusted.</li>
<li><strong>contrast_factor</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#float" title="(in Python v3.7)"><em>float</em></a>) – How much to adjust the contrast. Can be any
non negative number. 0 gives a solid gray image, 1 gives the
original image while 2 increases the contrast by a factor of 2.</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">Contrast adjusted image.</p>
</td>
</tr>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">PIL Image</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="function">
<dt id="torchvision.transforms.functional.adjust_gamma">
<code class="descclassname">torchvision.transforms.functional.</code><code class="descname">adjust_gamma</code><span class="sig-paren">(</span><em>img</em>, <em>gamma</em>, <em>gain=1</em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/torchvision/transforms/functional.html#adjust_gamma"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torchvision.transforms.functional.adjust_gamma" title="Permalink to this definition">¶</a></dt>
<dd><p>Perform gamma correction on an image.</p>
<p>Also known as Power Law Transform. Intensities in RGB mode are adjusted
based on the following equation:</p>
<blockquote>
<div>I_out = 255 * gain * ((I_in / 255) ** gamma)</div></blockquote>
<p>See <a class="reference external" href="https://en.wikipedia.org/wiki/Gamma_correction">https://en.wikipedia.org/wiki/Gamma_correction</a> for more details.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>img</strong> (<em>PIL Image</em>) – PIL Image to be adjusted.</li>
<li><strong>gamma</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#float" title="(in Python v3.7)"><em>float</em></a>) – Non negative real number. gamma larger than 1 make the
shadows darker, while gamma smaller than 1 make dark regions
lighter.</li>
<li><strong>gain</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#float" title="(in Python v3.7)"><em>float</em></a>) – The constant multiplier.</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="function">
<dt id="torchvision.transforms.functional.adjust_hue">
<code class="descclassname">torchvision.transforms.functional.</code><code class="descname">adjust_hue</code><span class="sig-paren">(</span><em>img</em>, <em>hue_factor</em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/torchvision/transforms/functional.html#adjust_hue"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torchvision.transforms.functional.adjust_hue" title="Permalink to this definition">¶</a></dt>
<dd><p>Adjust hue of an image.</p>
<p>The image hue is adjusted by converting the image to HSV and
cyclically shifting the intensities in the hue channel (H).
The image is then converted back to original image mode.</p>
<p><cite>hue_factor</cite> is the amount of shift in H channel and must be in the
interval <cite>[-0.5, 0.5]</cite>.</p>
<p>See <a class="reference external" href="https://en.wikipedia.org/wiki/Hue">https://en.wikipedia.org/wiki/Hue</a> for more details on Hue.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
<li><strong>img</strong> (<em>PIL Image</em>) – PIL Image to be adjusted.</li>
<li><strong>hue_factor</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#float" title="(in Python v3.7)"><em>float</em></a>) – How much to shift the hue channel. Should be in
[-0.5, 0.5]. 0.5 and -0.5 give complete reversal of hue channel in
HSV space in positive and negative direction respectively.
0 means no shift. Therefore, both -0.5 and 0.5 will give an image
with complementary colors while 0 gives the original image.</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">Hue adjusted image.</p>
</td>
</tr>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">PIL Image</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="function">
<dt id="torchvision.transforms.functional.adjust_saturation">
<code class="descclassname">torchvision.transforms.functional.</code><code class="descname">adjust_saturation</code><span class="sig-paren">(</span><em>img</em>, <em>saturation_factor</em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/torchvision/transforms/functional.html#adjust_saturation"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torchvision.transforms.functional.adjust_saturation" title="Permalink to this definition">¶</a></dt>
<dd><p>Adjust color saturation of an image.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
<li><strong>img</strong> (<em>PIL Image</em>) – PIL Image to be adjusted.</li>
<li><strong>saturation_factor</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#float" title="(in Python v3.7)"><em>float</em></a>) – How much to adjust the saturation. 0 will
give a black and white image, 1 will give the original image while
2 will enhance the saturation by a factor of 2.</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">Saturation adjusted image.</p>
</td>
</tr>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">PIL Image</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="function">
<dt id="torchvision.transforms.functional.affine">
<code class="descclassname">torchvision.transforms.functional.</code><code class="descname">affine</code><span class="sig-paren">(</span><em>img</em>, <em>angle</em>, <em>translate</em>, <em>scale</em>, <em>shear</em>, <em>resample=0</em>, <em>fillcolor=None</em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/torchvision/transforms/functional.html#affine"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torchvision.transforms.functional.affine" title="Permalink to this definition">¶</a></dt>
<dd><p>Apply affine transformation on the image keeping image center invariant</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>img</strong> (<em>PIL Image</em>) – PIL Image to be rotated.</li>
<li><strong>angle</strong> (<em>{python:float</em><em>, </em><em>int}</em>) – rotation angle in degrees between -180 and 180, clockwise direction.</li>
<li><strong>translate</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#list" title="(in Python v3.7)"><em>list</em></a><em> or </em><em>tuple of python:integers</em>) – horizontal and vertical translations (post-rotation translation)</li>
<li><strong>scale</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#float" title="(in Python v3.7)"><em>float</em></a>) – overall scale</li>