You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beam.apache.org by vt...@apache.org on 2026/01/29 11:18:07 UTC

(beam) 17/18: Fix inference

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

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

commit 2d399b2bf0ad211e1f3d4d0e2e7ffc8b9867588b
Author: Vitaly Terentyev <vi...@akvelon.com>
AuthorDate: Thu Jan 22 18:08:37 2026 +0400

    Fix inference
---
 .../apache_beam/examples/inference/pytorch_image_captioning.py       | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/sdks/python/apache_beam/examples/inference/pytorch_image_captioning.py b/sdks/python/apache_beam/examples/inference/pytorch_image_captioning.py
index 498c1c214c0..6b3f21c0d41 100644
--- a/sdks/python/apache_beam/examples/inference/pytorch_image_captioning.py
+++ b/sdks/python/apache_beam/examples/inference/pytorch_image_captioning.py
@@ -111,7 +111,10 @@ class PostProcessDoFn(beam.DoFn):
 
   def process(self, kv: Tuple[str, PredictionResult]):
     image_id, pred = kv
-    inf = pred.inference or {}
+    if hasattr(pred, "inference"):
+      inf = pred.inference or {}
+    else:
+      inf = pred
     # Expected inference fields from CLIP handler:
     # best_caption, best_score, candidates, scores, blip_ms, clip_ms, total_ms
     best_caption = inf.get("best_caption", "")