Make BaseOptions to pass absolute path to C++ layer.
PiperOrigin-RevId: 492296573
This commit is contained in:
parent
40eb0e6385
commit
fd79f18aeb
|
@ -14,6 +14,7 @@
|
||||||
"""Base options for MediaPipe Task APIs."""
|
"""Base options for MediaPipe Task APIs."""
|
||||||
|
|
||||||
import dataclasses
|
import dataclasses
|
||||||
|
import os
|
||||||
from typing import Any, Optional
|
from typing import Any, Optional
|
||||||
|
|
||||||
from mediapipe.tasks.cc.core.proto import base_options_pb2
|
from mediapipe.tasks.cc.core.proto import base_options_pb2
|
||||||
|
@ -49,10 +50,14 @@ class BaseOptions:
|
||||||
@doc_controls.do_not_generate_docs
|
@doc_controls.do_not_generate_docs
|
||||||
def to_pb2(self) -> _BaseOptionsProto:
|
def to_pb2(self) -> _BaseOptionsProto:
|
||||||
"""Generates a BaseOptions protobuf object."""
|
"""Generates a BaseOptions protobuf object."""
|
||||||
|
if self.model_asset_path is not None:
|
||||||
|
full_path = os.path.abspath(self.model_asset_path)
|
||||||
|
else:
|
||||||
|
full_path = None
|
||||||
|
|
||||||
return _BaseOptionsProto(
|
return _BaseOptionsProto(
|
||||||
model_asset=_ExternalFileProto(
|
model_asset=_ExternalFileProto(
|
||||||
file_name=self.model_asset_path,
|
file_name=full_path, file_content=self.model_asset_buffer))
|
||||||
file_content=self.model_asset_buffer))
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@doc_controls.do_not_generate_docs
|
@doc_controls.do_not_generate_docs
|
||||||
|
|
Loading…
Reference in New Issue
Block a user