Skip to content

Commit

Permalink
Add warning in docs of Resize about different results for PIL and ten…
Browse files Browse the repository at this point in the history
…sors (pytorch#3615)

* docs for resize

* address comment: describe antialiasing
  • Loading branch information
NicolasHug authored Mar 31, 2021
1 parent 7d955df commit 591c899
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
6 changes: 6 additions & 0 deletions torchvision/transforms/functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,12 @@ def resize(img: Tensor, size: List[int], interpolation: InterpolationMode = Inte
If the image is torch Tensor, it is expected
to have [..., H, W] shape, where ... means an arbitrary number of leading dimensions
.. warning::
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.
Args:
img (PIL Image or Tensor): Image to be resized.
size (sequence or int): Desired output size. If size is a sequence like
Expand Down
6 changes: 6 additions & 0 deletions torchvision/transforms/transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,12 @@ class Resize(torch.nn.Module):
If the image is torch Tensor, it is expected
to have [..., H, W] shape, where ... means an arbitrary number of leading dimensions
.. warning::
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.
Args:
size (sequence or int): Desired output size. If size is a sequence like
(h, w), output size will be matched to this. If size is an int,
Expand Down

0 comments on commit 591c899

Please sign in to comment.