The Yeezy Detector: an image classification model

Using Apple’s Create ML tool to develop a Core ML machine learning model that classifies Yeezy shoe models

Rahul D'Costa
MyTake
5 min readSep 8, 2019

--

Apple’s Core ML framework has enabled the creation and implementation of accurate, highly powerful machine learning models for developers who aren’t all that experienced in machine learning at all. Using Create ML, which allows the creation of Core ML models, one can use a dataset of images to develop a model that would be able to classify future images into the categories initially outlined by the model.

As a side project for my internship, which involved implementing an image classification model for an iOS application, I decided to create an image classification model to detect different models of Adidas Yeezys.

Kanye West surrounded by a variety of Yeezys (Photo by Jamel Toppin / Forbes)

First, a list of the models to be detected has to be made. For this example, I created ten categories representing ten different models of Yeezys:

· YEEZY BOOST 350 V2 “CLAY

· YEEZY BOOST 700 “INERTIA”

· YEEZY BOOST 350 V2 “FROZEN YELLOW”

· YEEZY BOOST 350 V2 “ZEBRA”

· YEEZY BOOST 350 V2 “BUTTER”

· YEEZY BOOST 350 V2 GID “GLOW”

· YEEZY BOOST 350 V2 “BELUGA”

· YEEZY BOOST 350 “PIRATE BLACK”

· YEEZY BOOST 700 V2 “TEPHRA”

· YEEZY BOOST 350 V2 “STATIC”

Based on these models, the dataset of the images of the shoes must be created. I named the folder “Yeezy Detector Model” and in this folder created two more folders, “Training Data” and “Testing Data”. In each of these folders, folders whose names were the shoe models below were created, as illustrated below.

Folders for training data. The same should be done for the testing data.

Now, we need the images for each folder. To get these images, I searched each model on Google Images and used an extension to download all the images on a search page. This amounted to around 500 images for a webpage. Once we have these images, it is important to clean the data i.e. making sure that each image belongs to the model that is being searched for. I also included mostly one shoe for each image to improve the accuracy of the model. After cleaning, around 250 images per model were used.

Images for the Yeezy Boost 350 V2 “Zebra”

Before proceeding, it is important to verify that we need 80% of the images for a model in the training data for a model and 20% of the images in the testing data for that same model. For the “Zebra” model, I used 243 images in total — 203 images were in the Training Data folder and 40 images were in the Testing Data folder.

Now that the data is ready, Create ML can be used to create the image classification model that would be able to detect each of the ten models of Yeezys of which a dataset has been prepared.

First, make sure that Xcode is installed on your device. From there, choose “Get started with a playground”. From here choose the “Blank” template under “macOS”. Name the .playground file something relevant and save it to a directory. The playground will now be displayed, showing two lines of code.

The first view of an Xcode playground

Now, replace the existing code with the following code which will enable the Create ML API to enable the creation of the model.

import CreateMLUIlet builder = MLImageClassifierBuilder()builder.showInLiveView()

Once this code is added, make sure the “Run” button, which is a small play button located along the line numbers, covers the entirety of the code and is situated below the code. Now, click on “Run”.

You should see two items appear on the right side, “Image Classifier Builder” and “Open Assistant Editor”. Use the shortcut ‘⌥⌘↩’ which will open the Assistant Editor. You should now see the following on your screen:

Playground ready to train the model

Click on the small arrow next to ImageClassifier and set the max iterations to 2500. We can now train the model. Go to “Finder” and drag the “Training Data” folder to the area labeled “Drop Images to Begin Training”. The model will now begin to train, and you can drag from the bottom of your screen to check out the progress of the training.

Training started for the model

After training is completed, drag and drop the “Testing Data” folder to the “Drop Images to Begin Testing” area. After Testing, you can view the accuracy of your model using the validation and evaluation percentages as well as the confusion matrix.

Confusion Matrix and Precision-Recall

Go ahead and rename the model and save it in a directory. Congratulations, you have now created a Core ML model that will be able to detect Yeezys! We can now implement this model in an iOS application. This will include being able to choose an image from your photo library or taking a picture of your Yeezys using your camera and having your image classification model detect the model of the Yeezys in the image you choose.

Below is a link to the dataset containing images of the shoes. Good luck! https://drive.google.com/drive/folders/1ssGjELIV2mffGb-rhXpMj-fyUh9w1cWw?usp=sharing

--

--

Rahul D'Costa
MyTake
Writer for

Technology, hip-hop, and sports enthusiast. Studying Computer Science at the University of Michigan. Go Blue!