Skip to content

Commit 38aab83

Browse files
authored
Added warning to the documentation of F_pil and F_t functions (2547) (#2664)
* Fixes #2547 - Added warning to the documentation of F_pil and F_t functions * Update functional_tensor.py
1 parent 5547747 commit 38aab83

File tree

2 files changed

+192
-29
lines changed

2 files changed

+192
-29
lines changed

torchvision/transforms/functional_pil.py

Lines changed: 92 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,12 @@ def _get_image_num_channels(img: Any) -> int:
3535

3636
@torch.jit.unused
3737
def hflip(img):
38-
"""Horizontally flip the given PIL Image.
38+
"""PRIVATE METHOD. Horizontally flip the given PIL Image.
39+
40+
.. warning::
41+
42+
Module ``transforms.functional_pil`` is private and should not be used in user application.
43+
Please, consider instead using methods from `transforms.functional` module.
3944
4045
Args:
4146
img (PIL Image): Image to be flipped.
@@ -51,7 +56,12 @@ def hflip(img):
5156

5257
@torch.jit.unused
5358
def vflip(img):
54-
"""Vertically flip the given PIL Image.
59+
"""PRIVATE METHOD. Vertically flip the given PIL Image.
60+
61+
.. warning::
62+
63+
Module ``transforms.functional_pil`` is private and should not be used in user application.
64+
Please, consider instead using methods from `transforms.functional` module.
5565
5666
Args:
5767
img (PIL Image): Image to be flipped.
@@ -67,7 +77,12 @@ def vflip(img):
6777

6878
@torch.jit.unused
6979
def adjust_brightness(img, brightness_factor):
70-
"""Adjust brightness of an RGB image.
80+
"""PRIVATE METHOD. Adjust brightness of an RGB image.
81+
82+
.. warning::
83+
84+
Module ``transforms.functional_pil`` is private and should not be used in user application.
85+
Please, consider instead using methods from `transforms.functional` module.
7186
7287
Args:
7388
img (PIL Image): Image to be adjusted.
@@ -88,7 +103,13 @@ def adjust_brightness(img, brightness_factor):
88103

89104
@torch.jit.unused
90105
def adjust_contrast(img, contrast_factor):
91-
"""Adjust contrast of an Image.
106+
"""PRIVATE METHOD. Adjust contrast of an Image.
107+
108+
.. warning::
109+
110+
Module ``transforms.functional_pil`` is private and should not be used in user application.
111+
Please, consider instead using methods from `transforms.functional` module.
112+
92113
Args:
93114
img (PIL Image): PIL Image to be adjusted.
94115
contrast_factor (float): How much to adjust the contrast. Can be any
@@ -107,7 +128,13 @@ def adjust_contrast(img, contrast_factor):
107128

108129
@torch.jit.unused
109130
def adjust_saturation(img, saturation_factor):
110-
"""Adjust color saturation of an image.
131+
"""PRIVATE METHOD. Adjust color saturation of an image.
132+
133+
.. warning::
134+
135+
Module ``transforms.functional_pil`` is private and should not be used in user application.
136+
Please, consider instead using methods from `transforms.functional` module.
137+
111138
Args:
112139
img (PIL Image): PIL Image to be adjusted.
113140
saturation_factor (float): How much to adjust the saturation. 0 will
@@ -126,7 +153,12 @@ def adjust_saturation(img, saturation_factor):
126153

127154
@torch.jit.unused
128155
def adjust_hue(img, hue_factor):
129-
"""Adjust hue of an image.
156+
"""PRIVATE METHOD. Adjust hue of an image.
157+
158+
.. warning::
159+
160+
Module ``transforms.functional_pil`` is private and should not be used in user application.
161+
Please, consider instead using methods from `transforms.functional` module.
130162
131163
The image hue is adjusted by converting the image to HSV and
132164
cyclically shifting the intensities in the hue channel (H).
@@ -174,7 +206,12 @@ def adjust_hue(img, hue_factor):
174206

175207
@torch.jit.unused
176208
def adjust_gamma(img, gamma, gain=1):
177-
r"""Perform gamma correction on an image.
209+
r"""PRIVATE METHOD. Perform gamma correction on an image.
210+
211+
.. warning::
212+
213+
Module ``transforms.functional_pil`` is private and should not be used in user application.
214+
Please, consider instead using methods from `transforms.functional` module.
178215
179216
Also known as Power Law Transform. Intensities in RGB mode are adjusted
180217
based on the following equation:
@@ -210,7 +247,12 @@ def adjust_gamma(img, gamma, gain=1):
210247

211248
@torch.jit.unused
212249
def pad(img, padding, fill=0, padding_mode="constant"):
213-
r"""Pad the given PIL.Image on all sides with the given "pad" value.
250+
r"""PRIVATE METHOD. Pad the given PIL.Image on all sides with the given "pad" value.
251+
252+
.. warning::
253+
254+
Module ``transforms.functional_pil`` is private and should not be used in user application.
255+
Please, consider instead using methods from `transforms.functional` module.
214256
215257
Args:
216258
img (PIL Image): Image to be padded.
@@ -309,7 +351,12 @@ def pad(img, padding, fill=0, padding_mode="constant"):
309351

310352
@torch.jit.unused
311353
def crop(img: Image.Image, top: int, left: int, height: int, width: int) -> Image.Image:
312-
"""Crop the given PIL Image.
354+
"""PRIVATE METHOD. Crop the given PIL Image.
355+
356+
.. warning::
357+
358+
Module ``transforms.functional_pil`` is private and should not be used in user application.
359+
Please, consider instead using methods from `transforms.functional` module.
313360
314361
Args:
315362
img (PIL Image): Image to be cropped. (0,0) denotes the top left corner of the image.
@@ -329,7 +376,12 @@ def crop(img: Image.Image, top: int, left: int, height: int, width: int) -> Imag
329376

330377
@torch.jit.unused
331378
def resize(img, size, interpolation=Image.BILINEAR):
332-
r"""Resize the input PIL Image to the given size.
379+
r"""PRIVATE METHOD. Resize the input PIL Image to the given size.
380+
381+
.. warning::
382+
383+
Module ``transforms.functional_pil`` is private and should not be used in user application.
384+
Please, consider instead using methods from `transforms.functional` module.
333385
334386
Args:
335387
img (PIL Image): Image to be resized.
@@ -370,7 +422,12 @@ def resize(img, size, interpolation=Image.BILINEAR):
370422

371423
@torch.jit.unused
372424
def _parse_fill(fill, img, min_pil_version, name="fillcolor"):
373-
"""Helper function to get the fill color for rotate, perspective transforms, and pad.
425+
"""PRIVATE METHOD. Helper function to get the fill color for rotate, perspective transforms, and pad.
426+
427+
.. warning::
428+
429+
Module ``transforms.functional_pil`` is private and should not be used in user application.
430+
Please, consider instead using methods from `transforms.functional` module.
374431
375432
Args:
376433
fill (n-tuple or int or float): Pixel fill value for area outside the transformed
@@ -409,7 +466,12 @@ def _parse_fill(fill, img, min_pil_version, name="fillcolor"):
409466

410467
@torch.jit.unused
411468
def affine(img, matrix, resample=0, fillcolor=None):
412-
"""Apply affine transformation on the PIL Image keeping image center invariant.
469+
"""PRIVATE METHOD. Apply affine transformation on the PIL Image keeping image center invariant.
470+
471+
.. warning::
472+
473+
Module ``transforms.functional_pil`` is private and should not be used in user application.
474+
Please, consider instead using methods from `transforms.functional` module.
413475
414476
Args:
415477
img (PIL Image): image to be rotated.
@@ -433,7 +495,12 @@ def affine(img, matrix, resample=0, fillcolor=None):
433495

434496
@torch.jit.unused
435497
def rotate(img, angle, resample=0, expand=False, center=None, fill=None):
436-
"""Rotate PIL image by angle.
498+
"""PRIVATE METHOD. Rotate PIL image by angle.
499+
500+
.. warning::
501+
502+
Module ``transforms.functional_pil`` is private and should not be used in user application.
503+
Please, consider instead using methods from `transforms.functional` module.
437504
438505
Args:
439506
img (PIL Image): image to be rotated.
@@ -467,7 +534,12 @@ def rotate(img, angle, resample=0, expand=False, center=None, fill=None):
467534

468535
@torch.jit.unused
469536
def perspective(img, perspective_coeffs, interpolation=Image.BICUBIC, fill=None):
470-
"""Perform perspective transform of the given PIL Image.
537+
"""PRIVATE METHOD. Perform perspective transform of the given PIL Image.
538+
539+
.. warning::
540+
541+
Module ``transforms.functional_pil`` is private and should not be used in user application.
542+
Please, consider instead using methods from `transforms.functional` module.
471543
472544
Args:
473545
img (PIL Image): Image to be transformed.
@@ -491,7 +563,12 @@ def perspective(img, perspective_coeffs, interpolation=Image.BICUBIC, fill=None)
491563

492564
@torch.jit.unused
493565
def to_grayscale(img, num_output_channels):
494-
"""Convert PIL image of any mode (RGB, HSV, LAB, etc) to grayscale version of image.
566+
"""PRIVATE METHOD. Convert PIL image of any mode (RGB, HSV, LAB, etc) to grayscale version of image.
567+
568+
.. warning::
569+
570+
Module ``transforms.functional_pil`` is private and should not be used in user application.
571+
Please, consider instead using methods from `transforms.functional` module.
495572
496573
Args:
497574
img (PIL Image): Image to be converted to grayscale.

0 commit comments

Comments
 (0)