3

I am writing a tool to dump our dedicated ML model from flatbuffers binary into human readable text format, is there any helper like text_format for protobuf?

zmyzhou
  • 43
  • 3

1 Answers1

1

There's currently no way to do that directly in Python, you'll need to invoke the command-line flatc tool to do so, e.g. flatc --json myschema.fbs mybinary.bin results in mybinary.json.

If necessary, it would be possible to compile the C++ json generator (and parser) into something that can be called from Python (through C), but that requires knowledge on how to create such extension libraries for Python.

Aardappel
  • 5,559
  • 1
  • 19
  • 22
  • Thanks Aardappel. In practice I found we need to add a `--` between shema file and binary file, it may also require a `--raw_binary` argument if there are not `file_identifier`. For those who has a similar requirment, please refer to [here](https://google.github.io/flatbuffers/flatbuffers_guide_using_schema_compiler.html) for details. – zmyzhou Oct 30 '19 at 09:43
  • Ah yes, forgot :) – Aardappel Oct 30 '19 at 16:58