We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 6abc97f commit 2b3cabfCopy full SHA for 2b3cabf
sdks/python/apache_beam/examples/inference/pytorch_imagenet_rightfit.py
@@ -45,7 +45,7 @@
45
from apache_beam.transforms import userstate
46
from apache_beam.transforms import window
47
48
-from PIL.Image import Image
+import PIL.Image as PILImage
49
from google.cloud import pubsub_v1
50
from apache_beam.io.filesystems import FileSystems
51
@@ -73,7 +73,7 @@ def load_image_from_uri(uri: str) -> bytes:
73
74
def decode_and_preprocess(image_bytes: bytes, size: int = 224) -> torch.Tensor:
75
"""Decode bytes->RGB PIL->resize/crop->tensor->normalize."""
76
- with Image.open(io.BytesIO(image_bytes)) as img:
+ with PILImage.open(io.BytesIO(image_bytes)) as img:
77
img = img.convert("RGB")
78
img.thumbnail((256, 256))
79
w, h = img.size
0 commit comments