Azure Notebooks: ML Training and Mobile Deployment with Skafos

Tyler Hutcherson
Jun 21 · 5 min read

Everyone is doin’ em these days... Jupyter Notebooks. Between Google Colab, AWS Sagemaker Notebooks and now Microsoft Azure Notebooks, accessing the endearing, data-science-friendly development environment in the cloud has never been easier.

In previous posts, we’ve shown you how to train machine learning models on common cloud platforms and upload them to Skafos for mobile app deployment:

In this third post, we will walk you through how to get started in Azure Notebooks and deploy models to the edge with Skafos.


Accessing Azure Notebooks

Microsoft provides a free training environment powered by Jupyter Notebooks/Labs where sharing and collaborating is central to the user experience. Because they’ve made it so easy to share projects with peers, we created a set of projects for you to explore. While this tool is still in “beta” mode, we’re excited about where it will go in the near future!

Example projects provided by Skafos.
Cloning a project on Azure Notebooks.
Azure Notebooks Free Compute

Training a Model

Once inside the Jupyter Lab environment, notice that there are three example notebooks you can choose between. If you want to follow along with this post, I will be using the image-classification-examples project and the dogs_and_cats.ipynb notebook.

At the time of writing this post Azure Notebooks don’t yet publicly support GPU training because it’s still in beta mode. Additionally, if the instance is slow or if dependencies aren’t properly installed, give it some time and restart the kernel.

Run through all of the cells prior toModel Export and Skafos Upload, which cover the following:

Delivering your model using Skafos

At the end of all of this, you will have a model artifact that you can convert to Core ML, upload to Skafos, and deploy to an iOS app. Before proceeding, make sure you’ve taken the following steps:

You now have the ability to tie this all together: a newly trained image classification model from an Azure Notebook and an iOS app that will use it.


Model Export and Upload

Back in the Jupyter Notebook, you need to convert the Turi Create model to CoreML format.

While other types of models can be used, CoreML is a solid starting point because Apple has made it SO easy to integrate them in your Xcode environment.

Converting to CoreML in Python.

Next, import the Skafos Python SDK. With your API token, get a summary of all of the Skafos Apps and Models for which you have access. This will help you find where this model version needs to be uploaded.

Run the Skafos summary command.

You can find your existing API tokens, generate new ones, and revoke old ones on your account settings page. The summary JSON response will look something like:

[
{
"org_name": "<your-org-name>",
"app_name": "<your-app-name>",
"model_name": "<your-model-name>"
},
]

Now that you have a token and summary of models, replace the org/app/model names below with your own. Check out this guide on best practices for setting up your dev environment when using the Python SDK.

Set your connection parameters and upload a model version to Skafos.

Finally, navigate to your Skafos dashboard and verify that your new model is there!

Model management tab on the dashboard.

Deploy this model (or any model) to your app by clicking the Deploy button. You will be presented with two environment groups: Dev or Prod. In your iOS app, the keys you set in the AppDelegate.swift file dictate the environment from which models will be downloaded.

That’s it! You can do this as many times as you need to iterate on your model. You can upload to Skafos, deploy to Dev or Prod as needed, or roll back to older model versions if there’s an issue. No need to re-release through the App Store to get out model updates to your user base. Period.


Intrigued? Want to try this out? Here are some resources:

We’re excited to see what you build!

Skafos

Skafos makes it simple for you to build ML-powered apps, whether you are prototyping or delivering to millions of devices.

Thanks to Lisa Richey and Miriam Friedel.

Tyler Hutcherson

Written by

Skafos

Skafos

Skafos makes it simple for you to build ML-powered apps, whether you are prototyping or delivering to millions of devices.