简体   繁体   中英

Convert frozen graph from .pb to .onnx

I have a TensorFlow graph frozen as a .pb , and I would like to convert it into the .onnx format. I am currently trying using mmconvert (from Microsoft's MMdnn ) and apparently I am doing something wrong (see code below). Is there any other recommended approach for converting a .pb into an .onnx ? Thanks.

Here's the command I am using:

mmconvert -sf tensorflow -iw /frozen_models/model.pb --inNodeName input --inputShape 512 -df onnx -om tf_mobilenet --inNodeName input

Which gives the error

ValueError: Need to provide the output node of Tensorflow model.

The Onnx format requires an output node to be specified in the model. A quick glance suggests mmconvert expects that to be specified with --dstNode.

If you're converting a TensorFlow graph to an Onnx Graph, you could also use tf2onnx .

You would convert the model with the command:

python -m tf2onnx.convert --input /frozen_models/model.pb --inputs input --outputs outputNodeName --outputoutput tf_mobilenet.onnx

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM