際際滷

際際滷Share a Scribd company logo
Navigating the
!
ML Landscape
Meghan Kane, @meghafon
developer @novoda, Berlin
Swift & Fika, 9/2018
Navigating the Apple ML Landscape
Navigating the Apple ML Landscape
!
before we pack our bags..
why use machine learning .. at all?
ML tasks
 detection: rectangles, face, barcode, text
 classi鍖cation: image, text, activity, column data
 style transfer
 image similarity
 object detection
 natural language processin
 regression
Navigating the Apple ML Landscape
Advantages of on device inference
1. user privacy
2. low latency user experience
Let's start our road trip
Navigating the Apple ML Landscape
Classify
board game
pieces
ML approach
Label: "Border"
1. Detect game box (rectangle
detection)
2. Classify Agricola piece within
rectangle (image classi鍖cation)
Capabilities
... built right into the Vision
framework, no model training
needed
 detection: rectangles, face,
barcode, text
 object tracking
 image alignment
How?
1. create handler
2. create task speci鍖c request
3. send request to handler
4. handle results
// 1. Create handler
let handler = VNImageRequestHandler(cgImage: image,
orientation: orientation,
options: [:])
// 2. Create request
let request = VNDetectRectanglesRequest(completionHandler: self.handleDetectedRectangles)
// 3. Send request to handler
do {
try handler.perform([request])
} catch let error as NSError {
// handle error
return
}
// 4. Handle results
func handleDetectedRectangles(request: VNRequest?, error: Error?) {
if let results = request?.results as? [VNRectangleObservation] {
// Do something with results [*bounding box coordinates*]
}
}
ML approach
Label: "Border"
1. Detect game box (rectangle
detection)
2. Classify Agricola piece within
rectangle (image classi鍖cation)
Why restrict input image to the box?
 easier to train an accurate model
 faster to collect image data
Capabilities
In Xcode playground, train custom
model for:
 image classi鍖cation
 text classi鍖cation
 classi鍖cation & regression of
column data
Collect Data
 Collect images representative of real world use
cases
 Vary angle & lighting
 >10 images per label, but ideally more
 Equal # images for each label
 Recommended: >299x299 pixels
Collecting Data Quickly
// Extract .jpg frames from .mov @ 5 frames/sec
ffmpeg -i stone.mov -r 5 data/stone/stone_%04d.jpg
Prepare Data
 Split data: 80% train / 20% test
Navigating the Apple ML Landscape
Navigating the Apple ML Landscape
Navigating the Apple ML Landscape
what's happening behind the scenes?
Transfer
Learning
Navigating the Apple ML Landscape
Evaluate
Navigating the Apple ML Landscape
Save model
Capabilities
 perform predictions using
model
 quantized weights (32 bit -> 16,
8, 4... bit)
 perform batch predictions
 create custom model layer
Vision + Core ML
1. create Vision Core ML model
2. create handler
3. create task speci鍖c request
4. send request to handler
5. handle results
// 1. Create Vision Core ML model
let model = AgricolaPieceClassifier()
guard let visionCoreMLModel = try? VNCoreMLModel(for: model.model) else { return }
// 2. Create handler
let handler = VNImageRequestHandler(cgImage: cgImage, orientation: cgImageOrientation)
// 3. Create request
let request = VNCoreMLRequest(model: visionCoreMLModel,
completionHandler: self.handleClassificationResults)
// 4. Send request to handler
do {
try handler.perform([request])
} catch let error as NSError {
// handle error
return
}
// 5. Handle results
func handleClassificationResults(request: VNRequest?, error: Error?) {
if let results = request?.results as? [VNClassificationObservation] {
// Do something with results
}
}
Problem solved

Label: "Border"
1. Detect game box (rectangle
detection)
2. Classify Agricola piece within
rectangle (image classi鍖cation)
Next
challenge...
Navigating the Apple ML Landscape
Capabilities
...robust Python training
framework
 style transfer
 activity classi鍖cation
 image similarity
 recommmendations
 object detection
Setting up python
virtualenv venv
source venv/bin/activate
pip install requests==2.18.4 turicreate==5.0b2 jupyter
Train style transfer
jupyter notebook
Navigating the Apple ML Landscape
Navigating the Apple ML Landscape
Ad

Recommended

