Skip to content

Model deployment quickstart

This quickstart guide will show you how to get started with UbiOps. In this quickstart you will learn how to deploy a neural network algorithm that classifies images of handwritten digits (MNIST). For example, it will classify the following image as a "2".

Example of a handwritten image from the MNIST set.",

This guide will cover three steps:

  1. Wrapping the Python code for the model in the UbiOps model format.
  2. Deploying the model to UbiOps.
  3. Sending a request to the deployed model for making classifications of handwritten images.

Requirements

  • A web browser
  • An UbiOps account (you can create a free trial account here)
  • (optional) An UbiOps API Token
  • 10 minutes of your time

Wrapping an existing model

Download the example .zip file

A prepared model is available for this quickstart example. You can download it here.

Inside the ZIP file there is a model_package directory, which contains:

  • model.py the main file that implements model functionality.
  • cnn.h5: a pre-trained machine learning model.
  • exceptions.py: a file for possible custom exceptions.
  • setup_logging: a Python file for setting up the logger.

Creating a model using the UbiOps UI

The next step is to deploy the wrapped model in UbiOps using the user interface.

  1. Go to UbiOps and login.
  2. In the sidebar on the left go to Models -> Create.
  3. Set the Name for the model, for example "mnist-model", and a description (optional).
  4. Set Input type to structured
  5. Add an input field image with data-type file
  6. Set Output type to structured.
  7. Add an output field prediction with data-type integer
  8. Add an output field probability with data-type double precision.

  9. Click Next step and then Confirm.

  10. Set the Language to Python 3.6.
  11. You can leave the rest of the settings on their defaults
  12. Upload the zipped model package and click on Create button.

The model should be active after a few minutes and can be seen in the Models overview page.

Model request

Now that the model has been deployed in UbiOps, it is time to test it by sending it an image and looking at the results For this example, three handwritten digits are available for testing.

Model request using the UI

You can easily create model requests using the UbiOps UI. This is handy when testing if everything works for example.

You can test your newly created MNIST model by going to the model version page.

  1. Click on Models in the sidebar on the left and then click on your model name (mnist-model) and then on one of the versions (v1). You should now be on the model version page. model version page

  2. Now click CREATE DIRECT REQUEST and upload a handwritten image to UbiOps. Click Create to create the request.

  3. When the model has finished processing you can see the results of your request.

Model requests using the API (optional)

API Token

For this part of the tutorial you will need an API Token with the correct permissions.

Upload an image

When using files as input for your model you first have to upload this file to UbiOps using the UbiOps API. In UbiOps we call these files Blobs. In this tutorial we will use Swagger, an interactive API explorer, for that.

  1. Visit Upload a blob
  2. Click on the Try it button in order to make a manual API request.
  3. Before making your first call click lock icon on the upper right corner, and fill in your UbiOps API Token in the format: Token 1ig03sggdqvqtvl2n7xc4q7npn7hqqe97od1qiyg (example)

  4. In the API explorer set all parameters for the manual model request:

  5. The name of your project.
  6. Select a handwritten digit image file in the File upload box.
  7. The blob-ttl (ttl=time to live), you can keep this empty.

  8. Execute the API request by pressing Execute button, located at the bottom of the form.

  9. You will now get the blob_id of the file created, copy this id.

Create model request

  1. Visit Create model request
  2. Click on the Try it button in order to make a manual API request.
  3. Before making your first call click lock icon on the upper right corner, and fill in your UbiOps API Token in the format : Token 1ig03sggdqvqtvl2n7xc4q7npn7hqqe97od1qiyg (example)

  4. In the API explorer set all parameters for the manual model request:

  5. The name of your project.
  6. The name of your model. Should be "mnist-model" if you followed our example above.
  7. The model version. Should be "v1" if you followed our example above.
  8. The data object which needs to include the blob id returned when creating a blob in the previous heading. It should be something like this:

    {"image": "PUT YOUR BLOB ID HERE"}
    

  9. Execute the API request by pressing Execute button, located at the bottom of the form.

  10. If your API call was successful, you should receive a server response containing:

  11. status: The state of the request. Should be on "succes"
  12. result: All the output fields with their results.

For more details on the process of making requests, you can read the API page.