Skip to content

Commit 044eacd

Browse files
committed
Manual parsing of PIL version
1 parent 1dfd59d commit 044eacd

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

test/common_utils.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
from subprocess import CalledProcessError, check_output, STDOUT
1313

1414
import numpy as np
15+
import PIL
1516
import pytest
1617
import torch
1718
import torch.testing

torchvision/utils.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,12 @@
88

99
import numpy as np
1010
import torch
11-
from PIL import Image, ImageColor, ImageDraw, ImageFont
11+
from PIL import __version__ as PILLOW_VERSION, Image, ImageColor, ImageDraw, ImageFont
1212

13+
PILLOW_VERSION = tuple(int(x) for x in PILLOW_VERSION.split("."))
1314

1415
__all__ = [
16+
"_Image_fromarray",
1517
"make_grid",
1618
"save_image",
1719
"draw_bounding_boxes",
@@ -183,7 +185,6 @@ def _Image_fromarray(
183185
mode paramter. See:
184186
https://pillow.readthedocs.io/en/stable/releasenotes/11.3.0.html#image-fromarray-mode-parameter
185187
"""
186-
PILLOW_VERSION = tuple(int(x) for x in PIL.__version__.split("."))
187188
if PILLOW_VERSION >= (11, 3):
188189
return Image.fromarray(obj)
189190
else:

0 commit comments

Comments
 (0)