Skip to content

Commit

Permalink
[fbsync] Add warning in docs of Resize about different results for PI…
Browse files Browse the repository at this point in the history
…L and tensors (#3615)

Summary:
* docs for resize

* address comment: describe antialiasing

Reviewed By: NicolasHug

Differential Revision: D27706945

fbshipit-source-id: e48c865c09f204b75d5e209a7ba45166fc913e18
  • Loading branch information
fmassa authored and facebook-github-bot committed Apr 13, 2021
1 parent 076b2bf commit 7a3176a
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 7a3176a

Please sign in to comment.