pythonibm-watsonwatson-studio

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?


Solution

  • 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

    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.