Docker Image supports gPRC + protobuf, and REST + JSON
Prepare the Model Servables
# //src - default working directory
# in order to avoid sending all //src/serving into docker build
$ mkdir -p ./rest/tf_servables
$ cp -r ./serving/tf_servables/slim ./rest/tf_servables
$ cd rest
Prepare REST client and server
$ cp -rL ../serving/bazel-bin/tensorflow_serving/example/slim_unified_client.runfiles/tf_serving/tensorflow_serving ./
$ [sudo] rm -r ./tensorflow_serving/example
# <git-repo>//src/rest/slim_unified_client_rest.py
# <git-repo>//src/rest/slim_unified_client_rest.ini
Dockerfile
# <git-repo>//src/rest/Dockerfile
Prepare Docker Init Script
# <git-repo>//src/rest/init.sh
Docker Image
//src/rest
$ docker build -t yg-tfs-slim:rest -f Dockerfile .
Run and Inspect Image
$ docker run -p 9000:9000 -p 9090:9090 -p 80:80 -it yg-tfs-slim:rest
//src/serving
$ bazel-bin/tensorflow_serving/example/slim_inception_resnet_v2_client \
--server=localhost:9000 \
--image_url=https://upload.wikimedia.org/wikipedia/commons/d/d9/First_Student_IC_school_bus_202076.jpg
$ curl -X GET 127.0.0.1:80
$ curl -X POST 127.0.0.1:80 -d '{"image_urls": ["https://upload.wikimedia.org/wikipedia/commons/d/d9/First_Student_IC_school_bus_202076.jpg", "https://upload.wikimedia.org/wikipedia/commons/thumb/9/90/Labrador_Retriever_portrait.jpg/1200px-Labrador_Retriever_portrait.jpg", "https://upload.wikimedia.org/wikipedia/commons/f/fd/Qantas_a380_vh-oqa_takeoff_heathrow_arp.jpg"]}'
Push to Public
$ docker tag yg-tfs-slim:rest gyang274/yg-tfs-slim:rest
$ docker login
$ docker push gyang274/yg-tfs-slim:rest