Intel® DevCloud
Help for those needing help starting or connecting to the Intel® DevCloud
1523 Discussions

ow do I transform Keras Model to Tensorflow Frozen Graph for use with openvino


Welcome to our Intel® DevCloud Forum.Please bring up any Intel AI/DevCloud issues you are facing here.

Some of the frequently asked questions on DevCloud are given here for quick reference

Sharing a commonly asked question on OpenVINO as it might be useful to many:


Question: How do I transform Keras Model to Tensorflow Frozen Graph for use with openvino?

Answer: Keras utilizes the h5 or hdf5 file format when saving its model. If we want to use our model outside of Keras, in OpenVINO, we need a frozen pb file to pass in when using a Tensorflow model. We can do that directly from Keras by utilizing the below functions. First we need to make sure that you set the learning phase to 0 or you might end up not correctly getting the output node from the session. Then we grab the session and output names and pass them to graph_util.convert_variables_to_constants ( If you have a trained graph containing Variable ops, it can be convenient to convert them all to Const ops holding the same values. This makes it possible to describe the network fully with a single GraphDef file, and allows the removal of a lot of ops related to loading and saving the variables. And then we pass that constant graph to graph_io.write_graph which writes the graph proto to a file.


An Example code is given below:


from tensorflow.python.framework import graph_util

from tensorflow.python.framework import graph_io


input_model_path = top_layers_file_path

output_model_name = "top_nodes.iv3.pb"

output_model_dir = "tf_model"



sess = K.get_session()


test_model = models.load_model(input_model_path)

orig_output_node_names = [ for node in test_model.outputs]


constant_graph = graph_util.convert_variables_to_constants( sess, sess.graph.as_graph_def(), orig_output_node_names)

graph_io.write_graph( constant_graph, output_model_dir, output_model_name, as_text=False)


Links & will give more details


For issues on connectivity to DevCloud, the attached document will give you some basic steps to troubleshoot the problem


Question: I need to use XXXX in DevCloud. Installation/Build of XXXX requires certain sudo installations. Could you please help me with that?

Answer: Please check if the pretrained models from will solve your problem.

If not, then the next option is to build XXXX from source. If the build from source needs any system level dependencies, check if conda installs help.

For this,

           1. Create a new conda environment.

           2. Check if conda version of the dependency library exists.

           3. If yes, then do a conda install in the environment.


Unfortunately, the Devcloud Admin team will not cater to requests to install packages at system level.



0 Kudos
0 Replies