将经过重新训练的初始SavedModel部署到Google Cloud ml引擎 [英] Deploy retrained inception SavedModel to google cloud ml engine
问题描述
我正在尝试在Google Cloud ml-engine上部署初始模型的经过重新训练的版本.从 SavedModel文档收集信息参考,以及此
I am trying to deploy a retrained version of the inception model on google cloud ml-engine. Gathering informations from the SavedModel documentation, this reference, and this post of rhaertel80, I exported successfully my retrained model to a SavedModel, uploaded it to a bucket and tried to deploy it to a ml-engine version.
最后一个任务实际上创建了一个版本,但输出了此错误:
This last task actually creates a version, but it outputs this error:
Create Version failed. Bad model detected with error: "Error loading the model: Unexpected error when loading the model"
当我尝试通过命令行从模型中获取预测时,出现以下错误消息:
"message": "Field: name Error: Online prediction is unavailable for this version. Please verify that CreateVersion has completed successfully."
And when I try to get predictions from the model via commandline I get this error message:
"message": "Field: name Error: Online prediction is unavailable for this version. Please verify that CreateVersion has completed successfully."
我做了几次尝试,尝试使用不同的method_name
和tag
选项,但是没有用.
I have made several attempts, trying different method_name
and tag
options but none worked.
添加到原始初始代码中的代码是
The code added to the original inception code is
### DEFINE SAVED MODEL SIGNATURE
in_image = graph.get_tensor_by_name('DecodeJpeg/contents:0')
inputs = {'image_bytes': tf.saved_model.utils.build_tensor_info(in_image)}
out_classes = graph.get_tensor_by_name('final_result:0')
outputs = {'prediction': tf.saved_model.utils.build_tensor_info(out_classes)}
signature = tf.saved_model.signature_def_utils.build_signature_def(
inputs=inputs,
outputs=outputs,
method_name='tensorflow/serving/predict'
)
### SAVE OUT THE MODEL
b = saved_model_builder.SavedModelBuilder('new_export_dir')
b.add_meta_graph_and_variables(sess,
[tf.saved_model.tag_constants.SERVING],
signature_def_map={'predict_images': signature})
b.save()
可能会有所帮助的其他考虑因素:
我已经使用导出的trained_graph.pb
和graph_def.SerializeToString()
在本地获取了预测,并且效果很好,但是当我用saved_model.pb
替换它时,它就会失败.
Another consideration that might help:
I have used an exported a trained_graph.pb
with graph_def.SerializeToString()
to get the predictions locally and it works fine, but when I substitute it with the saved_model.pb
it fails.
关于问题可能有什么建议?
Any suggestions on what the issue might be?
推荐答案
在您的signature_def_map中,使用键"serving_default",该键在
In your signature_def_map, use the key 'serving_default', which is defined in signature_constants
as DEFAULT_SERVING_SIGNATURE_DEF_KEY
:
b.add_meta_graph_and_variables(sess,
[tf.saved_model.tag_constants.SERVING],
signature_def_map={'serving_default': signature})
这篇关于将经过重新训练的初始SavedModel部署到Google Cloud ml引擎的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!