Skip to content

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 deployment in the UbiOps deployment format.
  2. Deploying the deployment to UbiOps.
  3. Sending a request to the deployment for making classifications of handwritten images.

Requirements

  • A web browser
  • A UbiOps account (you can create a free trial account here using your email address or Google or Microsoft account)
  • Optional: A UbiOps API Token
  • 10 minutes of your time

Wrapping existing code

All UbiOps workloads need to be implemented according to the Deployment package structure in order to be executed by the platform.

Download the example .zip file

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

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

  • deployment.py the main file that implements deployment functionality.
  • cnn.h5: a pre-trained machine learning model.
  • setup_logging: a Python file for setting up the logger. (This file is not required, you can also use print() statements if you prefer that.)

Creating a deployment using the UbiOps UI

The next step is to deploy the deployment package (the wrapped code) in UbiOps using the user interface.

  1. Go to UbiOps and login.
  2. In the sidebar on the left go to Deployments and click Create.

    Going through the page from top to bottom:

  3. At item General:

    • Set the Name for the deployment, for example mnist, and a description (optional).
  4. At item Input:

    • Set Input type to structured (default).

    • In the visual editor, under Fields, add an input field with the name image and field-type Blob(file).

  5. At item Output:

    • Set Output type to structured (default).

    • In the visual editor, under Fields, add an output field with the name prediction and field-type Integer.

    • Click Add in the visual editor to add another output field.

    • Give the new output field the name probability and field-type Double precision.

    screenshot

  6. Click Next step.

    Going through the page from top to bottom:

  7. At item General leave the information as it is.

  8. At item Deployment package:

    • Set the Language to Python 3.7.

    • Click Upload code and upload the zipped deployment package you previously downloaded.

  9. Leave the rest of the settings on their default values. For information on what these settings entail visit Advanced Parameters

  10. Click on the Create button.

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

Deployment request

Now that the deployment 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: Image 1, Image 2, Image 3.

Image 3 Image 1 Image 2

Deployment request using the WebApp

You can easily create requests to your deployment using the UbiOps WebApp. This is handy when testing if everything works for example.

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

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

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

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

Deployment requests using the API (optional)

A more real world implementation would be using the API, but you can also use this for testing of course. Follow these steps to learn how to create a deployment request using the API.

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 deployment 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

    • Click on the Try it button in order to make a manual API request.
    • 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)

  2. In the API explorer set all parameters for the manual deployment request:

    • The name of your project.
    • Select a handwritten digit image file in the File upload box.
    • The blob-ttl (ttl=time to live), you can keep this empty.
  3. Execute the API request by pressing Execute button, located at the bottom of the form.

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

Create deployment request

  1. Visit Create deployment request

    • Click on the Try it button in order to make a manual API request.
    • 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)

  2. In the API explorer set all parameters for the manual deployment request:

    • The name of your project.
    • The name of your deployment. Should be "mnist" if you followed our example above.
    • The deployment version. Should be "v1" if you followed our example above.
    • 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"}
      
  3. Execute the API request by pressing Execute button, located at the bottom of the form.

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

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

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