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