Convert graph (pb) to SavedModel for gcloud ml-engine predicts

I trained an object detector using the Learning Machine Learning engine in accordance with the recent Googles Derek Chow blog post on Google Data Big Data And Machine Learning a> and now want to predict the use of the engine for learning in the cloud.

The instructions include code for exporting the Tensorflow graph as output_inference_graph.pb, but not how to convert the protobuf (pb) format to the SavedModel format needed to predict gcloud ml-engine.

I reviewed Googles @ rhaertel80 's answer on how to convert the Tensorflow For Poets image classification model and the answer provided by Googles @MarkMcDonald on how to convert the Tensorflow For Poets 2 image classification model, but none of them work for the object detection graph (pb) described in the blog post.

How to convert this object detector (pb) so that it can be used, or gcloud ml-engine predicts please?

+4
source share
1 answer

SavedModel MetaGraphDef , SavedModel GraphDef python, , .

export_dir = ...
...
builder = tf.saved_model.builder.SavedModelBuilder(export_dir)
with tf.Session(graph=tf.Graph()) as sess:
  ...
  builder.add_meta_graph_and_variables(sess,
                                       [tag_constants.TRAINING],
                                       signature_def_map=foo_signatures,
                                       assets_collection=foo_assets)
...
with tf.Session(graph=tf.Graph()) as sess:
  ...
  builder.add_meta_graph(["bar-tag", "baz-tag"])
...
builder.save()
+2

Source: https://habr.com/ru/post/1679671/


All Articles