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 e2b4f73b297ccd706cb48b0be96e9f4ac41aa383 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]
