TensorFlow Serving client examples

TensorFlow · Beginner ·🔧 Backend Engineering ·3y ago

Key Takeaways

TensorFlow Serving client examples using Python and C++ for REST and gRPC prediction requests

Full Transcript

hi there welcome back to the video series of deploying production ml models with sensor flow serving my name is wei and i'm a developer advocate at google in our last episode we showed you how to start a tf serving model server and send post requests using the command line to occur while this is interesting we still need to learn how to send a request using different programming languages so in this episode we're going to discuss how to send rust and grpc requests to tf serving with python and c plus plus remember in our first episode we mentioned that your calendar app can send rest or grcc requests to tf serving and df7 will send back the corresponding responses it turns out that there are many clients in different languages and platforms you can use let's first take a look at a very common one using python to send rest requests to demonstrate this let's first download the risnet model from tensorflow hub and start tf serving with docker once the model server is up we can check out the model metadata in this link here we can see the input tensor name data type and shape it also shows the output tensor shape data type and etc it's usually a good practice to double check the metadata before you start sending requests to tensorflow serving since this is an image classification model we first download a test image file in our python code then we normalize the image sensor and dump it into json now we can send a poster request to the tf serving endpoint lastly we can get the prediction from the response that's it it's pretty straightforward right now let's move on to grpc grpc is a modern open source high performance remote procedure core framework that can run in any environment it can effectively connect the services in and across data centers with plugable support for load balancing tracing health checking and authentication please check out its home page to learn more about grpc grpc is open sourced by google and for our purpose it is an alternative way to send a prediction request to the tf7 backend let's see how we can leverage grpc in our python code we downloaded the image and normalized input sensor as before to send grpc requests we need to create a client stop which requires a channel and the server information in addition we specify our model name signature name and input tester in our prediction request now we use the stop to send the request to tensorflow serving once we get the response back we can extract the output tensors so this is how you would use python to send grpc requests but it is actually a little bit more involved than this we skipped this part to generate the client stop code because tf serving has done it for you in general to use grpc we need to define the remote service using dot product files then we can use grpc compiler to generate the client stop code which can then be integrated into your client this workflow applies to any programming language that grpc supports this is how our prediction service dot proto file looks like it has dependencies on a number of other product files including some in tensorflow repositories if you want to regenerate the client stop code yourself you can install grpc io tool package first and run the command to do so make sure you clone tensorflow repository as well since we depend on some products from tensorflow repository after the client stop code is generated we can import them and create a grpc request i highly recommend reading grpc documentation to learn more about generating grpc client stop if you are going beyond the python class bus lastly let's take a look at the c plus first c plus bus is actually very similar to python we specify our model name and signature name here then we read the image and use the client stop to send the request after we get the response we can extract the output sensor note that here we did not generate the client stop code either since tensorflow serving repository has done that for us so we just showed you how to call tensorflow serving backend using python and c plus plus what if you are not using python or c plus plus not to worry we have recently released a new set of codelabs covering web android flutter and ios foundants feel free to check them out so to summarize today we walk to you through how to send a prediction request to tensorflow serving backend with python and c plus bus you can find the complete code in the example folder of tensorflow serving repository in our next episode we are going to learn how to customize tensorflow serving please stay tuned thank you [Music] [Music]

Original Description

Wei Wei, Developer Advocate at Google, walks through how to send REST and gRPC prediction requests to TensorFlow serving backend with Python and C++. Don’t worry if your client uses another language, below there are new sets of codelabs covering web, Android, Flutter, and iOS frontends. Codelabs Image Classification with TensorFlow Serving (Web) → https://goo.gle/3tQfqMb Object Detection with TensorFlow Serving (Android) → https://goo.gle/3Oyo7mf Text Classification with TensorFlow Serving (Flutter) → https://goo.gle/3OrvJGY Regression with TensorFlow Serving (iOS) → https://goo.gle/3xHHjXF Resources: TensorFlow Serving examples → https://goo.gle/3tRuAk1 gRPC → https://goo.gle/3y9jA4a gRPC Python basics tutorial → https://goo.gle/3HGdlb7 gRPC vs REST: Understanding gRPC, OpenAPI and REST and when to use them in API design → https://goo.gle/3bh8PUC Deploying Production ML Models with TensorFlow Serving playlist → https://goo.gle/tf-serving Subscribe to TensorFlow → https://goo.gle/TensorFlow #TensorFlow #MachineLearning #ML
Watch on YouTube ↗ (saves to browser)
Sign in to unlock AI tutor explanation · ⚡30

Playlist

Uploads from TensorFlow · TensorFlow · 0 of 60

