Skip to content

Instantly share code, notes, and snippets.

@nanmi
Last active September 27, 2021 09:22
Show Gist options
  • Save nanmi/23f8aa7a2ca6fb65dc96b68be9b83da4 to your computer and use it in GitHub Desktop.
Save nanmi/23f8aa7a2ca6fb65dc96b68be9b83da4 to your computer and use it in GitHub Desktop.
解析onnx文件

解析ONNX文件

参考link: https://www.youtube.com/watch?v=QZQwmZTfLmI

安装Protobuf3.x

link: https://github.com/protocolbuffers/protobuf/releases

下载onnx.proto3

link: https://github.com/onnx/onnx/blob/master/onnx/onnx.proto3

解析onnx

将onnx模型和onnx.proto3放在同一文件夹

解码:

protoc --decode onnx.ModelProto onnx.proto3 < {your onnx model}.onnx > {model}.onnx.txt

编码:

protoc --encode onnx.ModelProto onnx.proto3 < {model}.onnx.txt > {your modified onnx model}.onnx

注意:< >符号不能少

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment