onnx / onnx-tensorflow

Tensorflow Backend for ONNX
Other
1.27k stars 296 forks source link

onnx model import to tensorflow is superficial at best. #987

Open gggh000 opened 2 years ago

gggh000 commented 2 years ago

https://github.com/onnx/tutorials/blob/master/tutorials/OnnxTensorflowImport.ipynb Inspecting the code, it does not really import to tensorflow, not even sure why it is called importing to tf. the imported so cald tf_rep appears to be onnx's own stuff. does not fit into keras model https://www.tensorflow.org/api_docs/python/tf/keras/Model

Traceback (most recent call last): print("Loading onnx model...") model_import = onnx.load('output/p297.onnx') model = prepare(model_import) ... File ".py", line 68, in model.evaluate(X_test, y_test) AttributeError: 'TensorflowRep' object has no attribute 'evaluate'

I wondered if there is a dedicatd keras converstion but pitifully https://github.com/onnx/tutorials has conversion from onnx to keras but scoring section has none.

chinhuang007 commented 2 years ago

Please note Keras != Tensorflow. onnx-tf converts to Tensorflow, not Keras. tf_rep allows you to run an onnx model in Tensorflow environment. And there is CLI to convert and save an onnx model as a Tensorflow saved model, as described here, https://github.com/onnx/onnx-tensorflow/blob/master/doc/CLI.md

gggh000 commented 2 years ago

I did not say keras = tflow, where I did say that? I was not interested in cmd looking tool rather I was looking to use model structure in the tf. I am not exactly clear on what you mean by tf_rep running on tf environment.

chinhuang007 commented 2 years ago

Great to clarify Keras != Tensorflow. tf_rep running in TF environment means it is using TF APIs to execute the converted onnx model.