Create a Hand Pose ML model using Create ML

Edoardo Troianiello
5 min readMar 31, 2022

--

First of all, let’s start with some basic concepts then we will focus on how to create a hand pose model.

Create ML

Create ML is a framework from Apple for machine learning. It allows the creation and training of machine learning models within the Apple ecosystem. The trained models can be easily integrated into own apps with Core ML.

Choose The Subject

CreateML allows you to choose different templates to train a model, such as Image classification which classifies the dominant object, or Hand Pose Classification which classifies a hand pose in an image.

This article is going to focus on the hand pose classification template.

Create ML Templates

Search for a dataset or create your own

A dataset is needed in order to train a model, but what is a dataset?

Oxford Dictionary defines a dataset as “a collection of data that is treated as a single unit by a computer”. This means that a dataset contains many separate pieces of data but can be used to train an algorithm to find predictable patterns inside the whole dataset.

A dataset should be divided into three parts: Training, Validation, and Testing datasets.

Although CreateML will divide automatically Training and Validation, you will be required to provide the Testing one.

Build your own dataset

Generally, it is not needed to create your own dataset and it is surprising how many types of collections can be found on the internet. Since creating a high-quality dataset is the most time-consuming part of the project which requires a lot of experience, it’s better to develop the first models using preexisting datasets.

However, if a dataset is not available, you need to create your own. This work can be divided into three main steps.

1. Collecting

The first step is to decide the sources to use to collect data, such as internet, artificial data generator, or open-source datasets.

2. PreProcessing

This stage is to ensure the data is clean and relevant for the purpose of the training.

3. Annotate

Finally, it is important to make sure that the data is understandable for a computer to process by labeling your data and creating a class for everything the model has to recognize. For example, the dataset used for the purpose of this article contains 28 classes.

There are some software that can help with the annotation process, like IBM Cloud annotation, Appen, Amazon SageMaker etc.

Dataset classes

Search for datasets

The internet is full of resources and huge collections of every kind of dataset.

One of the best source for providing datasets for Data Scientists and Machine Learners is Kaggle.

Other helpful sites to find the perfect dataset are :

  • Dataset via Amazon AWS
  • Google’s Dataset search engine
  • Microsoft Dataset

The difficult part of this step is choosing a high-quality dataset. High quality is an essential point to take into consideration when collecting datasets for a machine learning project. In a high-quality dataset, all the data pieces should be relevant to your goal, and furthermore, it’s important to ensure the pieces of data are of sufficient quality.

In addition, even for relevant and high-quality datasets, there is a problem of blind spots and biases that any data can be subject to. An imbalanced dataset in machine learning poses the dangers of throwing off the prediction results of your carefully built ML model.

Keep in mind that not only quality but quantity matters, too. It’s important to have enough data to train your algorithm properly. There’s also a possibility of overtraining an algorithm (known as overfitting).

SetUp Create ML

Once the dataset is ready, it’s time to set up Create ML and train your own model.

  1. Open Create ML and create a new project. After choosing the type of classification, you can start feeding the machine with the dataset.
  2. Click the plus button on training data and select the directory, as said before validation will be set to auto (for the first project it’s better to leave it that way), then add the Testing Data.
  3. At this point, choose a proper number of iterations and click the play button in the top left corner.

NOTE: There’s no general rule about the best iteration number, it strongly depends on your dataset: some small datasets could be overfitting just after 20 or 50 iterations, others after more.

Export the Model

As within the all apple environment, it’s really easy to export your model and to import it on Xcode. On the top right corner of Create ML, you will find three buttons which allow you to save it wherever you want, export it directly on Xcode or share it.

ASL Recognition Model

I decided to create a hand pose classification model which recognizes the ASL (America Sign Language).

My dataset is composed of 220k images ( about 7000 images for each class) and a testing dataset composed of 4500 images. I chose 80 iterations but my huge dataset might have needed some more.

Be aware that a huge dataset like this could take a lot of time to train, in this case, it required 28+ hours.

After the training was done I was able to see the results.

The final results after the training were: 92% Training Accuracy and 90% Validation Accuracy.

Using the hand pose classification template gives you the opportunity to have a live preview of the model and thus to verify your results.

If you enjoyed this article, please click the 👏 button and share to help others find it! Feel free to leave a comment below and follow me.

--

--

Edoardo Troianiello

Computer Engineer | iOS Developer | Alumni @Apple Developer Academy in Naples