QBoard » Artificial Intelligence & ML » AI and ML - Tensorflow » How can I download/export the deployed ML model to my local machine?

How can I download/export the deployed ML model to my local machine?

  • Using IBM Watson I can create and deploy the ML model either using its Auto AI platform or the Jupyter notebook. Once, my model is deployed then how can I download/export the ML model on which the predictions are done i.e. how can I get the final sklearn model (.pkl file), Tensorflow model (.pb file) or the other supported ML models on my local machine?
      July 27, 2021 4:43 PM IST
    0
  • To serve predictions from AI Platform Prediction, you must export your trained machine learning model as one or more artifacts. This guide describes the different ways to export trained models for deployment on AI Platform Prediction.

    The following methods of exporting your model apply whether you perform training on AI Platform Prediction or perform training elsewhere and just want to deploy to AI Platform Prediction to serve predictions.

    Once you have exported your model, read the guide to deploying models to learn how to create model and version resources on AI Platform Prediction for serving predictions.

    from sklearn import datasets
    import xgboost as xgb
    
    iris = datasets.load_iris()
    dtrain = xgb.DMatrix(iris.data, label=iris.target)
    bst = xgb.train({}, dtrain, 20)
    
    bst.save_model('model.bst')
      August 17, 2021 1:05 PM IST
    0
  • You can use following WML API call to download the content of your model:-

    curl -X PUT 'https://us-south.ml.cloud.ibm.com/ml/v4/models/:model_id/content?content_format=<string>&space_id=<string>&project_id=<string>&pipeline_node_id=<string>&name=<string>&version=2020-09-01' --data-raw '"<object>"'
    


    https://cloud.ibm.com/apidocs/machine-learning#models-download-content

    style="font-family: arial, helvetica, sans-serif; font-size: 10pt;">You can also use WML Python Client
    https://wml-api-pyclient-dev-v4.mybluemix.net/#repository

    client.repository.download(model_uid, 'my_model.tar.gz')
    


    Alternatively, if you are using deployment space now, You can simply export the space and just select the model that you would like to export. In the exported zip file, you will find the model file under the assets/wml_model/ directory.

      August 16, 2021 3:10 PM IST
    0