SnapML sample code throws error
Hi,
I'm following the instructions on https://lensstudio.snapchat.com/guides/machine-learning/ml-frameworks/export-from-tensorflow/ in order to freeze a TensorFlow PB file .
I am using the recommended version 1.15 for TensorFlow.
This is the error I get.
python3 freeze.py
Traceback (most recent call last):
File "freeze.py", line 17, in <module>
saved_model_tags=tag_constants.SERVING)
TypeError: 'module' object is not callable
thanks
thanks
-
Correct definition is
def freeze_graph(input_graph, input_saver, input_binary, input_checkpoint, output_node_names, restore_op_name, filename_tensor_name, output_graph, clear_devices, initializer_nodes, variable_names_whitelist="", variable_names_blacklist="", input_meta_graph=None, input_saved_model_dir=None, saved_model_tags=tag_constants.SERVING, checkpoint_version=saver_pb2.SaverDef.V2): Comment actions -
Here's code that worked for me
from tensorflow.python.tools import freeze_graph
from tensorflow.python.saved_model import tag_constants
freeze_graph.freeze_graph(input_graph=None,
input_saver=None,
input_binary=False,
input_checkpoint=None,
output_node_names="xxx",
restore_op_name=None,
filename_tensor_name=None,
output_graph='frozen_graph.pb',
clear_devices=False,
initializer_nodes="",
variable_names_whitelist="",
variable_names_blacklist="",
input_meta_graph=None,
input_saved_model_dir=".",
saved_model_tags=tag_constants.SERVING)
Comment actions -
This code snippet provided also has errors:
def export_from_frozen_graph(frozen_graph_filename,
input_node_names=['placeholder'],
output_node_names=['output'],
output_filename='frozen_graph.pb',
optimize=True):
tf.reset_default_graph()
graph_def = tf.GraphDef()
with tf.gfile.GFile(frozen_graph_dir, "rb") as f:
frozen_graph_dir should be replaced with frozen_graph_filename
Comment actions -
The following lines should be removed as well from the sample snippet as nowhere in the page it says the code is running on google collab
# download frozen graph from google.colab import files files.download('mobilenet_v1_optimized.pb')
Comment actions -
Thanks a lot for feedback, Marco!
Comment actions -
Hi Marco, thanks for the feedback! We've updated the Tensorflow guide and changes should be reflected shortly.
Comment actions
Please sign in to leave a comment.
Have a comment?