← Previous Next →
1 The TensorFlow YouTube Channel is Here!
The TensorFlow YouTube Channel is Here!
TensorFlow
2 Answering Your TF Questions #AskTensorFlow
Answering Your TF Questions #AskTensorFlow
TensorFlow
3 Chatting With the TensorFlow Community (TensorFlow Meets)
Chatting With the TensorFlow Community (TensorFlow Meets)
TensorFlow
4 All About TensorFlow Code (Coding TensorFlow)
All About TensorFlow Code (Coding TensorFlow)
TensorFlow
5 TensorFlow: an ML platform for solving impactful and challenging problems
TensorFlow: an ML platform for solving impactful and challenging problems
TensorFlow
6 Keynote (TensorFlow Dev Summit 2018)
Keynote (TensorFlow Dev Summit 2018)
TensorFlow
7 tf.data: Fast, flexible, and easy-to-use input pipelines (TensorFlow Dev Summit 2018)
tf.data: Fast, flexible, and easy-to-use input pipelines (TensorFlow Dev Summit 2018)
TensorFlow
8 Eager Execution (TensorFlow Dev Summit 2018)
Eager Execution (TensorFlow Dev Summit 2018)
TensorFlow
9 Machine Learning in JavaScript (TensorFlow Dev Summit 2018)
Machine Learning in JavaScript (TensorFlow Dev Summit 2018)
TensorFlow
10 Training Performance: A user’s guide to converge faster (TensorFlow Dev Summit 2018)
Training Performance: A user’s guide to converge faster (TensorFlow Dev Summit 2018)
TensorFlow
11 The Practitioner's Guide with TF High Level APIs (TensorFlow Dev Summit 2018)
The Practitioner's Guide with TF High Level APIs (TensorFlow Dev Summit 2018)
TensorFlow
12 Distributed TensorFlow (TensorFlow Dev Summit 2018)
Distributed TensorFlow (TensorFlow Dev Summit 2018)
TensorFlow
13 Debugging TensorFlow with TensorBoard plugins (TensorFlow Dev Summit 2018)
Debugging TensorFlow with TensorBoard plugins (TensorFlow Dev Summit 2018)
TensorFlow
14 TensorFlow Lite (TensorFlow Dev Summit 2018)
TensorFlow Lite (TensorFlow Dev Summit 2018)
TensorFlow
15 Searching Over Ideas (TensorFlow Dev Summit 2018)
Searching Over Ideas (TensorFlow Dev Summit 2018)
TensorFlow
16 Reconstructing Fusion Plasmas (TensorFlow Dev Summit 2018)
Reconstructing Fusion Plasmas (TensorFlow Dev Summit 2018)
TensorFlow
17 Nucleus: TensorFlow toolkit for Genomics (TensorFlow Dev Summit 2018)
Nucleus: TensorFlow toolkit for Genomics (TensorFlow Dev Summit 2018)
TensorFlow
18 Open Source Collaboration (TensorFlow Dev Summit 2018)
Open Source Collaboration (TensorFlow Dev Summit 2018)
TensorFlow
19 Swift for TensorFlow - TFiwS (TensorFlow Dev Summit 2018)
Swift for TensorFlow - TFiwS (TensorFlow Dev Summit 2018)
TensorFlow
20 TensorFlow Hub (TensorFlow Dev Summit 2018)
TensorFlow Hub (TensorFlow Dev Summit 2018)
TensorFlow
21 Applied AI at The Coca-Cola Company (TensorFlow Dev Summit 2018)
Applied AI at The Coca-Cola Company (TensorFlow Dev Summit 2018)
TensorFlow
22 Real-World Robot Learning (TensorFlow Dev Summit 2018)
Real-World Robot Learning (TensorFlow Dev Summit 2018)
TensorFlow
23 TensorFlow Extended (TFX) (TensorFlow Dev Summit 2018)
TensorFlow Extended (TFX) (TensorFlow Dev Summit 2018)
TensorFlow
24 Project Magenta (TensorFlow Dev Summit 2018)
Project Magenta (TensorFlow Dev Summit 2018)
TensorFlow
25 TensorFlow Dev Summit 2018 - Livestream
TensorFlow Dev Summit 2018 - Livestream
TensorFlow
26 Introducing TensorFlow Lite (Coding TensorFlow)
Introducing TensorFlow Lite (Coding TensorFlow)
TensorFlow
27 TensorFlow Dev Summit 2018 Highlights
TensorFlow Dev Summit 2018 Highlights
TensorFlow
28 Jeff Dean, Head of AI at Google discusses the impact of ML (TensorFlow Meets)
Jeff Dean, Head of AI at Google discusses the impact of ML (TensorFlow Meets)
TensorFlow
29 TensorFlow Mobile vs. TF Lite and More! #AskTensorFlow
TensorFlow Mobile vs. TF Lite and More! #AskTensorFlow
TensorFlow
30 Using TensorFlow to enable research & production across many fields (TensorFlow Meets)
Using TensorFlow to enable research & production across many fields (TensorFlow Meets)
TensorFlow
31 Teaching TensorFlow for Deep Learning at Stanford University (TensorFlow Meets)
Teaching TensorFlow for Deep Learning at Stanford University (TensorFlow Meets)
TensorFlow
32 TensorFlow Lite for Android (Coding TensorFlow)
TensorFlow Lite for Android (Coding TensorFlow)
TensorFlow
33 Using the tf.data API to build input pipelines (TensorFlow Meets)
Using the tf.data API to build input pipelines (TensorFlow Meets)
TensorFlow
34 Training Models in the Cloud & the Benefits of AI Toolkits #AskTensorFlow
Training Models in the Cloud & the Benefits of AI Toolkits #AskTensorFlow
TensorFlow
35 Execute operations immediately with TensorFlow's Eager Execution (TensorFlow Meets)
Execute operations immediately with TensorFlow's Eager Execution (TensorFlow Meets)
TensorFlow
36 TensorFlow Lite for iOS (Coding TensorFlow)
TensorFlow Lite for iOS (Coding TensorFlow)
TensorFlow
37 Get started with TensorFlow's High-Level APIs (Google I/O '18)
Get started with TensorFlow's High-Level APIs (Google I/O '18)
TensorFlow
38 TensorFlow for JavaScript (Google I/O '18)
TensorFlow for JavaScript (Google I/O '18)
TensorFlow
39 TensorFlow in production: TF Extended, TF Hub, and TF Serving (Google I/O '18)
TensorFlow in production: TF Extended, TF Hub, and TF Serving (Google I/O '18)
TensorFlow
40 Get started with TensorFlow's High-Level APIs in 5 mins |  Google I/O 2018
Get started with TensorFlow's High-Level APIs in 5 mins | Google I/O 2018
TensorFlow
41 TensorFlow and deep reinforcement learning, without a PhD (Google I/O '18)
TensorFlow and deep reinforcement learning, without a PhD (Google I/O '18)
TensorFlow
42 TensorFlow Lite for mobile developers (Google I/O '18)
TensorFlow Lite for mobile developers (Google I/O '18)
TensorFlow
43 Advances in machine learning and TensorFlow (Google I/O '18)
Advances in machine learning and TensorFlow (Google I/O '18)
TensorFlow
44 Distributed TensorFlow training (Google I/O '18)
Distributed TensorFlow training (Google I/O '18)
TensorFlow
45 Classification using neural networks & ML regression models #AskTensorFlow
Classification using neural networks & ML regression models #AskTensorFlow
TensorFlow
46 TensorFlow and Keras in R - Josh Gordon meets with J.J. Allaire (TensorFlow Meets)
TensorFlow and Keras in R - Josh Gordon meets with J.J. Allaire (TensorFlow Meets)
TensorFlow
47 Focus on your experiment with TensorFlow Estimators (TensorFlow Meets)
Focus on your experiment with TensorFlow Estimators (TensorFlow Meets)
TensorFlow
48 How to get started with AI/ML, retraining models, & more! #AskTensorFlow
How to get started with AI/ML, retraining models, & more! #AskTensorFlow
TensorFlow
49 TensorFlow - the deep learning solution for mobile platforms (TensorFlow Meets)
TensorFlow - the deep learning solution for mobile platforms (TensorFlow Meets)
TensorFlow
50 MiniGo: TensorFlow Meets Andrew Jackson (TensorFlow Meets)
MiniGo: TensorFlow Meets Andrew Jackson (TensorFlow Meets)
TensorFlow
51 The growth of TensorFlow with added support for JS & Swift (TensorFlow Meets)
The growth of TensorFlow with added support for JS & Swift (TensorFlow Meets)
TensorFlow
52 At the intersection of TensorFlow & nuclear physics (TensorFlow Meets)
At the intersection of TensorFlow & nuclear physics (TensorFlow Meets)
TensorFlow
53 NVidia TensorRT: high-performance deep learning inference accelerator (TensorFlow Meets)
NVidia TensorRT: high-performance deep learning inference accelerator (TensorFlow Meets)
TensorFlow
54 Try TensorFlow.js in your browser (Coding TensorFlow)
Try TensorFlow.js in your browser (Coding TensorFlow)
TensorFlow
55 TensorFlow Hub: reusing machine learning modules (TensorFlow Meets)
TensorFlow Hub: reusing machine learning modules (TensorFlow Meets)
TensorFlow
56 How to use TensorFlow in PyCharm (TensorFlow Tip of the Week)
How to use TensorFlow in PyCharm (TensorFlow Tip of the Week)
TensorFlow
57 Training models faster with TensorFlow Hub (TensorFlow Meets)
Training models faster with TensorFlow Hub (TensorFlow Meets)
TensorFlow
58 Prepare your dataset for machine learning (Coding TensorFlow)
Prepare your dataset for machine learning (Coding TensorFlow)
TensorFlow
59 Using ML to predict insulin use for Type 1 Diabetes (TensorFlow Meets)
Using ML to predict insulin use for Type 1 Diabetes (TensorFlow Meets)
TensorFlow
60 TFX: an end-to-end machine learning platform for TensorFlow (TensorFlow Meets)
TFX: an end-to-end machine learning platform for TensorFlow (TensorFlow Meets)
TensorFlow

This video teaches how to send REST and gRPC prediction requests to TensorFlow Serving backend using Python and C++

Key Takeaways
  1. Install TensorFlow Serving
  2. Choose between REST and gRPC for API design
  3. Send prediction requests using Python and C++
  4. Use codelabs for web, Android, Flutter, and iOS frontends
💡 TensorFlow Serving provides a flexible and scalable way to deploy machine learning models in production

Related AI Lessons

Up next
This Cop Was Held Accountable For His Brutality! #police #lawyer
Hampton Law
Watch →