Core ML vs ML Kit: Which Mobile Machine Learning Framework Is Right for You?

Until recently, there were very few libraries available for performing machine learning on mobile platforms. But these days we’re seeing loads of libraries being released. Last year, Apple released Core ML at WWDC, and it was considered a big step for the field of mobile ML.

Since then, we’ve seen lots of libraries and SDKs being released for the same purpose. Following the trend, Firebase — which is owned by Google — released ML Kit. However, it seems that developers are still reluctant to use ML Kit in their apps. In this post we’ll compare the two libraries, but first we should know why machine learning on mobile is a big deal.

Importance of Mobile Machine Learning

Machine learning is an extremely useful technology, and usage seems to be growing at an exponential rate. Nearly every day we see new advances, but this won’t continue if machine learning is not available to the masses.

Mobile phones are the best way to achieve this scale—the number of smartphone users is estimated to cross 5 billion by 2019. Many attempts have been made to help developers build apps that utilize machine learning, but not all have been successful. The release of these libraries is extremely important, as they make the complicated task of performing machine learning on mobile simple, and allow app developers with no prior machine learning experience to implement ML-enabled features in their projects.

Core ML

Apple released Core ML at WWDC ’17, and it was updated to Core ML 2 this year. As a reminder, Core ML enables developers to integrate machine learning models into iOS and MacOS apps. This was the first big attempt in this field, and initially, developers really liked it for a number of reasons.

Core ML is optimized for on-device performance, which minimizes a model’s memory footprint and power consumption. Running strictly on the device also ensures that user data is kept secure, and the app runs even in the absence of a network connection.

Core ML’s biggest advantage is that it is extremely simple to use. Just a few lines of code can help you integrate a complete machine learning model. Since the release of Core ML, there has been a flood of innovative projects using it. However, there are limitations around what Core ML can do. Core ML can only help you integrate pretrained ML models into your app. So this means you can do predictions only, no model training is possible.

Thus far, Core ML has proved to be extremely useful for developers. Core ML 2, which was announced at WWDC this year, should improve inference time by 30% using techniques called quantization and batch prediction.

Create ML

Apple also announced Create ML at this year’s WWDC. Create ML allows developers to train machine learning models within Xcode using Swift and MacOS Playgrounds. Developers with no machine learning experience can train models and don’t have to depend on other developers.

Create ML has enhanced the utility of Core ML by forming a complete package of tools. Currently, Create ML supports three data types: images, text and tabular data. There are many training and testing algorithms like Random Forest Classifier and Support Vector Machines. Create ML also reduces the size of trained machine learning models and offers a way to train models using Create ML UI.

ML Kit

Firebase announced ML Kit at Google I/O 2018. ML Kit enables developers to utilize machine learning in mobile apps in two ways: Developers can either run model inference in the cloud via API, or run strictly on-device, just like with Core ML.

ML Kit offers six base APIs that are ready to use for developers, with the models already provided: Image Labeling, Text Recognition (OCR), Landmark Detection, Face Detection, Barcode Scanning and Smart Reply (coming soon). If these APIs don’t cover your use case, then you can also upload a TensorFlow Lite model and ML Kit takes care of hosting and serving your model to your app.

The on-device version of ML Kit offers low accuracy compared to the cloud version, but at the same time it offers more security to user data. The base APIs offered by ML Kit cover all the general use cases of machine learning on mobile platforms, and the option to use custom trained models makes ML Kit a complete machine learning solution for mobile platforms.

Comparison

Both Core ML and ML Kit enable developers to leverage the power of machine learning in their apps. This may finally make these features accessible to the masses.

When compared to Core ML, ML Kit has a few advantages. ML Kit’s main advantage is that it supports both iOS and Android, and the same APIs can be utilized on both platforms. ML Kit has six base APIs that are easy to implement and do not require any machine learning expertise. If your use case is covered by the base APIs offered by ML Kit, then it’s a better option because of the pretrained models.

Another advantage with ML Kit is that it offers both on-device and cloud-based APIs. On-device APIs in ML Kit are designed to work fast and will be able to provide results even in the absence of an internet connection. The cloud-based APIs utilize the Google Cloud ML platform and provide an increased level of accuracy. The disadvantage with ML Kit is that you might need to upgrade your Firebase plan to a paid one depending on your use.

If you are only interested in developing for iOS, then Core ML paired with Create ML might be more useful. Apple’s tools allow you to both train and implement machine learning models in your app using fewer lines of code. Training models with Create ML is also easier than using TensorFlow, but TensorFlow offers more advanced training algorithms.

Core ML and ML Kit are both great tools, but each has limitations. Understanding your exact use case, and which platforms you will support beforehand, can help you decide which option is best.

Other Options

Core ML and ML Kit might be the most talked about ML libraries available for mobile platforms, but they aren’t the only ones. There are many open source machine learning libraries for mobile platforms such as Shark, AIToolbox, BirdBrain, and others. However, these libraries haven’t been used extensively because they aren’t backed by any big organization. Check out a few more libraries here.

Discuss this post on Hacker News.

Fritz

Our team has been at the forefront of Artificial Intelligence and Machine Learning research for more than 15 years and we're using our collective intelligence to help others learn, understand and grow using these new technologies in ethical and sustainable ways.

Comments 0 Responses

Leave a Reply

Your email address will not be published. Required fields are marked *

wix banner square