Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Voxxed Days Belgrade 2017: Deploying Image Reco...

Casey West
October 19, 2017

Voxxed Days Belgrade 2017: Deploying Image Recognition with TensorFlow and Kubernetes

Casey West

October 19, 2017
Tweet

More Decks by Casey West

Other Decks in Technology

Transcript

  1. Enhance! Deploying Image Recognition with TensorFlow and Kubernetes Casey West

    ! @caseywest @googlecloud @VoxxedBelgrade #" #VBD17 #machinelearning #tensorflow #kubernetes 1
  2. I am… —Dad, software architect, technical lead, change agent, programmer,

    beverage enthusiast, rock climber, cyclist, acro yoga person… —An Architecture Advocate at Google. I am not… —A data scientist. —An expert in machine learning. ! @caseywest @googlecloud @VoxxedBelgrade #" #VBD17 #machinelearning #tensorflow #kubernetes 2
  3. I know enough to be dangerous. ! @caseywest @googlecloud @VoxxedBelgrade

    #" #VBD17 #machinelearning #tensorflow #kubernetes 4
  4. In 40 minutes you will also know enough to be

    dangerous. ! ! @caseywest @googlecloud @VoxxedBelgrade #" #VBD17 #machinelearning #tensorflow #kubernetes 5
  5. Project Plan —Phase 0: Understand ML Basics —Phase 1: Create

    TensorFlow Serving model —Phase 2: Create TensorFlow Serving client app —Phase 3: Deploy on Kubernetes —Phase 4: Play! ! @caseywest @googlecloud @VoxxedBelgrade #" #VBD17 #machinelearning #tensorflow #kubernetes 7
  6. Training a Model 1. Data 2. Time 3. Procedure !

    @caseywest @googlecloud @VoxxedBelgrade #" #VBD17 #machinelearning #tensorflow #kubernetes 10
  7. Training a Model 1. Data Historical or available data. !

    @caseywest @googlecloud @VoxxedBelgrade #" #VBD17 #machinelearning #tensorflow #kubernetes 11
  8. Training a Model 2. Time Iterations you have time to

    make. ! @caseywest @googlecloud @VoxxedBelgrade #" #VBD17 #machinelearning #tensorflow #kubernetes 12
  9. Training a Model 3. Procedure Discover data preparation procedures, an

    algorithm to use, and how to configure it. ! @caseywest @googlecloud @VoxxedBelgrade #" #VBD17 #machinelearning #tensorflow #kubernetes 13
  10. Training a Model: Steps 1. Get a data set. 2.

    Split it into training and testing data. 3. Train the algorithm. 4. Test the algorithm. 5. Ship it! ! @caseywest @googlecloud @VoxxedBelgrade #" #VBD17 #machinelearning #tensorflow #kubernetes 14
  11. Training a Model: Know More in Five Minutes https://www.youtube.com/watch?v=2FmcHiLCwTU —

    Siraj Raval ! @caseywest @googlecloud @VoxxedBelgrade #" #VBD17 #machinelearning #tensorflow #kubernetes 15
  12. Serving the model with TensorFlow Serving —Continuous training pipeline —gRPC

    interface —Production ready https://www.tensorflow.org/serving/ ! @caseywest @googlecloud @VoxxedBelgrade #" #VBD17 #machinelearning #tensorflow #kubernetes 17
  13. Pre-trained models exist! ! Let's containerize them before they get

    away! ! @caseywest @googlecloud @VoxxedBelgrade #" #VBD17 #machinelearning #tensorflow #kubernetes 18
  14. Create a Docker Image: TensorFlow Serving Inception v3 Docker Machine

    docker-machine create \ --driver google \ --google-project goog-caseywest \ --google-zone us-central1-a \ --google-machine-type n1-standard-4 \ docker-machine eval $(docker-machine env docker-machine) ! @caseywest @googlecloud @VoxxedBelgrade #" #VBD17 #machinelearning #tensorflow #kubernetes 19
  15. Create a Docker Image: TensorFlow Serving Inception v3 Run developer

    container git clone [email protected]:tensorflow/serving.git cd serving docker build --pull \ -t $USER/tensorflow-serving-devel \ -f tensorflow_serving/tools/docker/Dockerfile.devel . docker run --name=inception_container -it \ $USER/tensorflow-serving-devel ! @caseywest @googlecloud @VoxxedBelgrade #" #VBD17 #machinelearning #tensorflow #kubernetes 20
  16. Create a Docker Image: TensorFlow Serving Inception v3 Build in

    the devel the container git clone --recurse-submodules \ https://github.com/tensorflow/serving cd serving/tensorflow ./configure # interactive :-( cd .. bazel build -c opt tensorflow_serving/... ! @caseywest @googlecloud @VoxxedBelgrade #" #VBD17 #machinelearning #tensorflow #kubernetes 21
  17. Create a Docker Image: TensorFlow Serving Inception v3 Export inception

    in the devel the container curl -LO http://cwe.st/tf-inception-v3 tar xzf inception-v3-2016-03-01.tar.gz bazel-bin/tensorflow_serving/example/inception_saved_model \ --checkpoint_dir=inception-v3 \ --output_dir=inception-export ! @caseywest @googlecloud @VoxxedBelgrade #" #VBD17 #machinelearning #tensorflow #kubernetes 22
  18. Create a Docker Image: TensorFlow Serving Inception v3 Commit and

    deploy container docker commit inception_container \ $USER/inception_serving docker tag $USER/inception_serving \ gcr.io/goog-caseywest/inception gcloud docker -- push \ gcr.io/goog-caseywest/inception ! @caseywest @googlecloud @VoxxedBelgrade #" #VBD17 #machinelearning #tensorflow #kubernetes 23
  19. The Machines Have Already Learned Using ML isn't doing ML.

    ! @caseywest @googlecloud @VoxxedBelgrade #" #VBD17 #machinelearning #tensorflow #kubernetes 24
  20. Deploy Inception Service on Kubernetes Create a cluster gcloud container

    clusters create \ image-recognition-cluster \ --num-nodes 5 ! @caseywest @googlecloud @VoxxedBelgrade #" #VBD17 #machinelearning #tensorflow #kubernetes 25
  21. We did it! ! ! @caseywest @googlecloud @VoxxedBelgrade #" #VBD17

    #machinelearning #tensorflow #kubernetes 27
  22. Takeaways —Training models is hard. —Serving models is kind of

    easy. —gRPC and protobuf have steep learning curves. —therefore, client libraries are challenging. ! @caseywest @googlecloud @VoxxedBelgrade #" #VBD17 #machinelearning #tensorflow #kubernetes 28
  23. Want the code? —DM me @caseywest —Email me [email protected] —Try

    a similar tutorial —https://tensorflow.github.io/serving/ serving_inception ! @caseywest @googlecloud @VoxxedBelgrade #" #VBD17 #machinelearning #tensorflow #kubernetes 29
  24. Want to try more ML? —TensorFlow —https://www.tensorflow.org/ —MXNet —http://mxnet.io/ —Google

    Cloud Playground —https://cloud.google.com/vision/ ! @caseywest @googlecloud @VoxxedBelgrade #" #VBD17 #machinelearning #tensorflow #kubernetes 30
  25. Let's be friends @caseywest ! ! @caseywest @googlecloud @VoxxedBelgrade #"

    #VBD17 #machinelearning #tensorflow #kubernetes 31