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


The following commit(s) were added to refs/heads/oss-image-cpu by this push:
     new 128dd3d8d2f Fix inference result
128dd3d8d2f is described below

commit 128dd3d8d2f021ef8d6c814d23995d7df16caca3
Author: Vitaly Terentyev <[email protected]>
AuthorDate: Thu Jan 22 15:25:00 2026 +0400

    Fix inference result
---
 .../examples/inference/pytorch_image_object_detection.py         | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git 
a/sdks/python/apache_beam/examples/inference/pytorch_image_object_detection.py 
b/sdks/python/apache_beam/examples/inference/pytorch_image_object_detection.py
index cb66e0f9dba..3512f75b24d 100644
--- 
a/sdks/python/apache_beam/examples/inference/pytorch_image_object_detection.py
+++ 
b/sdks/python/apache_beam/examples/inference/pytorch_image_object_detection.py
@@ -219,9 +219,12 @@ class PostProcessDoFn(beam.DoFn):
   def process(self, kv: Tuple[str, PredictionResult]):
     image_id, pred = kv
 
-    # pred.inference should be torchvision dict for this element,
-    # but keep robust fallback.
-    inference_obj = pred.inference
+    # pred can be PredictionResult OR raw torchvision dict.
+    if hasattr(pred, "inference"):
+      inference_obj = pred.inference
+    else:
+      inference_obj = pred
+
     if isinstance(inference_obj, list) and len(inference_obj) == 1:
       inference_obj = inference_obj[0]
 

Reply via email to