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

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.
  • exceptions.py: a file for possible custom exceptions.
  • 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 -> Create.
  3. Set the Name for the deployment, for example "mnist", 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.7.
  11. You can leave the rest of the settings on their defaults
  12. Upload the zipped deployment package and click on 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.

Deployment request using the UI

You can easily create requests to your deployment using the UbiOps UI. 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 DIRECT REQUEST and upload a handwritten image to UbiOps. Click Create to create the request.

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

Deployment 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 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.