Skip to content

Instantly share code, notes, and snippets.

@tompizmor
Last active June 29, 2017 13:46
Show Gist options
  • Save tompizmor/309bbc53d40ccd41aec28b158f4befa1 to your computer and use it in GitHub Desktop.
Save tompizmor/309bbc53d40ccd41aec28b158f4befa1 to your computer and use it in GitHub Desktop.
tensorflow_inception_python_client.md

TensorFlow Inception Python Client

Below you will find instructions to run the inception_client without having to compile it with bazel.

1. Clone the following repo

We need the files predict_pb2.py and prediction_service_pb2.py and their dependencies.

$ git clone https://github.com/tobegit3hub/deep_recommend_system
$ cd deep_recommend_system/python_predict_client

2. Download inception_client.py script:

$ curl -JLO https://raw.githubusercontent.com/tensorflow/serving/master/tensorflow_serving/example/inception_client.py

3. Edit inception_client.py to import previous modules

$ sed -i 's/from tensorflow_serving.apis import predict_pb2/import predict_pb2/g' inception_client.py
$ sed -i 's/from tensorflow_serving.apis import prediction_service_pb2/import prediction_service_pb2/g' inception_client.py

4. Install all the dependencies:

$ pip install enum34 futures mock numpy grpcio tensorflow

If tensorflow has no candidates to install from pip you can try installing like this:

$ pip install https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-1.2.0-cp27-none-linux_x86_64.whl

5. Test the script:

Download an image:

$ curl -o 'labrador.jpg' 'http://cdn2-www.dogtime.com/assets/uploads/gallery/labrador-retriever-dog-breed-pictures/labrador-retriever-dog-pictures-7.jpg'

Query the server:

$ python inception_client.py --server=tensorflow-serving:9000 --image=labrador.jpg

NOTE: A tensorflow-serving server has to be running with hostnametensorflow-serving and port 9000. In order to launch a server you can check the tensorflow-inception helm chart

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment