LoginSignup
1
3

More than 5 years have passed since last update.

ONNX のモデルを JSON に変換する

Posted at

漢なら ONNX モデルを JSON に変換したいですね!

ONNX は中身は protobuf(+ numpy バイナリデータ?)なので,

tensorflow の GraphDef を JSON 形式でシリアライズ/デシリアライズする
https://qiita.com/syoyo/items/3a1a5b84fb7c37c9adf5

と似たようなやりかたで, google.protobuf.json_format で JSON に変換できました.

import onnx
from google.protobuf.json_format import MessageToJson

model = onnx.load('mnist/model.onnx')

j = MessageToJson(model)
print(j)

TODO

  • デシリアライズ時に onnx の protobuf 定義で JSON のチェックを行う
  • ONNX JSON schema ほしい
1
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
3