-
Notifications
You must be signed in to change notification settings - Fork 7.1k
Update transforms for PIL deprecation #5898
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
Changes from 3 commits
7874b06
80f8f60
3cfe376
a74be25
1ac68ca
cb13daa
57228df
77a2dfb
3ee5542
8597dd5
8743141
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
|
||
import PIL | ||
from PIL import Image | ||
|
||
if tuple(int(part) for part in PIL.__version__.split(".")) >= (9, 1, 0): | ||
pmeier marked this conversation as resolved.
Show resolved
Hide resolved
|
||
FLIP_LEFT_RIGHT = Image.Transpose.FLIP_LEFT_RIGHT | ||
FLIP_TOP_BOTTOM = Image.Transpose.FLIP_TOP_BOTTOM | ||
BILINEAR = Image.Resampling.BILINEAR | ||
NEAREST = Image.Resampling.NEAREST | ||
AFFINE = Image.Transform.AFFINE | ||
BICUBIC = Image.Resampling.BICUBIC | ||
PERSPECTIVE = Image.Transform.PERSPECTIVE | ||
LINEAR = Image.Resampling.BILINEAR | ||
pmeier marked this conversation as resolved.
Show resolved
Hide resolved
|
||
else: | ||
FLIP_LEFT_RIGHT = Image.FLIP_LEFT_RIGHT | ||
FLIP_TOP_BOTTOM = Image.FLIP_TOP_BOTTOM | ||
BILINEAR = Image.BILINEAR | ||
NEAREST = Image.NEAREST | ||
AFFINE = Image.AFFINE | ||
BICUBIC = Image.BICUBIC | ||
PERSPECTIVE = Image.PERSPECTIVE | ||
LINEAR = Image.LINEAR |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -392,7 +392,7 @@ def resize( | |||||||||||||||||||||||||
:class:`torchvision.transforms.InterpolationMode`. | ||||||||||||||||||||||||||
Default is ``InterpolationMode.BILINEAR``. If input is Tensor, only ``InterpolationMode.NEAREST``, | ||||||||||||||||||||||||||
``InterpolationMode.BILINEAR`` and ``InterpolationMode.BICUBIC`` are supported. | ||||||||||||||||||||||||||
For backward compatibility integer values (e.g. ``PIL.Image.NEAREST``) are still acceptable. | ||||||||||||||||||||||||||
For backward compatibility integer values (e.g. ``PIL.Image(.Resampling).NEAREST``) are still acceptable. | ||||||||||||||||||||||||||
pmeier marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||||||
max_size (int, optional): The maximum allowed for the longer edge of | ||||||||||||||||||||||||||
the resized image: if the longer edge of the image is greater | ||||||||||||||||||||||||||
than ``max_size`` after being resized according to ``size``, then | ||||||||||||||||||||||||||
|
@@ -572,7 +572,7 @@ def resized_crop( | |||||||||||||||||||||||||
:class:`torchvision.transforms.InterpolationMode`. | ||||||||||||||||||||||||||
Default is ``InterpolationMode.BILINEAR``. If input is Tensor, only ``InterpolationMode.NEAREST``, | ||||||||||||||||||||||||||
``InterpolationMode.BILINEAR`` and ``InterpolationMode.BICUBIC`` are supported. | ||||||||||||||||||||||||||
For backward compatibility integer values (e.g. ``PIL.Image.NEAREST``) are still acceptable. | ||||||||||||||||||||||||||
For backward compatibility integer values (e.g. ``PIL.Image(.Resampling).NEAREST``) are still acceptable. | ||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm ok with this style in the docstring. Any objections? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @kylematoba Could you address this in all docstrings? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure, so replace instances of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Yes.
No. The docstring need to be changed indicating that passing vision/torchvision/transforms/functional.py Lines 1029 to 1031 in 6274080
Furthermore, we need to change the warning vision/torchvision/transforms/functional.py Lines 415 to 419 in 6274080
to include the concrete deprecation date, e.g. vision/torchvision/transforms/functional.py Lines 1042 to 1045 in 6274080
For this we will be deprecating in |
||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
Returns: | ||||||||||||||||||||||||||
PIL Image or Tensor: Cropped image. | ||||||||||||||||||||||||||
|
@@ -652,7 +652,7 @@ def perspective( | |||||||||||||||||||||||||
interpolation (InterpolationMode): Desired interpolation enum defined by | ||||||||||||||||||||||||||
:class:`torchvision.transforms.InterpolationMode`. Default is ``InterpolationMode.BILINEAR``. | ||||||||||||||||||||||||||
If input is Tensor, only ``InterpolationMode.NEAREST``, ``InterpolationMode.BILINEAR`` are supported. | ||||||||||||||||||||||||||
For backward compatibility integer values (e.g. ``PIL.Image.NEAREST``) are still acceptable. | ||||||||||||||||||||||||||
For backward compatibility integer values (e.g. ``PIL.Image(.Resampling).NEAREST``) are still acceptable. | ||||||||||||||||||||||||||
fill (sequence or number, optional): Pixel fill value for the area outside the transformed | ||||||||||||||||||||||||||
image. If given a number, the value is used for all bands respectively. | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
|
@@ -1012,7 +1012,7 @@ def rotate( | |||||||||||||||||||||||||
interpolation (InterpolationMode): Desired interpolation enum defined by | ||||||||||||||||||||||||||
:class:`torchvision.transforms.InterpolationMode`. Default is ``InterpolationMode.NEAREST``. | ||||||||||||||||||||||||||
If input is Tensor, only ``InterpolationMode.NEAREST``, ``InterpolationMode.BILINEAR`` are supported. | ||||||||||||||||||||||||||
For backward compatibility integer values (e.g. ``PIL.Image.NEAREST``) are still acceptable. | ||||||||||||||||||||||||||
For backward compatibility integer values (e.g. ``PIL.Image(.Resampling).NEAREST``) are still acceptable. | ||||||||||||||||||||||||||
expand (bool, optional): Optional expansion flag. | ||||||||||||||||||||||||||
If true, expands the output image to make it large enough to hold the entire rotated image. | ||||||||||||||||||||||||||
If false or omitted, make the output image the same size as the input image. | ||||||||||||||||||||||||||
|
@@ -1105,7 +1105,7 @@ def affine( | |||||||||||||||||||||||||
interpolation (InterpolationMode): Desired interpolation enum defined by | ||||||||||||||||||||||||||
:class:`torchvision.transforms.InterpolationMode`. Default is ``InterpolationMode.NEAREST``. | ||||||||||||||||||||||||||
If input is Tensor, only ``InterpolationMode.NEAREST``, ``InterpolationMode.BILINEAR`` are supported. | ||||||||||||||||||||||||||
For backward compatibility integer values (e.g. ``PIL.Image.NEAREST``) are still acceptable. | ||||||||||||||||||||||||||
For backward compatibility integer values (e.g. ``PIL.Image(.Resampling).NEAREST``) are still acceptable. | ||||||||||||||||||||||||||
fill (sequence or number, optional): Pixel fill value for the area outside the transformed | ||||||||||||||||||||||||||
image. If given a number, the value is used for all bands respectively. | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
|
Uh oh!
There was an error while loading. Please reload this page.