SlideShare a Scribd company logo
1 of 87
Download to read offline
CORE ML
СТОИТ ЛИ?
Introduction
Kirill Averyanov !
Discussion
Vision
Pros
Cons
3
CoreML
Siri
new voice "
ARKit
WWDC Results
Machine Learning
ML INTRO
5
Training ModelTask
6
Task
Real Time Image Recognition
Text Prediction
Sentiment Analysis
Machine Translation
Face Detection
Emotion Detection
Personalization Search Prediction
Music Tagging
Natural Language Processing
Speaker Identification
Handwriting Recognition
Task
7
Task
ML INTRO
8
Training ModelTask
Training
9
Training
With
Teacher
Without
Teacher
Training
10
Training
Images + Labels
Learning
Algorithm
Model
With
Teacher
Training
11
Training
Images + Labels
Learning
Algorithm
Model
With
Teacher
64 pixels
+ 1 / 0
1 - hotdog
0 - not hotdog
Training
12
Training
With
Teacher
Without
Teacher
Training
13
Training
Without
Teacher
ML INTRO
14
Training ModelTask
Model
15
Model
Model OUTPUTINPUT
Classical Problems
16
• Classification
• Regression
• Cluster analysis
Classification
17
Square
Classical Problems
18
• Classification
• Regression
• Cluster analysis
Regression
19
a b c
aX1 + bX2 + c = y
Y - Возраст
X1 - Вес
X2 - Рост
Classical Problems
20
• Classification
• Regression
• Cluster analysis
Cluster Analysis
21
Cluster Analysis
22
Classification
Regression
Clustering
Ranking
Dimensionality reduction
Density estimation
Structure prediction
Anomaly
Novelty detection
Rule mining
Denoising
Data compression
Representation learning
Reinforcement learning
24
Your App
Vision Natural Language Processing GameplayKit
Core ML
Accelerate and BNNS Metal Performance Shaders
7 языков,
Я говорю на
русском!
52 языка
Для
определения
языка
CORE ML
CORE ML
26
Trained model on your device
CORE ML INTRO
27
let model = ModelName()
Model
32
Label: iPhone
Confidence: 90%
let model = Сlassifier()
If let prediction = try? model.prediction(image: image) {
return prediction.type
}
Model
33
Label: iPhone
Confidence: 90%
let model = Сlassifier()
If let prediction = try? model.prediction(image: image) {
return prediction.type
}
CORE ML INTRO
34
C
INPUT & OUTPUT
36
Numeric
Categories
Images
Arrays
Dictionaries
Double, Int64
String, Int64
CVPixelBuffer
MLMultiArray
[ String : Double ], [ Int64 : Double ]
37
Numeric
Categories
Images
Arrays
Dictionaries
Double, Int64
String, Int64
CVPixelBuffer
MLMultiArray
[ String : Double ], [ Int64 : Double ]
38
Numeric
Categories
Images
Arrays
Dictionaries
Double, Int64
String, Int64
CVPixelBuffer
MLMultiArray
[ String : Double ], [ Int64 : Double ]
39
Numeric
Categories
Images
Arrays
Dictionaries
Double, Int64
String, Int64
CVPixelBuffer
MLMultiArray
[ String : Double ], [ Int64 : Double ]
40
Numeric
Categories
Images
Arrays
Dictionaries
Double, Int64
String, Int64
CVPixelBuffer
MLMultiArray
[ String : Double ], [ Int64 : Double ]
41
42
CVPixelBuffer
44
func buffer(from image: UIImage) -> CVPixelBuffer? {
let attrs = [kCVPixelBufferCGImageCompatibilityKey: kCFBooleanTrue,
kCVPixelBufferCGBitmapContextCompatibilityKey: kCFBooleanTrue] as CFDictionary
var pixelBuffer: CVPixelBuffer?
let status = CVPixelBufferCreate(kCFAllocatorDefault, Int(image.size.width),
Int(image.size.height), kCVPixelFormatType_32ARGB,
attrs, &pixelBuffer)
guard status == kCVReturnSuccess else {
return nil
}
CVPixelBufferLockBaseAddress(pixelBuffer!, CVPixelBufferLockFlags(rawValue: 0))
let pixelData = CVPixelBufferGetBaseAddress(pixelBuffer!)
let rgbColorSpace = CGColorSpaceCreateDeviceRGB()
let context = CGContext(data: pixelData, width: Int(image.size.width),
height: Int(image.size.height), bitsPerComponent: 8,
bytesPerRow: CVPixelBufferGetBytesPerRow(pixelBuffer!),
space: rgbColorSpace, bitmapInfo: CGImageAlphaInfo.noneSkipFirst.rawValue)
context?.translateBy(x: 0, y: image.size.height)
context?.scaleBy(x: 1.0, y: -1.0)
UIGraphicsPushContext(context!)
image.draw(in: CGRect(x: 0, y: 0, width: image.size.width, height: image.size.height))
UIGraphicsPopContext()
CVPixelBufferUnlockBaseAddress(pixelBuffer!, CVPixelBufferLockFlags(rawValue: 0))
return pixelBuffer
}
Vision
46
47
48
Real Time
50
Feature
51
AVFoundation + Vision + Core ML
Feature
52
AVFoundation + Vision + Core ML
SUMMARY
53
C
Input
CVPixelBuffer
Vision
ML MODEL?
55
https://developer.apple.com/machine-learning/
56
Core ML Tools
58
Core ML Tools
59
Core ML Tools
Open Source v0.4
CORE ML TOOLS
Let’s try
61
VIRTUAL ENV
62
pip install virtualenv
virtualenv --python=/usr/bin/python2.7 python27
source python27/bin/activate
pip install -U coremltools
VIRTUAL ENV
63
pip install virtualenv
virtualenv --python=/usr/bin/python2.7 python27
source python27/bin/activate
pip install -U coremltools
VIRTUAL ENV
64
pip install virtualenv
virtualenv --python=/usr/bin/python2.7 python27
source python27/bin/activate
pip install -U coremltools
VIRTUAL ENV
65
pip install virtualenv
virtualenv --python=/usr/bin/python2.7 python27
source python27/bin/activate
pip install -U coremltools
VIRTUAL ENV
66
pip install virtualenv
virtualenv --python=/usr/bin/python2.7 python27
source python27/bin/activate
pip install -U coremltools
CONVERT
68
import coremltools

# Convert a caffe model to a classifier in Core ML

coreml_model = coremltools.converters.caffe.convert(('bvlc_alexnet.caffemodel', 

‘deploy.prototxt'), 

predicted_feature_name='class_labels.txt')

# Now save the model

coreml_model.save('BVLCObjectClassifier.mlmodel')
69
import coremltools

# Convert a caffe model to a classifier in Core ML

coreml_model = coremltools.converters.caffe.convert(('bvlc_alexnet.caffemodel', 

‘deploy.prototxt'), 

predicted_feature_name='class_labels.txt')

# Now save the model

coreml_model.save('BVLCObjectClassifier.mlmodel')
70
import coremltools

# Convert a caffe model to a classifier in Core ML

coreml_model = coremltools.converters.caffe.convert(('bvlc_alexnet.caffemodel', 

‘deploy.prototxt'), 

predicted_feature_name='class_labels.txt')

# Now save the model

coreml_model.save('BVLCObjectClassifier.mlmodel')
71
import coremltools

# Convert a caffe model to a classifier in Core ML

coreml_model = coremltools.converters.caffe.convert(('bvlc_alexnet.caffemodel', 

‘deploy.prototxt'), 

predicted_feature_name='class_labels.txt')

# Now save the model

coreml_model.save('BVLCObjectClassifier.mlmodel')
72
PROS
PROS
75
User Privacy Data Cost Server Cost
Always
Available
CONS
1 2 3
2 Types of ML
78
1
Regression & Classification
79
1
1 2 3
Training & Updating
81
2
1 2 3
Not Compressing
83
3
Results
Results
85
Small
Huge
TO READ
86
•https://developer.apple.com/videos/play/wwdc2017/703/
•https://developer.apple.com/videos/play/wwdc2017/703/
•https://developer.apple.com/videos/play/wwdc2017/208/
•https://developer.apple.com/videos/play/wwdc2017/506/
•https://developer.apple.com/documentation/coreml
•https://alexsosn.github.io/ml/2017/06/09/Core-ML-will-not-Work-for-Your-
App.htm
•https://medium.com/@s1ddok/holistically-nested-edge-detection-on-ios-
with-coreml-and-swift-e45df264cf66
https://machinelearning.apple.com
87
Thanks!
@kirillzzy

More Related Content

Similar to Core ML Speech

Tim Popl
Tim PoplTim Popl
Tim Popl
mchaar
 

Similar to Core ML Speech (20)

Learning Predictive Modeling with TSA and Kaggle
Learning Predictive Modeling with TSA and KaggleLearning Predictive Modeling with TSA and Kaggle
Learning Predictive Modeling with TSA and Kaggle
 
Introduction to Deep Learning
Introduction to Deep LearningIntroduction to Deep Learning
Introduction to Deep Learning
 
Flutter & ML KIt at Io extended 19 incheon
Flutter & ML KIt at Io extended 19 incheonFlutter & ML KIt at Io extended 19 incheon
Flutter & ML KIt at Io extended 19 incheon
 
Stupid Canvas Tricks
Stupid Canvas TricksStupid Canvas Tricks
Stupid Canvas Tricks
 
HTML5 game dev with three.js - HexGL
HTML5 game dev with three.js - HexGLHTML5 game dev with three.js - HexGL
HTML5 game dev with three.js - HexGL
 
Overview of graphics systems
Overview of  graphics systemsOverview of  graphics systems
Overview of graphics systems
 
Image style transfer & AI on App
Image style transfer & AI on AppImage style transfer & AI on App
Image style transfer & AI on App
 
Metaprogramming, Metaobject Protocols, Gradual Type Checks: Optimizing the "U...
Metaprogramming, Metaobject Protocols, Gradual Type Checks: Optimizing the "U...Metaprogramming, Metaobject Protocols, Gradual Type Checks: Optimizing the "U...
Metaprogramming, Metaobject Protocols, Gradual Type Checks: Optimizing the "U...
 
Building Native Apps- A Digital Canvas for Coders and Designers with Walter Luh
Building Native Apps- A Digital Canvas for Coders and Designers with Walter LuhBuilding Native Apps- A Digital Canvas for Coders and Designers with Walter Luh
Building Native Apps- A Digital Canvas for Coders and Designers with Walter Luh
 
DiscoGAN
DiscoGANDiscoGAN
DiscoGAN
 
Easy path to machine learning
Easy path to machine learningEasy path to machine learning
Easy path to machine learning
 
Information from pixels
Information from pixelsInformation from pixels
Information from pixels
 
Machine Learning for Web Developers
Machine Learning for Web DevelopersMachine Learning for Web Developers
Machine Learning for Web Developers
 
Anomalies in X-Ray Engine
Anomalies in X-Ray EngineAnomalies in X-Ray Engine
Anomalies in X-Ray Engine
 
The Next Mainstream Programming Language: A Game Developer’s Perspective
The Next Mainstream Programming Language: A Game Developer’s PerspectiveThe Next Mainstream Programming Language: A Game Developer’s Perspective
The Next Mainstream Programming Language: A Game Developer’s Perspective
 
Tim Popl
Tim PoplTim Popl
Tim Popl
 
The Ring programming language version 1.5.3 book - Part 58 of 184
The Ring programming language version 1.5.3 book - Part 58 of 184The Ring programming language version 1.5.3 book - Part 58 of 184
The Ring programming language version 1.5.3 book - Part 58 of 184
 
The Ring programming language version 1.5.3 book - Part 48 of 184
The Ring programming language version 1.5.3 book - Part 48 of 184The Ring programming language version 1.5.3 book - Part 48 of 184
The Ring programming language version 1.5.3 book - Part 48 of 184
 
Don't Call It a Comeback: Attribute Grammars for Big Data Visualization
Don't Call It a Comeback: Attribute Grammars for Big Data VisualizationDon't Call It a Comeback: Attribute Grammars for Big Data Visualization
Don't Call It a Comeback: Attribute Grammars for Big Data Visualization
 
WT-4065, Superconductor: GPU Web Programming for Big Data Visualization, by ...
WT-4065, Superconductor: GPU Web Programming for Big Data Visualization, by  ...WT-4065, Superconductor: GPU Web Programming for Big Data Visualization, by  ...
WT-4065, Superconductor: GPU Web Programming for Big Data Visualization, by ...
 

Recently uploaded

Obat Penggugur Kandungan Di Apotik Kimia Farma (087776558899)
Obat Penggugur Kandungan Di Apotik Kimia Farma (087776558899)Obat Penggugur Kandungan Di Apotik Kimia Farma (087776558899)
Obat Penggugur Kandungan Di Apotik Kimia Farma (087776558899)
Cara Menggugurkan Kandungan 087776558899
 

Recently uploaded (6)

Obat Penggugur Kandungan Di Apotik Kimia Farma (087776558899)
Obat Penggugur Kandungan Di Apotik Kimia Farma (087776558899)Obat Penggugur Kandungan Di Apotik Kimia Farma (087776558899)
Obat Penggugur Kandungan Di Apotik Kimia Farma (087776558899)
 
Android Application Components with Implementation & Examples
Android Application Components with Implementation & ExamplesAndroid Application Components with Implementation & Examples
Android Application Components with Implementation & Examples
 
Mobile App Penetration Testing Bsides312
Mobile App Penetration Testing Bsides312Mobile App Penetration Testing Bsides312
Mobile App Penetration Testing Bsides312
 
Satara Call girl escort *74796//13122* Call me punam call girls 24*7hour avai...
Satara Call girl escort *74796//13122* Call me punam call girls 24*7hour avai...Satara Call girl escort *74796//13122* Call me punam call girls 24*7hour avai...
Satara Call girl escort *74796//13122* Call me punam call girls 24*7hour avai...
 
Mobile Application Development-Components and Layouts
Mobile Application Development-Components and LayoutsMobile Application Development-Components and Layouts
Mobile Application Development-Components and Layouts
 
Mobile Application Development-Android and It’s Tools
Mobile Application Development-Android and It’s ToolsMobile Application Development-Android and It’s Tools
Mobile Application Development-Android and It’s Tools
 

Core ML Speech