Skip to content

Commit

Permalink
[fbsync] Update _pil_constants.py (#6154)
Browse files Browse the repository at this point in the history
Summary:
* Update _pil_constants.py

* Update _pil_constants.py

* Fix flake8

* Fixed two related warnings in tests

* switch dir with hasattr

Reviewed By: datumbox

Differential Revision: D37212661

fbshipit-source-id: de82b320b5d8d1a76f56dfe531678f2e81c5c3e0

Co-authored-by: Vasilis Vryniotis <datumbox@users.noreply.github.com>
  • Loading branch information
2 people authored and facebook-github-bot committed Jun 17, 2022
1 parent 0a6e4e1 commit 5e24004
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
4 changes: 2 additions & 2 deletions test/test_transforms.py
Expand Up @@ -1522,10 +1522,10 @@ def test_ten_crop(should_vflip, single_dim):
five_crop.__repr__()

if should_vflip:
vflipped_img = img.transpose(Image.FLIP_TOP_BOTTOM)
vflipped_img = img.transpose(_pil_constants.FLIP_TOP_BOTTOM)
expected_output += five_crop(vflipped_img)
else:
hflipped_img = img.transpose(Image.FLIP_LEFT_RIGHT)
hflipped_img = img.transpose(_pil_constants.FLIP_LEFT_RIGHT)
expected_output += five_crop(hflipped_img)

assert len(results) == 10
Expand Down
3 changes: 1 addition & 2 deletions torchvision/transforms/_pil_constants.py
@@ -1,10 +1,9 @@
import PIL
from PIL import Image

# See https://pillow.readthedocs.io/en/stable/releasenotes/9.1.0.html#deprecations
# TODO: Remove this file once PIL minimal version is >= 9.1

if tuple(int(part) for part in PIL.__version__.split(".")) >= (9, 1):
if hasattr(Image, "Resampling"):
BICUBIC = Image.Resampling.BICUBIC
BILINEAR = Image.Resampling.BILINEAR
LINEAR = Image.Resampling.BILINEAR
Expand Down

0 comments on commit 5e24004

Please sign in to comment.