Chu*_*ley 5 object-detection tensorflow google-cloud-ml google-cloud-ml-engine
根据Google 的 Derek Chow 最近在 Google Cloud Big Data And Machine Learning Blog 上的帖子,我使用 Cloud Machine Learning Engine 训练了一个对象检测器,现在想使用 Cloud Machine Learning Engine 进行预测。
说明包括将 Tensorflow 图导出为 output_inference_graph.pb 的代码,但不包括如何将 protobuf 格式 (pb) 转换为 gcloud ml-engine predict 所需的 SavedModel 格式。
我查看了Google 的 @rhaertel80关于如何转换“Tensorflow For Poets”图像分类模型的答案,以及 Google 的 @MarkMcDonald 提供的关于如何转换“Tensorflow For Poets 2”图像分类模型的答案,但似乎都不适用于博客文章中描述的对象检测器图 (pb)。
请如何转换该对象检测器图 (pb) 以便可以使用它或 gcloud ml-engine 预测?
小智 2
SavedModel在其结构中包含一个MetaGraphDef。要在 python 中从 GraphDef 创建 SavedModel,您可能需要使用链接中所述的构建器。
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()
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1326 次 |
| 最近记录: |