通过 CLI 序列化和反序列化 protobufs?
我正在尝试通过 CLI 反序列化保存为 protobuf 的文件(这似乎是最简单的事情).我宁愿不使用 protoc 编译,将其导入编程语言,然后读取结果.
I am trying to deserialize a file saved as a protobuf through the CLI (seems like the easiest thing to do). I would prefer not to use protoc to compile, import it into a programming language and then read the result.
我的用例:TensorFlow lite 工具以 protobuf 格式输出一些数据.我也在 TensorFlow 存储库中找到了 protobuf message
定义.我只想快速阅读输出.具体来说,我从 inference_diff
工具.
My use case: A TensorFlow lite tool has output some data in a protobuf format. I've found the protobuf message
definition in the TensorFlow repo too. I just want to read the output quickly. Specifically, I am getting back a tflite::evaluation::EvaluationStageMetrics
message from the inference_diff
tool.
我假设该工具以二进制格式输出 protobuf 消息.
I assume that the tool outputs a protobuf message in binary format.
protoc 可以解码消息并以文本格式输出.请参阅此选项:
protoc can decode the message and output in text format. See this option:
--decode=MESSAGE_TYPE Read a binary message of the given type from
standard input and write it in text format
to standard output. The message type must
be defined in PROTO_FILES or their imports.