Machine Learning and Object Detection Application — Part 2

Gianluca De Lucia
3 min readApr 3, 2020

--

Introduction

For those of you who haven’t done so, please read the first part of the article here.

Model training

An example about how to create a model using Create ML

Example of training for detection object in Create ML

This video is just for giving an example of the use case of Create ML in order to create an object detection model. In fact, during the demonstration we used fewer images than necessary for the training. Besides, the proportion between training images and testing images isn’t correct and if we increase number of iterations, we increase the precision. The process of creating an image classifier remains the same, but the only difference is that we have a subfolder for each object (and the image inside that) in training and testing folder, instead of a JSON file with the image description inside.
Next, on the left we can see the new model just created that we can export as an mlmodel file and import it in our code.

Model’s integration in the code

Once we exported the model out of Create ML, we now had a .mlmodel file that must be imported in the project. First of all, we needed to create an XCode project, define the necessary permissions to enable the mobile camera and create a view controller to manage it. Then, we could import the model inside Xcode:

Import of mlmodel inside XCode

Next, created a second view controller that uses Vision to manage object detection. After importing the model, we need to associate it to the new view controller:

Association of the model inside the code

For more information on a project example we suggest to consult the [8] the sources listed below, which this project is strongly based on.Conclusion

The goal of this article is not to provide an exhaustive tutorial on how to develop a machine learning-based iOS app but, being an academic and study project, it is to analyze the main aspects of creating and importing a machine learning model inside a generic XCode project.

During this study we analyzed the main phases of developing this project and reported here in this article, and the difficulty encountered in the choice of a valid enough image dataset. For each image, in fact, and in particular for each object we should consider a lot of parameters including size, shape, rotation, color, number of objects inside the image and number of images of each object. Clearly, this last one and their homogeneity is directly proportional to the probability that the model is created in an accurate and functional way.

Exultation

If after this article you tried to develop a machine learning-based iOS app which manages object detection, then enjoy the fun of tasting your creation. We are tasting like this:

Fruitable, our app from IOS Developer Academy

A big greeting from Doct. Andrea Capone and Doct. Gianluca De Lucia, two computer science doctor.

Thank you for reading.

Fruitable, app icon

For more information you can contact us to our E-Mails:

Andrea: capone.andrea195@gmail.com
Gianluca: gianluca.delucia.94@gmail.com

Github profile:
Andrea:
https://github.com/One195/
Gianluca:
https://github.com/gigernau

Fruitable application link:
https://github.com/One195/Fruitable

--

--

Gianluca De Lucia

“May your choices reflect your hopes, not your fears.”