426 lecture 4: AR Developer Tools
426 lecture 4: AR Developer Tools
Mark Billinghurst
Drone ppt
Drone ppt
Changik Choi
Cutting Edge Computer Vision for Everyone
Cutting Edge Computer Vision for Everyone
Ivo Andreev
5 Ways to Improve Your LiDAR Workflows
5 Ways to Improve Your LiDAR Workflows
Safe Software
Lecture 5,6(Comp Vision) [Auto-saved].pptx
Lecture 5,6(Comp Vision) [Auto-saved].pptx
SadiqaKhan13
Towards Machine Intelligence
Towards Machine Intelligence
Daniyal Shahrokhian
Advanced Game Development with the Mobile 3D Graphics API
Advanced Game Development with the Mobile 3D Graphics API
Tomi Aarnio
Annotation tools for ADAS & Autonomous Driving
Annotation tools for ADAS & Autonomous Driving
Yu Huang
Django Good Practices
Django Good Practices
Solution4Future
Unsupervised Aspect Based Sentiment Analysis at Scale
Unsupervised Aspect Based Sentiment Analysis at Scale
Aaron (Ari) Bornstein
patternfinders-141205004957-conversion-gate02.pptx
patternfinders-141205004957-conversion-gate02.pptx
snnit
Easy path to machine learning
Easy path to machine learning
wesley chun
Analytics Zoo: Building Analytics and AI Pipeline for Apache Spark and BigDL ...
Analytics Zoo: Building Analytics and AI Pipeline for Apache Spark and BigDL ...
Databricks
Viktor Tsykunov: Azure Machine Learning Service
Viktor Tsykunov: Azure Machine Learning Service
Lviv Startup Club
Ember.js Tokyo event 2014/09/22 (English)
Ember.js Tokyo event 2014/09/22 (English)
Yuki Shimada
Gitter marionette deck
Gitter marionette deck
Mike Bartlett
Marker-based Augmented Monuments on iPhone and iPad
Marker-based Augmented Monuments on iPhone and iPad
Enrico Micco
Leaving Flatland: Getting Started with WebGL- SXSW 2012
Leaving Flatland: Getting Started with WebGL- SXSW 2012
philogb
5 Ways to Optimize Your LiDAR Data
5 Ways to Optimize Your LiDAR Data
Safe Software
Apple Machine Learning
Apple Machine Learning
Denise Nepraunig
Overcoming The Impedance Mismatch Between Source Code And Architecture
Overcoming The Impedance Mismatch Between Source Code And Architecture
Peter Friese
Mirko Lucchese - Deep Image Processing
Mirko Lucchese - Deep Image Processing
MeetupDataScienceRoma
Scala.IO 2024: Mill builds in Scala 3, a migration story
Scala.IO 2024: Mill builds in Scala 3, a migration story
James Thompson
Javascript Design Patterns
Javascript Design Patterns
Iv叩n Fern叩ndez Perea
Easy path to machine learning (Spring 2021)
Easy path to machine learning (Spring 2021)
wesley chun
Cloudera Data Science Challenge
Cloudera Data Science Challenge
Mark Nichols, P.E.
Data Science Challenge presentation given to the CinBITools Meetup Group
Data Science Challenge presentation given to the CinBITools Meetup Group
Doug Needham
From Zero to Hero Web Performance
From Zero to Hero Web Performance
Sebastian Springer
FUNDAMENTALS OF COMPUTER ORGANIZATION AND ARCHITECTURE
FUNDAMENTALS OF COMPUTER ORGANIZATION AND ARCHITECTURE
Shabista Imam
Modern multi-proposer consensus implementations
Modern multi-proposer consensus implementations
Fran巽ois Garillot

More Related Content

Similar to Navigating the Apple ML Landscape (20)

Django Good Practices
Django Good Practices
Solution4Future
Unsupervised Aspect Based Sentiment Analysis at Scale
Unsupervised Aspect Based Sentiment Analysis at Scale
Aaron (Ari) Bornstein
patternfinders-141205004957-conversion-gate02.pptx
patternfinders-141205004957-conversion-gate02.pptx
snnit
Easy path to machine learning
Easy path to machine learning
wesley chun
Analytics Zoo: Building Analytics and AI Pipeline for Apache Spark and BigDL ...
Analytics Zoo: Building Analytics and AI Pipeline for Apache Spark and BigDL ...
Databricks
Viktor Tsykunov: Azure Machine Learning Service
Viktor Tsykunov: Azure Machine Learning Service
Lviv Startup Club
Ember.js Tokyo event 2014/09/22 (English)
Ember.js Tokyo event 2014/09/22 (English)
Yuki Shimada
Gitter marionette deck
Gitter marionette deck
Mike Bartlett
Marker-based Augmented Monuments on iPhone and iPad
Marker-based Augmented Monuments on iPhone and iPad
Enrico Micco
Leaving Flatland: Getting Started with WebGL- SXSW 2012
Leaving Flatland: Getting Started with WebGL- SXSW 2012
philogb
5 Ways to Optimize Your LiDAR Data
5 Ways to Optimize Your LiDAR Data
Safe Software
Apple Machine Learning
Apple Machine Learning
Denise Nepraunig
Overcoming The Impedance Mismatch Between Source Code And Architecture
Overcoming The Impedance Mismatch Between Source Code And Architecture
Peter Friese
Mirko Lucchese - Deep Image Processing
Mirko Lucchese - Deep Image Processing
MeetupDataScienceRoma
Scala.IO 2024: Mill builds in Scala 3, a migration story
Scala.IO 2024: Mill builds in Scala 3, a migration story
James Thompson
Javascript Design Patterns
Javascript Design Patterns
Iv叩n Fern叩ndez Perea
Easy path to machine learning (Spring 2021)
Easy path to machine learning (Spring 2021)
wesley chun
Cloudera Data Science Challenge
Cloudera Data Science Challenge
Mark Nichols, P.E.
Data Science Challenge presentation given to the CinBITools Meetup Group
Data Science Challenge presentation given to the CinBITools Meetup Group
Doug Needham
From Zero to Hero Web Performance
From Zero to Hero Web Performance
Sebastian Springer
Django Good Practices
Django Good Practices
Solution4Future
Unsupervised Aspect Based Sentiment Analysis at Scale
Unsupervised Aspect Based Sentiment Analysis at Scale
Aaron (Ari) Bornstein
patternfinders-141205004957-conversion-gate02.pptx
patternfinders-141205004957-conversion-gate02.pptx
snnit
Easy path to machine learning
Easy path to machine learning
wesley chun
Analytics Zoo: Building Analytics and AI Pipeline for Apache Spark and BigDL ...
Analytics Zoo: Building Analytics and AI Pipeline for Apache Spark and BigDL ...
Databricks
Viktor Tsykunov: Azure Machine Learning Service
Viktor Tsykunov: Azure Machine Learning Service
Lviv Startup Club
Ember.js Tokyo event 2014/09/22 (English)
Ember.js Tokyo event 2014/09/22 (English)
Yuki Shimada
Gitter marionette deck
Gitter marionette deck
Mike Bartlett
Marker-based Augmented Monuments on iPhone and iPad
Marker-based Augmented Monuments on iPhone and iPad
Enrico Micco
Leaving Flatland: Getting Started with WebGL- SXSW 2012
Leaving Flatland: Getting Started with WebGL- SXSW 2012
philogb
5 Ways to Optimize Your LiDAR Data
5 Ways to Optimize Your LiDAR Data
Safe Software
Overcoming The Impedance Mismatch Between Source Code And Architecture
Overcoming The Impedance Mismatch Between Source Code And Architecture
Peter Friese
Mirko Lucchese - Deep Image Processing
Mirko Lucchese - Deep Image Processing
MeetupDataScienceRoma
Scala.IO 2024: Mill builds in Scala 3, a migration story
Scala.IO 2024: Mill builds in Scala 3, a migration story
James Thompson
Easy path to machine learning (Spring 2021)
Easy path to machine learning (Spring 2021)
wesley chun
Cloudera Data Science Challenge
Cloudera Data Science Challenge
Mark Nichols, P.E.
Data Science Challenge presentation given to the CinBITools Meetup Group
Data Science Challenge presentation given to the CinBITools Meetup Group
Doug Needham
From Zero to Hero Web Performance
From Zero to Hero Web Performance
Sebastian Springer

Recently uploaded (20)

