Freigeben über


How to operationalize TensorFlow models in Microsoft Machine Learning Server

We have seen how to operationalize Keras models as web services in R and Python in a previous blog. Now we will see how to deploy a TensorFlow image classification model to Microsoft Machine Learning Server. 

Click here to know more about Microsoft Machine Learning Server Operationalization. You can configure Machine Learning Server to operationalize analytics on a single machine (One-box) or multiple web and compute nodes that are configured on multiple machines along with other enterprise features.

Create a web service for a TensorFlow image classification model in Python

Before you can use the web service management functions in the azureml-model-management-sdk Python package, you must:

  •  Have access to a Python-enabled instance of Machine Learning Server that was properly configured to host web services.
  • Authenticate with Machine Learning Server in Python as described in "Connecting to Machine Learning Server."
  • Have Tensorflow installed on compute nodes.
  • Have a trained TensorFlow image classification model.

In the following example, we are going to demonstrate how to operationalize a TensorFlow image classification model and generate web service API. We are using the trained ImageNet model downloaded from TensorFlow Models Repo.

  1. We first put the trained model on each compute node
  2. The below python script loads the model, builds the graph, and decodes image for classification
  3. The below python script deploys the image classification model as a service and generates service swagger
  4. We can use the swagger json file from previous step to generate clients in many languages. With the generated web service API, developers can easily consume the image classification model in their applications. In another blog, we will talk about how to consume the image classification web service in a JavaScript web application.

REFERENCES

https://www.tensorflow.org/tutorials/images/image\_recognition

https://www.image-net.org/

https://github.com/tensorflow/models/blob/master/tutorials/image/imagenet/classify\_image.py