This is an automated email from the ASF dual-hosted git repository.

vterentev pushed a commit to branch oss-image-classification
in repository https://gitbox.apache.org/repos/asf/beam.git


The following commit(s) were added to refs/heads/oss-image-classification by 
this push:
     new 2b3cabf496c Fix import PILImage
2b3cabf496c is described below

commit 2b3cabf496c930a1eb12342aed6aa81cb9d08e12
Author: Vitaly Terentyev <[email protected]>
AuthorDate: Tue Nov 11 17:26:58 2025 +0400

    Fix import PILImage
---
 .../apache_beam/examples/inference/pytorch_imagenet_rightfit.py       | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git 
a/sdks/python/apache_beam/examples/inference/pytorch_imagenet_rightfit.py 
b/sdks/python/apache_beam/examples/inference/pytorch_imagenet_rightfit.py
index 4ae9657546c..e8915fda016 100644
--- a/sdks/python/apache_beam/examples/inference/pytorch_imagenet_rightfit.py
+++ b/sdks/python/apache_beam/examples/inference/pytorch_imagenet_rightfit.py
@@ -45,7 +45,7 @@ from apache_beam.runners.runner import PipelineResult
 from apache_beam.transforms import userstate
 from apache_beam.transforms import window
 
-from PIL.Image import Image
+import PIL.Image as PILImage
 from google.cloud import pubsub_v1
 from apache_beam.io.filesystems import FileSystems
 
@@ -73,7 +73,7 @@ def load_image_from_uri(uri: str) -> bytes:
 
 def decode_and_preprocess(image_bytes: bytes, size: int = 224) -> torch.Tensor:
   """Decode bytes->RGB PIL->resize/crop->tensor->normalize."""
-  with Image.open(io.BytesIO(image_bytes)) as img:
+  with PILImage.open(io.BytesIO(image_bytes)) as img:
     img = img.convert("RGB")
     img.thumbnail((256, 256))
     w, h = img.size

Reply via email to