QBoard » Artificial Intelligence & ML » AI and ML - Tensorflow » deploy trained python data science project on azure as service

deploy trained python data science project on azure as service

  • I have created a data science neural network in Python anaconda Spyder. My projects have multiple .py files and I have trained this model for 10 days and weights are generated. I want to use this model as a service and want to deploy it to Azure for consumption. I tried following but facing difficulties -

    1) I tried deploying this as "Execute Python Script" in Azure ML studio but I am not finding an option to upload the weights. I understand I can zip all the .py files but what about the trained weights and virtual environment (I am using an old version of tensorflow)?

    2) I am seeing an option of creating a Jupyter notebook but my project is created in Spyder and doesn't have .ipynb files. Is there any way to convert my .py files into .ipynb files? ALso, I have created a virtual environment with the older version of tensorflow and python version? How to take care of this while deploying to azure?

    3) I tried deploying this to azure as a python web app but again what shall I do with the virtual environment and my existing weights? Also, how do I create my configuration or dependency file required for webapp?

    Please, can you let me know the best method to deploy this solution to azure with weights if possible?

    Thanks

      October 4, 2021 2:01 PM IST
    0
  • I cannot help you much as it seems that you are not familiar with it and it is hard to express just by words.
    First, have you saved your trained model? If you have saved it, you can upload the saved model and reload it after deployment.
    Second, you don't need to use a jupyter notebook, that is meaningless in your situation.
    Third, you don't need to create virtualenv by yourself. You just need to provide a requirements.txt file to specify all packages you need. And Azure web app will automatically create a virtualenv and install every packages in requirements.txt.
    Finally, if you want to work it out, you should first start with some simple example.
      October 6, 2021 9:13 AM IST
    0
  • According to your description, it sounds like you want to deploy your trained tensorflow model as an Execute Python Script module on Azure ML Studio and publish it as webservice for consumption.

    So if not considered for the compatiblilty of tensorflow CPU]-only code, as you said, you can refer to the offical document Execute Python machine learning scripts in Azure Machine Learning Studio and the SO thread Updating pandas to version 0.19 in Azure ML Studio to zip all files and dependencies which include .py files and your exported trained model as a read-only file to setup an Azure ML webservice like the document describes.

    Or there was a similar thread How to deploy a tensorflow model to azure ml workbench to save model as a protobuf for consumption.

    However, some workaround ways just using Azure GPU Machine or Docker for deployment is simple for the scenario. Please refer to these Train a TensorFlow model in the cloud and TensorFlow on Docker with Microsoft Azure Container Services.

    Hope it helps.
      October 6, 2021 2:59 PM IST
    0
  • You’ll need an Azure subscription (create one free here). Then you’ll need to create an Azure Machine Learning service workspace resource in your tenant. Once you spin up the workspace, you will also need to create a Notebook VM, then open a Jupyter notebook to code in. Each of the code segments below are blocks of code inside of the notebook I created for this demo.

    We will cover three major sections in our walkthrough: 1) setting up the development environment, 2) training the predictive model, and 3) deploying the model as an Azure ML service – each step has several sub-steps.

    Set Up the Development Environment

    We’ll begin by setting up our environment and getting it ready to train an experiment. There are five essential steps to getting our environment ready for an experiment:

    1. Initialize the Workspace
    2. Initialize an Experiment
    3. Create a Datastore
    4. Create or Attach a Compute Resource
    5. Environment Set Up
      October 7, 2021 12:49 PM IST
    0