Skip to Content

Use Create ML to Train an Image Classification Model

Get to know Create ML and how to create an Image Classification Model for products.
You will learn
KevinMuessigKevin MuessigJanuary 12, 2022
Created by
KevinMuessig
January 23, 2020
Contributors
KevinMuessig

Prerequisites

  • Development environment: Apple Mac running macOS Catalina or higher with Xcode 12 or higher
  • SAP BTP SDK for iOS: Version 6.0 or newer
  • What Create ML is
  • How to create an Image Classification Model
  • Step 1

    Since MacOS 10.14 developers have the opportunity to use Create ML as a tool to train different types of Core ML models to be used in your apps.

    Currently Apple supports the following types of models:

    Image:

    Sound:

    Motion:

    Text:

    Table:

    If you’re interested in a more detailed description on how to use and create those models you can take a look at Apple’s official documentation about Create ML and the API documentation.

    With this easy to use tool you can quickly create, train, and test the above mentioned ML models via Templates.

  • Step 2

    For this tutorial series you’re going to need an Image Classification Model to identify products.

    1. After you have installed Create ML you should see a popup asking you to create a New Document. Please select that to reach the template screen in Create ML.

      Create ML
    2. Now please select the Image Classifier template as a starting point and click on Next.

      Create ML
    3. Fill out the required fields like the following and click on Next:

      Field Value
      Project Name ProductImageClassifier
      Author Your name
      Description A machine learning model that has been trained to recognize images. When you give it an image, it responds with a label for that image. It is trained on product images.
      Create ML

      Create ML will ask you for a location to safe the project at. Please select your preferred location and click on Create.

      You should see the project opening up.

      Create ML
  • Step 3

    In order to train your model in the created project you need images of products. As this is just an example you need only a few images for this tutorial series.

    Let’s try and get 5-10 images of Laptops including MacBooks as well as office chairs. There are several ways you can get those images:

    1. Take the pictures yourself from different angles of the product and a variety of products.
    2. Download images from the internet to train your model on. Please make sure you’re not using copyright images because it could be that you need the rights for using those.
    3. Use one of many training image pools online.

    Personally I’ve just taken a bunch of pictures around the office and train the model on those. Of course if you have a productive model you need to train it on far more then just 5-10 images.

    If you have all images ready you have to structure them in a specified way for Create ML to successfully train your model.

    The folder structure needs to look like the following:

    Create ML

    The training data and the testing data need to be different images for Create ML training and testing properly.

    After you’ve chosen your training and testing data inside of Create ML you could add different Augmentations if you want to but for now this is not necessary.

    Create ML

    To create a Core ML model you just have to hit Train located on the top of Create ML.

    Create ML

    After Core ML runs the training you will get results similar to the following screenshot. This data allows you to understand your model, how accurate it is and how you might need to tweak the training to get better results.

    The model should work just fine and you can export it onto the hard-drive or directly into Xcode.

    Create ML

    Please export the model directly into Xcode and then continue with the next tutorial.

    Create ML
    Create ML

    Congratulations! You’ve trained a Core ML model with Create ML. Feel free to play around more with Create ML and the Machine Learning capabilities with Artificial Intelligence.

    Why is it so important to label the folders which contain your machine learning data? Please check the correct answer below.

Back to top