3 - Compare, Register and Deploy the Model
Introduction
In the previous part, we used PrimeHub Notebook to train and manage the base model. In this part, we will:
Compare the results of these two experiment.
The experiment with the best performance will be registered in PrimeHub Models
Deploy as an online API service via PrimeHub's Model Deployment feature.
Use the command line to test the API service.
Prerequisites
1. Enable Model Deployment
Before we get started, enable the Model Deployment toggle in your group settings.
![](https://docs-v4.primehub.io/~gitbook/image?url=https%3A%2F%2F850895114-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FN77KrdBayk0hKvYb985v%252Fuploads%252Fgit-blob-81a7fa439c5dc42ab7a5a568511d6fdd48f95860%252Fprimehub-end-to-end-tutorial-model-deployment.png%3Falt%3Dmedia&width=768&dpr=4&quality=100&sign=b701e892&sv=1)
2. Model pre-package docker image
There are two methods to get your pre-package docker image:
You can use our model pre-package docker image:
Image Name:
infuseaidev/tensorflow2-prepackaged:screw-classification
You can build your own pre-packaged docker image by followed the advanced guide.
Step 1: Compared and Register the model
1. Compare the model in the MLFlow server
To compare the results, click the checkbox next to each run to select them, then click the Compare button.
→ MLFlow server UI → Choose two runs → Click Compare.
![](https://docs-v4.primehub.io/~gitbook/image?url=https%3A%2F%2F850895114-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FN77KrdBayk0hKvYb985v%252Fuploads%252Fgit-blob-dd349f6d1fd4b2e6036b5fbb4323c593cc6fa48e%252Fprimehub-end-to-end-tutorial-mlflow-compare-results.png%3Falt%3Dmedia&width=768&dpr=4&quality=100&sign=b1defc59&sv=1)
2. Choose the best run and register the model
Check the best score in Metrics
![](https://docs-v4.primehub.io/~gitbook/image?url=https%3A%2F%2F850895114-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FN77KrdBayk0hKvYb985v%252Fuploads%252Fgit-blob-68355c1bb75e82c40dde3c46f7c20f5b6371026d%252Fprimehub-end-to-end-tutorial-mlflow-check-score.png%3Falt%3Dmedia&width=768&dpr=4&quality=100&sign=e90b088&sv=1)
At the top of the page, click the Run ID link for the run.
![](https://docs-v4.primehub.io/~gitbook/image?url=https%3A%2F%2F850895114-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FN77KrdBayk0hKvYb985v%252Fuploads%252Fgit-blob-9690990db431bc057c2ddfaee030fb6c606de1a1%252Fprimehub-end-to-end-tutorial-mlflow-run-id.png%3Falt%3Dmedia&width=768&dpr=4&quality=100&sign=7f805c49&sv=1)
In the Artifact, register the model folder as our model registry.
![](https://docs-v4.primehub.io/~gitbook/image?url=https%3A%2F%2F850895114-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FN77KrdBayk0hKvYb985v%252Fuploads%252Fgit-blob-0c1c66ee4c1b9ebf5d6256394f1ef57f4bdd7706%252Fprimehub-end-to-end-tutorial-mlflow-register-model-1.png%3Falt%3Dmedia&width=768&dpr=4&quality=100&sign=66ffcdd7&sv=1)
Enter the model information to register the model.
![](https://docs-v4.primehub.io/~gitbook/image?url=https%3A%2F%2F850895114-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FN77KrdBayk0hKvYb985v%252Fuploads%252Fgit-blob-2b0f736f4873d5d94095b26f6932a21b3ba4b1ef%252Fprimehub-end-to-end-tutorial-mlflow-register-model-2.png%3Falt%3Dmedia&width=768&dpr=4&quality=100&sign=db8ac6ed&sv=1)
Step 2: Deploy and test the model service
1. Model Deployment
On the Models page in the PrimeHub user portal, click our managed model with the name tf-screw-model.
![](https://docs-v4.primehub.io/~gitbook/image?url=https%3A%2F%2F850895114-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FN77KrdBayk0hKvYb985v%252Fuploads%252Fgit-blob-f78e4f5eead337472a46354cdc5f30a35f93a2da%252Ftutorial_models_managed.png%3Falt%3Dmedia&width=768&dpr=4&quality=100&sign=1145341e&sv=1)
The following page shows all versions of the tf-screw-model model. Click the Deploy button for Version 1.
![](https://docs-v4.primehub.io/~gitbook/image?url=https%3A%2F%2F850895114-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FN77KrdBayk0hKvYb985v%252Fuploads%252Fgit-blob-5c5a8b9d85bb4ce5a6eed4a1dccd26e20ca56eb7%252Ftutorial_models_version.png%3Falt%3Dmedia&width=768&dpr=4&quality=100&sign=b362513b&sv=1)
In the Deploy Model dialog, select Create new deployment from the Deployment dropdown and then click OK.
![](https://docs-v4.primehub.io/~gitbook/image?url=https%3A%2F%2F850895114-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FN77KrdBayk0hKvYb985v%252Fuploads%252Fgit-blob-0bab790dfe191e62fcfbf8bbe09bc99c2ddc7f9f%252Ftutorial_models_create_new_deployment.png%3Falt%3Dmedia&width=768&dpr=4&quality=100&sign=20931f88&sv=1)
Fill in the Deployment information:
Variable | Value |
---|---|
Deployment Name | tf-screw-deployment |
Model image | infuseai/tensorflow2-prepackaged:screw-classification |
InstanceTypes | CPU 1 |
Click the Deploy button, and you will be redirected to the Deployments page.
To view the details of the deployment, click the tf-screw-deployment card.
If you want to build your custom deployment logic and environment, you can see the information in the advanced tutorial section.
2. Test the model service is available to use
Run the following command line:
You can get the output result:
Conclusion
In this tutorial, we compared and selected a suitable model using MLflow, deployed a model, and tested the model with sample data.
Next Section
In the next article, we will add a web application interface to our model using Streamlit, another app available through PrimeHub Apps.
Last updated