question

RajamannarAK-6287 avatar image
0 Votes"
RajamannarAK-6287 asked ramr-msft answered

How to Register a ML model using MLflow

Hi,

I have a PyTorch model which I have pushed into the dbfs now I want to serve the model using MLflow. I saw that the model needs to be in python_function model.

To do that I did the following methods
1. load the model from dbfs using torch load option
2. Then save the model in python_function model using the pyfunc.save_model function
3. After this when I register the model I get a decode error

I'm not training any model in the Databricks.

import mlflow
import mlflow.pyfunc
from torch import load as torch_load

py_model = torch_load( "/dbfs/FileStore/ml/ner_model" , map_location = torch_device(ner_gpu_device))
mlflow.pytorch.save_model(py_model,path="/dbfs/FileStore/pyfunc/ner_model")

model = mlflow.pyfunc.load_model("/dbfs/FileStore/pyfunc/ner_model")
mlflow.register_model(model,"ner_model")

# loading the python_function model to register
model = mlflow.pyfunc.load_model("/dbfs/FileStore/pyfunc/ner_model")
model_version = mlflow.register_model(model,"ner_model")


this is the error which I get while running the register model line


156022-image.png



azure-machine-learningazure-databricks
image.png (69.0 KiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

ramr-msft avatar image
0 Votes"
ramr-msft answered

@RajamannarAK-6287 Thanks for the question. Can you please add more details about the trained model and deployment that you are trying.

Here is link to an example of how to deploy and use object detection model in Azure ML with MLFlow option.

the process to do MLFlow using a custom python flavor then deploy to Azure ML using the Azure version of MLFlow.
Created the template here:
1. Main deployment script to AML: aml_mlflow_deployment/mlflow_aml_deployment.ipynb at main · james-tn/aml_mlflow_deployment (github.com)
2. Custom mlflow.pyfunc module: aml_mlflow_deployment/model_loader.py at main · james-tn/aml_mlflow_deployment (github.com)


There's also the option of simply using Azure DevOps to pull the model out of the MLFlow model repo in Azure Databricks, containerize it, and put it directly to ACI/AKS for API scoring outside of Azure Databricks.


5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.