Skip to main content
Version: Next

Tutorial 4B: Model deployment to H2O MLOps through the H2O Hydrogen Torch UI

Overview

This tutorial explores one of the options available to deploy a built model. In particular, this tutorial builds an image regression model to explore how you can deploy a model to H2O MLOps through the H2O Hydrogen Torch UI.

Objectives

  1. Understand how to deploy a built model to H2O MLOps through the H2O Hydrogen Torch UI.
  2. Learn how to score new data with the deployed model in H2O MLOps.

Prerequisites

Step 1: Import dataset

For this tutorial, let's utilize the demo out-of-the-box preprocessed coins_image_regression.zip dataset. The dataset contains a collection of 6,028 images with one or more coins. Each image has been labeled to indicate the sum of its coins. The currency of the coins is the Brazilian Real (R$). Let's import the dataset.

  1. In the H2O Hydrogen Torch navigation menu, click Import dataset.
  2. In the File name list, select coins_image_regression.zip.
  3. Click Continue.
  4. Click Continue.
  5. Click Continue.

Four Brazilian Real coins image called 150_1479430290.jpg

150_1479430290.jpg

Step 2: Build model

Let's quickly build an image regression model capable of predicting the sum of Brazilian Real (R$) coins in images. After creating the model, we will deploy it to H2O MLOps through the H2O Hydrogen Torch UI.

  1. In the H2O Hydrogen Torch navigation menu, click Create experiment.
  2. In the Dataset list, select coins_image_regression.
  3. In the Experiment name box, enter tutorial-4b.
  4. Click Run experiment.

Step 3: Deploy model to H2O MLOps through the H2O Hydrogen Torch UI

After a few minutes/seconds, you can deploy the model. To deploy the model to H2O MLOps through the H2O Hydrogen Torch UI, consider the following instructions:

  1. In the H2O Hydrogen Torch navigation menu, click View experiments.
  2. In the Experiments table, click tutorial-4b.
  3. Click the Deployments tab. Deployments tab
  4. In the Project box, enter tutorial-4b.
    note

    To deploy the model, you can enter a non-existent project name, which will create a project in H2O MLOps under that name to deploy the model.

  5. Click Deploy.
    note

    H2O Hydrogen Torch deploys the model to your H2O MLOps account within the H2O AI Cloud. You can access your H2O MLOps account through the H2O MLOps legacy UI or the H2O MLOps Wave application.

    • To access the H2O MLOps legacy UI in the H2O AI Cloud, click MY MODELS. Legacy UI
    • To access the H2O MLOps Wave application, consider the following steps:
      1. In the H2O AI Cloud navigation menu, click APP STORE.
      2. In the search bar, enter H2O MLOps. Wave application
      3. Click the H2O MLOps tile.
      4. Click Visit. Visit
note

To learn about the H2O MLOps deployment settings, see H2O MLOps deployment settings.

After a few minutes/seconds, the model in the List of deployments table will achieve a HEALTHY status which will mean that the model has been deployed. A HEALTHY status will allow you to view certain deployment pieces of information (for example, the endpoint URL).

To keep track of the status of the deployed model, consider the following step:

  1. Click Refresh. Refresh

Step 4: Score new data

After the model achieves a HEALTHY status, proceed with the next step to view the deployed model's details:

  1. In the List of deployments table, click *_tutorial-4b_dev. Deployment table and details

After deploying the model to H2O MLOps, we can use the endpoint URL and sample request (Python script) of the deployed model to score new data. For instance, let's score the following image: 150_1479430290.jpg.

Four Brazilian Real coins image called 150_1479430290.jpg

150_1479430290.jpg

  1. In the Sample request box, copy and save the Python script (a sample request). Sample request
    note

    In line 8 of the copied sample request, note the deployed model's endpoint URL is already specified (for example, URL = "https://model.cloud-qa.h2o.ai/0397.........64a/model/score").

Now, modify the Python script (sample request), in particular, modified the following line as stated, and right after, run the script:

  1. In line 11, specify the path to the 150_1479430290.jpg image.
    • For example, img = cv2.imread("150_1479430290.jpg").

After modifying and running the Python script, the response obtained is in a JSON format following the format of the Pickle files discussed in the follwing page: Download a prediction.

413 Request Entity Too Large

If you obtained the following error after running the Python script, you need to reduce the image size: 413 Request Entity Too Large. For example:

img = cv2.imread("150_1479430290.jpg")
img = cv2.resize(img, (200,150)) # From 640x480 to 200x150

For example, scoring the 150_1479430290.jpg image, we receive the following response:

{'predictions': [[143.6985321044922]], 'labels': [['label']]}

Summary

In this tutorial, we learned how to deploy a built model to H2O MLOps through the H2O Hydrogen Torch UI. We also learned how to score new data with the deployed model in H2O MLOPs.

Next

Now that you know how to deploy a built model to H2O MLOps through the H2O Hydrogen Torch UI, consider the following tutorials to learn about the other options to deploy a built model:


Feedback