Skip to content

Commit 68fe451

Browse files
authored
Fixed Pillow version check for Pillow >= 10 (#2039)
Co-authored-by: Andrew Murray <[email protected]>
1 parent a687b83 commit 68fe451

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

torchvision/transforms/functional.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,9 @@ def _parse_fill(fill, img, min_pil_version):
437437
Returns:
438438
dict: kwarg for ``fillcolor``
439439
"""
440-
if PILLOW_VERSION < min_pil_version:
440+
major_found, minor_found = (int(v) for v in PILLOW_VERSION.split('.')[:2])
441+
major_required, minor_required = (int(v) for v in min_pil_version.split('.')[:2])
442+
if major_found < major_required or (major_found == major_required and minor_found < minor_required):
441443
if fill is None:
442444
return {}
443445
else:
@@ -853,7 +855,7 @@ def affine(img, angle, translate, scale, shear, resample=0, fillcolor=None):
853855
output_size = img.size
854856
center = (img.size[0] * 0.5 + 0.5, img.size[1] * 0.5 + 0.5)
855857
matrix = _get_inverse_affine_matrix(center, angle, translate, scale, shear)
856-
kwargs = {"fillcolor": fillcolor} if PILLOW_VERSION[0] >= '5' else {}
858+
kwargs = {"fillcolor": fillcolor} if int(PILLOW_VERSION.split('.')[0]) >= 5 else {}
857859
return img.transform(output_size, Image.AFFINE, matrix, resample, **kwargs)
858860

859861

0 commit comments

Comments
 (0)