Dutch Analytics - Xenia documentation

Model deployment quickstart

This quickstart guide will show you how to get started with Xenia. 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 Xenia model format.
  2. Deploying the model to Xenia.
  3. Sending a request to the deployed model for making classifications of handwritten images.

Requirements

Wrapping an existing model

All Xenia workloads need to be implemented in the same model structure in order to be executed by the platform.

📘

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 file: a pre-trained machine learning model.
  • exceptions.py: a file for possible custom exceptions.
  • requirements.txt: a file with the required packages by the model.
  • __init__.py: a Python initialization file.

Creating a model using the Xenia UI

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

  1. Go to Xenia 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

    • Add an input field input_blob with data-type file
  5. Set Output type to structured.

    • Add an output field prediction with data-type integer
    • Add an output field probability with data-type double precision.
  6. Click Next step and then Confirm.

  7. Set the Language to Python 3.6.

  8. You can leave the rest of the settings on their defaults

  9. 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 Xenia, 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 Xenia 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 clicking 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

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

  2. When the model has finished processing you can click the notification in the right bottom named Results and see the results of your request.


Model 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 do a model 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 model you first have to upload this file to Xenia using the Xenia API. In Xenia 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 Xenia API Token in the format:
    Token 1ig03sggdqvqtvl2n7xc4q7npn7hqqe97od1qiyg (example)
  1. In the API explorer set all parameters for the manual model request:
  • The name of your project.
  • Select a handwritten digit image file in the File upload box.
  • The blob-ttl, you can keep this empty.
  1. 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 model request

  1. Visit Create model 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 Xenia API Token in the format :
    Token 1ig03sggdqvqtvl2n7xc4q7npn7hqqe97od1qiyg (example)
  1. In the API explorer set all parameters for the manual model request:
  • The name of your project.
  • The name of your model. Should be "mnist-model" if you followed our example above.
  • The model 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:
{
 "input_blob": "PUT YOUR BLOB ID HERE"
}
  1. Execute the API request by pressing Execute button, located at the bottom of the form.

  2. If your API call was successful, you should receive a server response code 200 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.

Updated about 17 hours ago

Model deployment quickstart


Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.