Parag Jain
Parag Jain

Reputation: 662

How to convert Onnx model (.onnx) to Tensorflow (.pb) model

I am trying to convert .onxx model to .pb model. I have written the code but i am getting error:

@tf_func(tf.ceil)AttributeError: module 'tensorflow' has no attribute 'ceil'

Code:

import onnx
from tensorflow.python.tools.import_pb_to_tensorboard import import_to_tensorboard
from onnx_tf.backend import prepare
onnx_model = onnx.load("original_3dlm.onnx")
tf_rep = prepare(onnx_model)
tf_rep.export_graph("model_var.pb")
import_to_tensorboard("model_var.pb", "tb_log")

How to resolve this issue? Is there any other way to convert Onxx to Tensorflow?

Upvotes: 6

Views: 15854

Answers (2)

DarQ
DarQ

Reputation: 102

your code as far as I can tell should be fine. The problem probably lies in the onnx-tf version you currently use. pip currently installs a version that only supports TensorFlow <= 1.15. run this in the terminal to install a more up-to-date version of onnx-tf.

pip uninstall onnx_tf
pip install git+https://github.com/onnx/onnx-tensorflow.git

refer to this issue for further details

Upvotes: 1

Zrufy
Zrufy

Reputation: 453

I solve this issue with this. Tensorflow Backend for ONNX. Let me know if you have any issue. Change from tensorflow 2.0 to 1.14.Maybe solve the problem.

Upvotes: 5

Related Questions