-
Notifications
You must be signed in to change notification settings - Fork 298
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Transform ONNX to TF SavedModel #490
Comments
I also used tf.saved_model.simple_save to create a SavedModel in my prototype code for training. So I agree producing such models is a nice addition to the onnx-tf converter. One thing however, the simple_save function is deprecated, https://www.tensorflow.org/api_docs/python/tf/saved_model/simple_save. Since TF 2.0 should be released pretty soon, I would suggest to look into the new APIs or some other ways to create the SavedModel files. |
After a peek at tf2.0 codes, it seems and the codes can be found here I will try out the Python API later and post the results. |
I've tested the API on my own trained model tf.saved_model.save(model, "./model_path/") which works as expected. |
Yeah, we plan to support TF 2.0 in our 1.6 release (not in the immediate 1.5 release). |
Thank you for your work! |
This PR, #531, is supposed to address the TF 2.0 API issues. Please check it out and provide comments as working or not for you. Save as a SavedModel will be looked at next. |
Any update on this issue? I agree with @wjiuhe - this would be a nice feature. |
We are looking into export onnx models into SavedModel format, along with a few other general requirements and fixes. Will certainly give a high priority and provide updates soon. |
Quick update after first round of investigation, TF 2.0 seems to promote tf.function, eager mode, and SavedModel, while discourage direct use of tf.Graph [https://www.tensorflow.org/api_docs/python/tf/Graph#using_graphs_directly_deprecated] so I think we should eventually move away from operating directly on the graph. Use of tf.Module, which is supported in saved_model APIs, is what I have in mind. Since it's going to be a major overhaul of our code base, I would like to know whether there are better/easier ways to be aligned with TF 2.0 and future versions, where deprecated APIs might be completely removed. Comments and recommendations are welcome. |
With this TF2.0 API, does anyone know how we can export to SavedModel - is there a sample script someone has written for this? I know onnx-tf doesn't support it yet, but if anyone knows if there's a way to do it please let me know. |
We already have a prototype using tf.Module. Hope able to make it production soon. |
do you have example code? |
A simple code snippet: import numpy as np dtype = tf.float32 class OnnxTfBackend(tf.Module): class CastHandler(OnnxTfBackend): @tf.function class AddHandler(OnnxTfBackend): class GraphHandler(OnnxTfBackend):
########################################## tf.saved_model.save(m, path) m2 = tf.saved_model.load(path) print(m2(tf.constant([1]), tf.constant([2]))) |
it will work for tensorflow version 1.15.0 |
Any updates on the progress? |
Looking for this update! Meanwhile. This prototype code works? |
any update, I really need this now |
@chinhuang007 Hi, Can we expect TF2-saved_models.pb support during the month? |
Currently, SavedModel format is commonly used in Tensorflow, especially in Tensorflow Serving.
Will you think about supporting tranforming ONNX to TF SavedModel?
I tried out a piece of codes based on existing codes, although the implementation is far from good, it worked in my scenario.
It will be convenient if the transformation to SavedModel is implemented, for example:
FYI, below is the existing codes I use as the reference and the piece of codes I've tested.
The text was updated successfully, but these errors were encountered: