Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Add Machine Learning to your iOS 11 App Using Core ML

Presented at Confoo 2018 (http://www.confoo.ca)

  • Be the first to comment

  • Be the first to like this

Add Machine Learning to your iOS 11 App Using Core ML

  1. 1. Add Machine Learning to your iOS 
 App with Core ML Jean-Luc David
 iOS Developer
  2. 2. My iOS Machine Learning App Circa 2012
  3. 3. OpenCV
  4. 4. Popular Perceptions
  5. 5. Popular Perceptions
  6. 6. Popular Perceptions
  7. 7. Nomenclature
  8. 8. Application of Machine Learning
  9. 9. Silicon Valley - Jian-Yang's Not Hotdog App
  10. 10. Fiction Becomes Reality
  11. 11. Types of Machine Learning
  12. 12. 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.
  13. 13. But I want to train models!
  14. 14. Runs On Device User Privacy Data Cost Server Cost Available
  15. 15. How Does a Model Work?
  16. 16. Machine Learning Model Types
  17. 17. Demo - Face Detection & Recognition
  18. 18. Types of Machine Learning Offline + Labels
  19. 19. Task - Find a Rose
  20. 20. Inference is Difficult
  21. 21. Inference is Difficult
  22. 22. Core ML Model • Single Document • Public Format • Reduced Size • Improved Accuracy • Decreased Prediction
 Time
  23. 23. Core ML Architecture • Unified Fine Tuned Inference Engine • Xcode Integration • Built on Accelerate and Metal • Public Model Format • Support for Popular Training Libraries
  24. 24. Core ML Model • Function learned from data • Observed inputs • Predicts outputs • Single Document • Public Format • Ready to Use • Task Specific
  25. 25. Sample Models https://developer.apple.com/machine-learning/
  26. 26. Converting to Core ML Core ML 
 Tools Open Source
  27. 27. 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
  28. 28. Demo - Converting a Model to MLModel
  29. 29. Xcode Integration
  30. 30. Swift ML Code Generates this code
  31. 31. Model as Code • Quick Initialization • Optimized Prediction Xcode Your App
  32. 32. Demo - FlowerClassifier
  33. 33. Resources • https://www.slideshare.net/jldavid • https://github.com/jldavid/FaceDetection • https://github.com/jldavid/FlowerClassifier
  34. 34. Thank You

×