Why not login to Qiita and try out its useful features?

We'll deliver articles that match you.

You can read useful information later.

1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Create Image Classifier with CreateML

Posted at

Introductions

In WWDC 2018 event, Apple has introduced their brand new Machine Learning Framework call CreateML. It allow you to build machine learning model very quick and easy by using Xcode and Swift. It's designed for simplicity and performance. It was build based upon the Metal to run our training process on the GPU rather than CPU, so that we can train image classifier for 20000 images within an hour according to Apple.

Basic System Requirements

  • Beta of Xcode 10
  • MacOS 10.14 (Mojave)

Preparing the dataset

In this article, I will create an Image Classifier to classify between boy and girl. So let's go ahead and download images for boys and girls from Google and place it in two different folder as it's going to be the label of our Image Classifier.
screenshot.png

Data Traning

After get all the dataset, let's go ahead and create new Playground in Xcode for macOS.
screenshot.png
Let's go ahead and write some code.
I separate all of those dataset into two parts, 80% TraningData and 20% for TestingData.
screenshot.png

import CreateMLUI

let builder = MLImageClassifierBuilder()
builder.showInLiveView()

then run this code. after that you should see something as shown in the picture below:
screenshot.png
after that drag and drop your TraningData dataset into the ImageClassifier in Xcode. It took me a fews second to finish training the classifier. After that drag the TestingData dataset into the ImageClassifier for testing our model.
screenshot.png
Here we got 100% Training and 100% Evaluation. That's mean our model is ready.
** Note: The more image you give for training, the more accurate image classifier you will get.
You can also export your model as .mlmodel file.
screenshot.png
You can use this model in your application with the help of CoreML library.

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up

Qiita Conference 2025 will be held!: 4/23(wed) - 4/25(Fri)

Qiita Conference is the largest tech conference in Qiita!

Keynote Speaker

ymrl、Masanobu Naruse, Takeshi Kano, Junichi Ito, uhyo, Hiroshi Tokumaru, MinoDriven, Minorun, Hiroyuki Sakuraba, tenntenn, drken, konifar

View event details
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?