Skip to content

Commit c02d6ce

Browse files
vfdev-5datumbox
andauthored
Update _pil_constants.py (#6154)
* Update _pil_constants.py * Update _pil_constants.py * Fix flake8 * Fixed two related warnings in tests * switch dir with hasattr Co-authored-by: Vasilis Vryniotis <[email protected]>
1 parent fee6d12 commit c02d6ce

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

test/test_transforms.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1522,10 +1522,10 @@ def test_ten_crop(should_vflip, single_dim):
15221522
five_crop.__repr__()
15231523

15241524
if should_vflip:
1525-
vflipped_img = img.transpose(Image.FLIP_TOP_BOTTOM)
1525+
vflipped_img = img.transpose(_pil_constants.FLIP_TOP_BOTTOM)
15261526
expected_output += five_crop(vflipped_img)
15271527
else:
1528-
hflipped_img = img.transpose(Image.FLIP_LEFT_RIGHT)
1528+
hflipped_img = img.transpose(_pil_constants.FLIP_LEFT_RIGHT)
15291529
expected_output += five_crop(hflipped_img)
15301530

15311531
assert len(results) == 10

torchvision/transforms/_pil_constants.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
import PIL
21
from PIL import Image
32

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

7-
if tuple(int(part) for part in PIL.__version__.split(".")) >= (9, 1):
6+
if hasattr(Image, "Resampling"):
87
BICUBIC = Image.Resampling.BICUBIC
98
BILINEAR = Image.Resampling.BILINEAR
109
LINEAR = Image.Resampling.BILINEAR

0 commit comments

Comments
 (0)