Skip to content

Minor additions to Resize docs #4138

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions torchvision/transforms/functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,8 @@ def resize(img: Tensor, size: List[int], interpolation: InterpolationMode = Inte
The output image might be different depending on its type: when downsampling, the interpolation of PIL images
and tensors is slightly different, because PIL applies antialiasing. This may lead to significant differences
in the performance of a network. Therefore, it is preferable to train and serve a model with the same input
types.
types. See also below the ``antialias`` parameter, which can help making the output of PIL images and tensors
closer.

Args:
img (PIL Image or Tensor): Image to be resized.
Expand All @@ -372,8 +373,9 @@ def resize(img: Tensor, size: List[int], interpolation: InterpolationMode = Inte
if ``size`` is an int (or a sequence of length 1 in torchscript
mode).
antialias (bool, optional): antialias flag. If ``img`` is PIL Image, the flag is ignored and anti-alias
is always used. If ``img`` is Tensor, the flag is False by default and can be set True for
``InterpolationMode.BILINEAR`` only mode.
is always used. If ``img`` is Tensor, the flag is False by default and can be set to True for
``InterpolationMode.BILINEAR`` only mode. This can help making the output for PIL images and tensors
closer.

.. warning::
There is no autodiff support for ``antialias=True`` option with input ``img`` as Tensor.
Expand Down
8 changes: 5 additions & 3 deletions torchvision/transforms/transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,8 @@ class Resize(torch.nn.Module):
The output image might be different depending on its type: when downsampling, the interpolation of PIL images
and tensors is slightly different, because PIL applies antialiasing. This may lead to significant differences
in the performance of a network. Therefore, it is preferable to train and serve a model with the same input
types.
types. See also below the ``antialias`` parameter, which can help making the output of PIL images and tensors
closer.

Args:
size (sequence or int): Desired output size. If size is a sequence like
Expand All @@ -258,8 +259,9 @@ class Resize(torch.nn.Module):
if ``size`` is an int (or a sequence of length 1 in torchscript
mode).
antialias (bool, optional): antialias flag. If ``img`` is PIL Image, the flag is ignored and anti-alias
is always used. If ``img`` is Tensor, the flag is False by default and can be set True for
``InterpolationMode.BILINEAR`` only mode.
is always used. If ``img`` is Tensor, the flag is False by default and can be set to True for
``InterpolationMode.BILINEAR`` only mode. This can help making the output for PIL images and tensors
closer.

.. warning::
There is no autodiff support for ``antialias=True`` option with input ``img`` as Tensor.
Expand Down