Skip to content
Home » How to convert onnx model to tensorflow saved model

How to convert onnx model to tensorflow saved model

There are few ways to convert onnx model to tensorflow saved model. Some of the ways are described below.

Method 1:

1. Firstly, install the onnx-tensorflow using pip install onnx-tf

2. Then run the following command to convert the onnx to tf saved model : onnx-tf convert -t tf -i /path_to/input_file.onnx -o /path_to/output_file.pb

Method 2:

Run the below code by modifying the paths of the file in the below code. Comment which got while running the below code.

#import the following packages 
# Use pip install onnx if face errors while importing onnx
import onnx
from onnx_tf.backend import prepare

# load the onnx model by giving the path
onnx_model = onnx.load("replace_with_input_path_of_file")  

tf_conv = prepare(onnx_model)

# export the converted model
tf_conv.export_graph("output_path_to_store_file")