MLSteam Model SDK
💡This example demonstrates how to use MLSteam Model SDK to download an encrypted model for prediction. It has been verified in an MLSteam lab running from a ubuntu:20.04 image.
Create a new model version
Create a new folder (previously known as dataset) in MLSteam.
Upload the
model.zipfile into folder and extract it.Create a new model named
stockin MLSteam.Within the
stockmodel, create a new packaged or encrypted version namedv1.models:
models/(folder)hooks:
hooks/(folder)manifest:
manifest.json
Install required SDK packages
If the last step of install-themisdev fails in JupyterLab or if you are not using Ubuntu, you may install the package according to the official instructions instead.
%pip install -U pip
%pip install -U setuptools
%pip install -U mlsteam-model-sdk
!mlsteam-model-cli install-themisdev -p ubuntu
Install required model packages
Replace the following pip-requirements path by the actual file location.
%pip install -U -r examples/tensorflow_stockpred/requirements.txt
Initialize SDK
Replace the value of
--default_project_valby the actual project name (format:PROJECT_OWNER_NAME/PROJECT_NAME).Change
--default_model_valalso if you use another model name.
!rm -rf ~/.mlsteam-model-sdk
!mlsteam-model-cli init \
--default_project_type name \
--default_project_val "admin/test" \
--default_model_type name \
--default_model_val "stock"
!cat ~/.mlsteam-model-sdk/cfg.ini
from mlsteam_model_sdk.sdk.model import Model
sdk_model = Model()
sdk_model.download_model_version(version_name='v1')
mv = sdk_model.load_model_version(version_name='v1')
inputs = [50.0]*80
outputs = mv.predict(inputs=inputs)
print(outputs)
mv.models