Using Skafos with AWS Sagemaker

Miriam Friedel
4 min readMay 31, 2019

--

This article was written by Ashley Dahl, a senior at St. Anne’s Belfield School in Charlottesville, VA. Ashley interned with Skafos in May 2019, and will be attending the University of Virginia in the fall.

In a previous article, we showed you how to train a model with Turi Create on Google Colab. But what if you prefer to work with AWS SageMaker? Not a problem! This article walks you through training one of our example models on SageMaker and saving it to Skafos using the Python SDK.

Because our Python SDK is training environment agnostic, you can train your models on Sagemaker and upload them to the Skafos platform. Skafos allows machine learning engineers and app developers to work together to seamlessly deploy their newly trained models to their mobile apps in the background, bypassing app store releases. The SDK is a toolkit with which Skafos users can upload their machine learning models from any Python 3+ environment.

We have created a number of example models including Image Classification, Text Classification and Object Detection to help you get started. While these models were built using Google Colab, the Skafos SDK enables Data Scientists to train models on their platform of choice, and remain in a Python environment to upload their model to Skafos, where they can deploy the model straight to their app.

Amazon Web Services Sagemaker makes training and optimizing machine learning models accessible to all, providing an end-to-end cloud-based platform on which to operate. Coupled with the Skafos SDK, training your model, uploading it to Skafos, and deploying the model to mobile applications is extremely streamlined.

Training on Sagemaker

After creating a free account with AWS, I created a ml.t2.medium “Notebook Instance” with a Conda Python 3 environment and was able to begin transferring the example code from Github. Within minutes, I had a trained model which I converted to CoreML format on Sagemaker. Then I was able to connect directly with my Skafos account via my organization and app names and my Skafos API token. The upload command can be found in the Model Version Management segment of the SDK Documentation. With these new tools, it’s clear that the future of machine learning and app development is becoming increasingly user-friendly, faster, and headed towards more seamless integration.

How I did it

1. Created Skafos account

2. Created an AWS account, created a Notebook Instance, and opened JupyterLab.

3. In the notebook instance, I chose Files → New → conda_python3

4. Used an example model from the Skafos GitHub Repository

5. Uploaded the trained model with the Skafos SDK.

import skafos
from skafos import models
import os

# Set your API Token first for repeated use
os.environ["SKAFOS_API_TOKEN"] = "<YOUR-SKAFOS-API-TOKEN>"

# You can retrieve this info with skafos.summary()
org_name = "<YOUR-SKAFOS-ORG-NAME>"
app_name = "<YOUR-SKAFOS-APP-NAME>"
model_name = "<YOUR-MODEL-NAME>"

# Upload model version to Skafos
model_upload_result = models.upload_version(
files="TextClassifier.mlmodel",
org_name=org_name,
app_name=app_name,
model_name=model_name,
description="Upload from AWS using SDK"
)

6. When I navigated back to the Skafos dashboard, I could see the model I just uploaded. It is version 5 in the screenshot below.

In under a half hour, I was able to pull some existing code into Sagemaker and upload it to Skafos for delivery. I know that the next time I do this will be even faster, and I’m excited to continue working with these platforms.

--

--

Miriam Friedel

Mom, Data Scientist, Physics PhD. Currently: Senior Director, Machine Learning Engineering at Capital One. Previously: Director of Data Science at Skafos.