zmyzhou
zmyzhou

Reputation: 63

How to convert FlatBuffer message from binary to human readable text format with Python?

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?

Upvotes: 5

Views: 2359

Answers (1)

Aardappel
Aardappel

Reputation: 6074

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 [--raw-binary] --json myschema.fbs -- mybinary.bin results in mybinary.json. If there is no file_identifier, you need file_identifier

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.

Upvotes: 2

Related Questions