From f5197a3adc3d5ee309cbca02b6a32c5699eee5ac Mon Sep 17 00:00:00 2001 From: MediaPipe Team Date: Fri, 14 Apr 2023 13:00:44 -0700 Subject: [PATCH] Expose get_graph_config function for task_runner. PiperOrigin-RevId: 524365682 --- mediapipe/tasks/python/core/pybind/task_runner.cc | 5 +++++ mediapipe/tasks/python/vision/core/base_vision_task_api.py | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/mediapipe/tasks/python/core/pybind/task_runner.cc b/mediapipe/tasks/python/core/pybind/task_runner.cc index aa48a1a9a..250c0fa62 100644 --- a/mediapipe/tasks/python/core/pybind/task_runner.cc +++ b/mediapipe/tasks/python/core/pybind/task_runner.cc @@ -204,6 +204,11 @@ This can be useful for resetting a stateful task graph to process new data. Raises: RuntimeError: The underlying medipaipe graph fails to reset and restart. )doc"); + + task_runner.def( + "get_graph_config", + [](TaskRunner* self) { return self->GetGraphConfig(); }, + R"doc(Returns the canonicalized CalculatorGraphConfig of the underlying graph.)doc"); } } // namespace python diff --git a/mediapipe/tasks/python/vision/core/base_vision_task_api.py b/mediapipe/tasks/python/vision/core/base_vision_task_api.py index eb976153e..d9195d3ce 100644 --- a/mediapipe/tasks/python/vision/core/base_vision_task_api.py +++ b/mediapipe/tasks/python/vision/core/base_vision_task_api.py @@ -208,6 +208,11 @@ class BaseVisionTaskApi(object): """ self._runner.close() + def get_graph_config(self) -> calculator_pb2.CalculatorGraphConfig: + """Returns the canonicalized CalculatorGraphConfig of the underlying graph. + """ + return self._runner.get_graph_config() + def __enter__(self): """Return `self` upon entering the runtime context.""" return self