FUNDAMENTALS OF COMPUTER ORGANIZATION AND ARCHITECTURE
FUNDAMENTALS OF COMPUTER ORGANIZATION AND ARCHITECTURE
Shabista Imam
Modern multi-proposer consensus implementations
Modern multi-proposer consensus implementations
Fran巽ois Garillot
Introduction to Python Programming Language
Introduction to Python Programming Language
merlinjohnsy
Deep Learning for Natural Language Processing_FDP on 16 June 2025 MITS.pptx
Deep Learning for Natural Language Processing_FDP on 16 June 2025 MITS.pptx
resming1
How Binning Affects LED Performance & Consistency.pdf
How Binning Affects LED Performance & Consistency.pdf
Mina Anis
Intro際際滷s-June-GDG-Cloud-Munich community gathering@Netlight.pdf
Intro際際滷s-June-GDG-Cloud-Munich community gathering@Netlight.pdf
Luiz Carneiro
special_edition_using_visual_foxpro_6.pdf
special_edition_using_visual_foxpro_6.pdf
Shabista Imam
IPL_Logic_Flow.pdf Mainframe IPLMainframe IPL
IPL_Logic_Flow.pdf Mainframe IPLMainframe IPL
KhadijaKhadijaAouadi
Tesla-Stock-Analysis-and-Forecast.pptx (1).pptx
Tesla-Stock-Analysis-and-Forecast.pptx (1).pptx
moonsony54
Cadastral Maps
Cadastral Maps
Google
A Cluster-Based Trusted Secure Multipath Routing Protocol for Mobile Ad Hoc N...
A Cluster-Based Trusted Secure Multipath Routing Protocol for Mobile Ad Hoc N...
IJCNCJournal
Industrial internet of things IOT Week-3.pptx
Industrial internet of things IOT Week-3.pptx
KNaveenKumarECE
AI_Presentation (1). Artificial intelligence
AI_Presentation (1). Artificial intelligence
RoselynKaur8thD34
NEW Strengthened Senior High School Gen Math.pptx
NEW Strengthened Senior High School Gen Math.pptx
DaryllWhere
60 Years and Beyond eBook 1234567891.pdf
60 Years and Beyond eBook 1234567891.pdf
waseemalazzeh
Fundamentals of Digital Design_Class_12th April.pptx
Fundamentals of Digital Design_Class_12th April.pptx
drdebarshi1993
Center Enamel can Provide Aluminum Dome Roofs for diesel tank.docx
Center Enamel can Provide Aluminum Dome Roofs for diesel tank.docx
CenterEnamel
Complete guidance book of Asp.Net Web API
Complete guidance book of Asp.Net Web API
Shabista Imam
Industry 4.o the fourth revolutionWeek-2.pptx
Industry 4.o the fourth revolutionWeek-2.pptx
KNaveenKumarECE
Fundamentals of Digital Design_Class_21st May - Copy.pptx
Fundamentals of Digital Design_Class_21st May - Copy.pptx
drdebarshi1993
FUNDAMENTALS OF COMPUTER ORGANIZATION AND ARCHITECTURE
FUNDAMENTALS OF COMPUTER ORGANIZATION AND ARCHITECTURE
Shabista Imam
Modern multi-proposer consensus implementations
Modern multi-proposer consensus implementations
Fran巽ois Garillot
Introduction to Python Programming Language
Introduction to Python Programming Language
merlinjohnsy
Deep Learning for Natural Language Processing_FDP on 16 June 2025 MITS.pptx
Deep Learning for Natural Language Processing_FDP on 16 June 2025 MITS.pptx
resming1
How Binning Affects LED Performance & Consistency.pdf
How Binning Affects LED Performance & Consistency.pdf
Mina Anis
Intro際際滷s-June-GDG-Cloud-Munich community gathering@Netlight.pdf
Intro際際滷s-June-GDG-Cloud-Munich community gathering@Netlight.pdf
Luiz Carneiro
special_edition_using_visual_foxpro_6.pdf
special_edition_using_visual_foxpro_6.pdf
Shabista Imam
IPL_Logic_Flow.pdf Mainframe IPLMainframe IPL
IPL_Logic_Flow.pdf Mainframe IPLMainframe IPL
KhadijaKhadijaAouadi
Tesla-Stock-Analysis-and-Forecast.pptx (1).pptx
Tesla-Stock-Analysis-and-Forecast.pptx (1).pptx
moonsony54
Cadastral Maps
Cadastral Maps
Google
A Cluster-Based Trusted Secure Multipath Routing Protocol for Mobile Ad Hoc N...
A Cluster-Based Trusted Secure Multipath Routing Protocol for Mobile Ad Hoc N...
IJCNCJournal
Industrial internet of things IOT Week-3.pptx
Industrial internet of things IOT Week-3.pptx
KNaveenKumarECE
AI_Presentation (1). Artificial intelligence
AI_Presentation (1). Artificial intelligence
RoselynKaur8thD34
NEW Strengthened Senior High School Gen Math.pptx
NEW Strengthened Senior High School Gen Math.pptx
DaryllWhere
60 Years and Beyond eBook 1234567891.pdf
60 Years and Beyond eBook 1234567891.pdf
waseemalazzeh
Fundamentals of Digital Design_Class_12th April.pptx
Fundamentals of Digital Design_Class_12th April.pptx
drdebarshi1993
Center Enamel can Provide Aluminum Dome Roofs for diesel tank.docx
Center Enamel can Provide Aluminum Dome Roofs for diesel tank.docx
CenterEnamel
Complete guidance book of Asp.Net Web API
Complete guidance book of Asp.Net Web API
Shabista Imam
Industry 4.o the fourth revolutionWeek-2.pptx
Industry 4.o the fourth revolutionWeek-2.pptx
KNaveenKumarECE
Fundamentals of Digital Design_Class_21st May - Copy.pptx
Fundamentals of Digital Design_Class_21st May - Copy.pptx
drdebarshi1993
Ad

