Chapter 6: Getting Started with Create ML

Create ML is a tool used to train custom models on top of pre-trained models. It offers a user-friendly interface that combines a graphical user interface (GUI) and a Swift-based training environment, making it an excellent platform for training machine learning models.

It supports multi-model training, allowing us to train multiple models using diverse datasets within a single project.

Unlike other training methods, Create ML doesn’t need specialized machines. Instead, it enables model training on our Mac, leveraging the power of both the GPU and CPU.

Additionally, it provides visual evaluation capabilities, enabling us to assess the model’s performance on test data. .

Create ML supports a wide range of model types, giving us the freedom to select the most suitable model for our specific needs.

Credit Apple.com

Let’s build a new model using Create ML to classify various fruits. This type of model is known as Image Classifier.

Image classifier

An image classifier is a machine learning model that recognizes images. When we give it an image, it responds with a category label for that image.

Credit Apple.com

We train an image classifier by showing it many examples of images we have already labeled. For example, we can train an image classifier to recognize animals by gathering photos of elephants, giraffes, lions, and so on.

Credit Apple.com

After the image classifier finishes training, we assess its accuracy and, if it performs well enough, save it as a Core ML model file. We then import the model file into our Xcode project to use the image classifier in our app.

Data Prep

During the training process, we will need a dataset to train the new model on. Fortunately, the Kaggle community offers a wide variety of datasets that can be downloaded and used to train our own models.

We will be using this dataset from Kaggle.com.

https://www.kaggle.com/datasets/shreyapmaher/fruits-dataset-images

This dataset comprises nine folders, each containing nine distinct types of fruit images.

Each folder contains approximately 40 images, as Create ML employs transfer learning, we do not require an exceptionally large number of images for training our own model. Notably, each folder is named after the fruit it contains. This naming convention is crucial because it ensures that all images of a specific fruit type are grouped together in a single folder, and the folder’s name is assigned as the class for the images that the model will be trained on. The names of the images within the folder are irrelevant and can be anything.

Create ML uses the VisionFeatureScreen_Print model for transfer learning. This model was trained on a larger dataset to recognize various entities, including objects, people, animals, and vegetables. (More on this in next chapter.)

Model Training

To get started, we need to open the Create ML app.

  1. Launch Xcode if it is not already open.

  2. In the menu bar at the top, click on Xcode to open the dropdown menu.

  3. Select “Open Developer Tool” from the list of options.

  4. From the sub menu, choose “Create ML” to launch the Create ML application.

After launching the Create ML app, we are presented with a template selection screen where we can select a template for our machine learning project.

The app provides several predefined templates tailored for different machine learning tasks. These templates simplify the setup process by configuring the necessary parameters, data requirements, and pre-trained models.

We are working on an image classification problem, so we will select the “Image Classification” template and click the “next” button.

On the next screen, we will be prompted to provide details about the project, including its name, author, license, and description.

Once we have filled in all the information, click “Next” and select a location to store the project file. The project will be created, and we will be presented with a screen where we can train our model.

Conclusion

In this chapter, we explored the Create ML app and embarked on an exciting journey to create our very first project.