Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to serve retrained Inception model using Tensorflow Serving?

So I have trained inception model to recognize flowers according to this guide. https://www.tensorflow.org/versions/r0.8/how_tos/image_retraining/index.html

bazel build tensorflow/examples/image_retraining:retrain
bazel-bin/tensorflow/examples/image_retraining/retrain --image_dir ~/flower_photos

To classify the image via command line, I can do this:

bazel build tensorflow/examples/label_image:label_image && \
bazel-bin/tensorflow/examples/label_image/label_image \
--graph=/tmp/output_graph.pb --labels=/tmp/output_labels.txt \
--output_layer=final_result \
--image=$HOME/flower_photos/daisy/21652746_cc379e0eea_m.jpg

But how do I serve this graph via Tensorflow serving?

The guide about setting up Tensorflow serving (https://tensorflow.github.io/serving/serving_basic) does not tell how to incorporate the graph (output_graph.pb). The server expects the different format of file:

$>ls /tmp/mnist_model/00000001
checkpoint export-00000-of-00001 export.meta
like image 440
arjunaskykok Avatar asked May 15 '16 11:05

arjunaskykok


People also ask

What is TensorFlow model serving?

“TensorFlow Serving is a flexible, high-performance serving system for machine learning models, designed for production environments. TensorFlow Serving makes it easy to deploy new algorithms and experiments while keeping the same server architecture and APIs.

What's the name of the package you install to get TensorFlow serving?

TensorFlow Serving Python API PIP package.


1 Answers

To serve the graph after you have trained it, you would need to export it using this api: https://www.tensorflow.org/versions/r0.8/api_docs/python/train.html#export_meta_graph

That api generates the metagraph def that is needed by the serving code ( this will generate that .meta file you are asking about)

Also, you need to restore a checkpoint using Saver.save() which is the Saver class https://www.tensorflow.org/versions/r0.8/api_docs/python/train.html#Saver

Once you have done this, you will both the metagraph def and the checkpoint files that are needed to restore the graph.

like image 198
Bhupesh Avatar answered Nov 25 '22 13:11

Bhupesh