Navigating the Apple ML Landscape

  • 1. Navigating the ! ML Landscape Meghan Kane, @meghafon developer @novoda, Berlin Swift & Fika, 9/2018
  • 4. ! before we pack our bags..
  • 5. why use machine learning .. at all?
  • 6. ML tasks detection: rectangles, face, barcode, text classi鍖cation: image, text, activity, column data style transfer image similarity object detection natural language processin regression
  • 8. Advantages of on device inference 1. user privacy 2. low latency user experience
  • 9. Let's start our road trip
  • 12. ML approach Label: "Border" 1. Detect game box (rectangle detection) 2. Classify Agricola piece within rectangle (image classi鍖cation)
  • 13. Capabilities ... built right into the Vision framework, no model training needed detection: rectangles, face, barcode, text object tracking image alignment
  • 14. How? 1. create handler 2. create task speci鍖c request 3. send request to handler 4. handle results
  • 15. // 1. Create handler let handler = VNImageRequestHandler(cgImage: image, orientation: orientation, options: [:])
  • 16. // 2. Create request let request = VNDetectRectanglesRequest(completionHandler: self.handleDetectedRectangles)
  • 17. // 3. Send request to handler do { try handler.perform([request]) } catch let error as NSError { // handle error return }
  • 18. // 4. Handle results func handleDetectedRectangles(request: VNRequest?, error: Error?) { if let results = request?.results as? [VNRectangleObservation] { // Do something with results [*bounding box coordinates*] } }
  • 19. ML approach Label: "Border" 1. Detect game box (rectangle detection) 2. Classify Agricola piece within rectangle (image classi鍖cation)
  • 20. Why restrict input image to the box? easier to train an accurate model faster to collect image data
  • 21. Capabilities In Xcode playground, train custom model for: image classi鍖cation text classi鍖cation classi鍖cation & regression of column data
  • 22. Collect Data Collect images representative of real world use cases Vary angle & lighting >10 images per label, but ideally more Equal # images for each label Recommended: >299x299 pixels
  • 23. Collecting Data Quickly // Extract .jpg frames from .mov @ 5 frames/sec ffmpeg -i stone.mov -r 5 data/stone/stone_%04d.jpg
  • 24. Prepare Data Split data: 80% train / 20% test
  • 28. what's happening behind the scenes?
  • 34. Capabilities perform predictions using model quantized weights (32 bit -> 16, 8, 4... bit) perform batch predictions create custom model layer
  • 35. Vision + Core ML 1. create Vision Core ML model 2. create handler 3. create task speci鍖c request 4. send request to handler 5. handle results
  • 36. // 1. Create Vision Core ML model let model = AgricolaPieceClassifier() guard let visionCoreMLModel = try? VNCoreMLModel(for: model.model) else { return }
  • 37. // 2. Create handler let handler = VNImageRequestHandler(cgImage: cgImage, orientation: cgImageOrientation)
  • 38. // 3. Create request let request = VNCoreMLRequest(model: visionCoreMLModel, completionHandler: self.handleClassificationResults)
  • 39. // 4. Send request to handler do { try handler.perform([request]) } catch let error as NSError { // handle error return }
  • 40. // 5. Handle results func handleClassificationResults(request: VNRequest?, error: Error?) { if let results = request?.results as? [VNClassificationObservation] { // Do something with results } }
  • 41. Problem solved Label: "Border" 1. Detect game box (rectangle detection) 2. Classify Agricola piece within rectangle (image classi鍖cation)
  • 44. Capabilities ...robust Python training framework style transfer activity classi鍖cation image similarity recommmendations object detection
  • 45. Setting up python virtualenv venv source venv/bin/activate pip install requests==2.18.4 turicreate==5.0b2 jupyter