8

Will the support for frozen graph continue in tensorflow 2.0 or deprecated? I mean the scripts and APIs to create/optimize frozen graph from saved_model. Also the APIs to run the inference for the same.

Assuming it will be supported in future, what is the recommended method to run the inference on frozen graph in tensorflow 2.0 ?

kumar desappan
  • 131
  • 1
  • 1
  • 10
  • what do you mean by frozen graph? – abunickabhi Apr 07 '19 at 18:07
  • 2
    Most of the time, tensorflow 1.x models are shared by freezing the graph for inference. You can refer this for more details on : https://github.com/tensorflow/tensorflow/blob/master/tensorflow/python/tools/freeze_graph.py – kumar desappan Apr 08 '19 at 14:49

3 Answers3

8

The freeze graph APIs - freeze_graph.py and converter_variables_to_constants - will not be supported in TensorFlow 2.0.

In 2.0, the primary export format is SavedModels so APIs are built to directly support SavedModels. Inference on existing frozen graphs can be run using the v1.compat path.

Nupur Garg
  • 524
  • 2
  • 9
2

Now, freeze_graph is officially gone with TensorFlow 2.0 stable release.

Check Here.

enter image description here

Praveen Kulkarni
  • 2,816
  • 1
  • 23
  • 39
0

if you use estimator to biuld a model, you can using tf.estimator.Estimator.export_saved_model to freeze your model.

model = tf.estimator.Estimator(
    model_fn=model_fn, 
    model_dir=model_saved_dir)

def serving_input_receiver_fn():
    # in here, my input is 512 x 512 single channel image
    feature = tf.compat.v1.placeholder(tf.float32, shape=[None, 512, 512, 1], name="inputs")
    return tf.estimator.export.TensorServingInputReceiver(feature, feature)

model.export_saved_model(model_saved_dir, serving_input_receiver_fn)

this code is work in tensorflow 2.0

or you use keras, You can refer to the steps of the official website https://www.tensorflow.org/tutorials/keras/save_and_load#savedmodel_format