Add Machine Learning to your iOS 

App with Core ML
Jean-Luc David

iOS Developer
My iOS Machine Learning App Circa 2012
OpenCV
Popular Perceptions
Popular Perceptions
Popular Perceptions
Nomenclature
Application of Machine Learning
Silicon Valley - Jian-Yang's Not Hotdog App
Fiction Becomes Reality
Types of Machine Learning
Core ML
• Announced at WWDC 17.
• Works only on iOS 11
• Inference engine
• Does not support training models.
• Heterogenous compute architecture - CPU & GPU.
• Open Source Python coremltool for converting
to coremlmodel file.
But I want to train models!
Runs On Device
User Privacy Data Cost Server Cost Available
How Does a Model Work?
Machine Learning Model Types
Demo - Face Detection & Recognition
Types of Machine Learning
Offline
+ Labels
Task - Find a Rose
Inference is Difficult
Inference is Difficult
Core ML Model
• Single Document
• Public Format
• Reduced Size
• Improved Accuracy
• Decreased Prediction

Time
Core ML Architecture
• Unified Fine Tuned Inference Engine
• Xcode Integration
• Built on Accelerate and Metal
• Public Model Format
• Support for Popular Training Libraries
Core ML Model
• Function learned from data
• Observed inputs
• Predicts outputs
• Single Document
• Public Format
• Ready to Use
• Task Specific
Sample Models
https://developer.apple.com/machine-learning/
Converting to Core ML
Core ML 

Tools
Open Source
Converting to Core ML
• Download a trained .caffemodel and
a .prototxt of the dataset, as well as a .txt list
of names related to the model.
• Install Python 2.7 and pip
• Install, create, then activate the virtualenv.
• Write and run a Python script to convert
the .caffemodel to a Core ML model,
using coremltools
• Add the generated .mlmodel to the Xcode project
Demo - Converting a Model to MLModel
Xcode Integration
Swift ML Code
Generates this code
Model as Code
• Quick Initialization
• Optimized Prediction
Xcode Your App
Demo - FlowerClassifier
Resources
• https://www.slideshare.net/jldavid
• https://github.com/jldavid/FaceDetection
• https://github.com/jldavid/FlowerClassifier
Thank You

Add Machine Learning to your iOS 11 App Using Core ML