Skip to content

Commit 2b3cabf

Browse files
committed
Fix import PILImage
1 parent 6abc97f commit 2b3cabf

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

sdks/python/apache_beam/examples/inference/pytorch_imagenet_rightfit.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
from apache_beam.transforms import userstate
4646
from apache_beam.transforms import window
4747

48-
from PIL.Image import Image
48+
import PIL.Image as PILImage
4949
from google.cloud import pubsub_v1
5050
from apache_beam.io.filesystems import FileSystems
5151

@@ -73,7 +73,7 @@ def load_image_from_uri(uri: str) -> bytes:
7373

7474
def decode_and_preprocess(image_bytes: bytes, size: int = 224) -> torch.Tensor:
7575
"""Decode bytes->RGB PIL->resize/crop->tensor->normalize."""
76-
with Image.open(io.BytesIO(image_bytes)) as img:
76+
with PILImage.open(io.BytesIO(image_bytes)) as img:
7777
img = img.convert("RGB")
7878
img.thumbnail((256, 256))
7979
w, h = img.size

0 commit comments

Comments
 (0)