File tree Expand file tree Collapse file tree 3 files changed +12
-7
lines changed
prototype/transforms/functional Expand file tree Collapse file tree 3 files changed +12
-7
lines changed Original file line number Diff line number Diff line change 33import PIL .Image
44import torch
55from torchvision .transforms import functional_tensor as _FT
6- from torchvision .transforms .functional import to_tensor , to_pil_image
6+ from torchvision .transforms .functional import pil_to_tensor , to_pil_image
77
88
99normalize_image_tensor = _FT .normalize
@@ -39,4 +39,6 @@ def gaussian_blur_image_tensor(
3939
4040
4141def gaussian_blur_image_pil (img : PIL .Image , kernel_size : List [int ], sigma : Optional [List [float ]] = None ) -> PIL .Image :
42- return to_pil_image (gaussian_blur_image_tensor (to_tensor (img ), kernel_size = kernel_size , sigma = sigma ))
42+ t_img = pil_to_tensor (img )
43+ output = gaussian_blur_image_tensor (t_img , kernel_size = kernel_size , sigma = sigma )
44+ return to_pil_image (output , mode = img .mode )
Original file line number Diff line number Diff line change @@ -126,6 +126,9 @@ def to_tensor(pic):
126126
127127 See :class:`~torchvision.transforms.ToTensor` for more details.
128128
129+ .. warning::
130+ This method is deprecated, please use :meth:`~torchvision.transforms.functional.pil_to_tensor`.
131+
129132 Args:
130133 pic (PIL Image or numpy.ndarray): Image to be converted to tensor.
131134
@@ -403,11 +406,8 @@ def resize(
403406 mode).
404407 antialias (bool, optional): antialias flag. If ``img`` is PIL Image, the flag is ignored and anti-alias
405408 is always used. If ``img`` is Tensor, the flag is False by default and can be set to True for
406- ``InterpolationMode.BILINEAR`` only mode. This can help making the output for PIL images and tensors
407- closer.
408-
409- .. warning::
410- There is no autodiff support for ``antialias=True`` option with input ``img`` as Tensor.
409+ ``InterpolationMode.BILINEAR`` and ``InterpolationMode.BICUBIC`` modes.
410+ This can help making the output for PIL images and tensors closer.
411411
412412 Returns:
413413 PIL Image or Tensor: Resized image.
Original file line number Diff line number Diff line change @@ -114,6 +114,9 @@ class ToTensor:
114114
115115 In the other cases, tensors are returned without scaling.
116116
117+ .. warning::
118+ This method is deprecated, please use :meth:`~torchvision.transforms.functional.pil_to_tensor`.
119+
117120 .. note::
118121 Because the input image is scaled to [0.0, 1.0], this transformation should not be used when
119122 transforming target image masks. See the `references`_ for implementing the transforms for image masks.
You can’t perform that action at this time.
0 commit comments