Deploy Retrained inception model on Google cloud machine learning

拥有回忆 提交于 2019-12-02 01:58:11

问题


I manage to retrain my specific classification model using the generic inception model following this tutorial. I would like now to deploy it on the google cloud machine learning following this steps.

I already managed to export it as MetaGraph but I can't manage to get the proper inputs and outputs.

Using it locally, my entry point to the graph is DecodeJpeg/contents:0 which is fed with a jpeg image in binary format. The output are my predictions.

The code I use locally (which is working) is:

softmax_tensor = sess.graph.get_tensor_by_name('final_result:0')
predictions = sess.run(softmax_tensor,{'DecodeJpeg/contents:0': image_data})

Should the input tensor be DecodeJpeg? What would be the changes I need to make if I would like to have a base64 image as input ?

I defined the output as:

outputs = {'prediction':softmax_tensor.name}

Any help is highly appreciated.


回答1:


In your example, the input tensor is 'DecodeJpeg/contents:0', so you would have something like:

inputs = {'image': 'DecodeJpeg/contents:0')
outputs = {'prediction': 'final_result:0')

(Be sure to follow all of the instructions for preparing a model).

The model directory you intend to export should have files such as:

gs://my_bucket/path/to/model/export.meta
gs://my_bucket/path/to/model/checkpoint*

When you deploy your model, be sure to set gs://my_bucket/path/to/model as the deployment_uri.

To send an image to the service, as you suggest, you will need to base64 encode the image bytes. The body of your request should look like the following (note the 'tag', 'b64', indicating the data is base-64 encoded):

{'instances': [{'b64': base64.b64encode(image)}]}



回答2:


We've now released a tutorial on how to retrain the Inception model, including instructions for how to deploy the model on the CloudML service.

https://cloud.google.com/blog/big-data/2016/12/how-to-train-and-classify-images-using-google-cloud-machine-learning-and-cloud-dataflow



来源:https://stackoverflow.com/questions/39978526/deploy-retrained-inception-model-on-google-cloud-machine-learning

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!