Core ML in Depth. System Frameworks #WWDC17. Krishna Sridhar, Core ML Zach Nation, Core ML

Similar documents
Vision Framework. Building on Core ML. Media #WWDC17. Brett Keating, Apple Manager Frank Doepke, He who wires things together

What s New in Xcode App Signing

Introducing Password AutoFill for Apps

Using and Extending the Xcode Source Editor

What s New in watchos

Building Visually Rich User Experiences

Media and Gaming Accessibility

Introduction to Siri Shortcuts

Localizing with Xcode 9

Introducing Swift Playgrounds

Extending Your Apps with SiriKit

What s New in Swift Playgrounds

What s New in imessage Apps

What s New in Energy Debugging

Quick Interaction Techniques for watchos

Modern User Interaction on ios

Working with Metal Overview

Designing Great Apple Watch Experiences

Introducing On Demand Resources

Using Grouped Notifications

Data Delivery with Drag and Drop

What s New in Testing

imessage Apps and Stickers, Part 2

Enabling Your App for CarPlay

Integrating Apps and Content with AR Quick Look

Enhancing your apps for the next dimension of touch

Getting the Most out of Playgrounds in Xcode

Understanding Undefined Behavior

Seamless Linking to Your App

Mastering UIKit on tvos

Why data science is the new frontier in software development

Advances in TVMLKit. App Frameworks #WWDC17. Trevor Cortez, Localization Engineer Parry Panesar, tvos Engineer Jeremy Foo, tvos Engineer

Building Apps with Dynamic Type

What s New in Core Data?

Mastering Drag and Drop

Natural Language Processing and your Apps

Touch Bar Fundamentals

Neural Network Exchange Format

Creating Photo and Video Effects Using Depth

What s New in Device Configuration, Deployment, and Management

Automatic Strong Passwords and Security Code AutoFill

What s New in Notifications

Accessibility on ios. Developing for everyone. Frameworks #WWDC14. Session 210 Clare Kasemset ios Accessibility

Building Watch Apps #WWDC15. Featured. Session 108. Neil Desai watchos Engineer

Building Faster in Xcode

What s New in MapKit. App Frameworks #WWDC17. Fredrik Olsson

Monetize and Promote Your App with iad

Building for Voice with Siri Shortcuts

Using Accelerate and simd

Implementing UI Designs in Interface Builder

Optimizing Swift Performance Session 409

Leveraging Touch Input on ios

What s New in tvos #WWDC16. App Frameworks. Session 206. Hans Kim tvos Engineer

Apple Watch Design Tips and Tricks

Metal for Ray Tracing Acceleration

New UIKit Support for International User Interfaces

Writing Energy Efficient Apps

What s New in CloudKit

ios Accessibility Developing for everyone Session 201 Ian Fisch ios Accessibility

What s New in tvos 12

Advanced Scrollviews and Touch Handling Techniques

Getting to Know Swift Package Manager

Introducing MusicKit. Media #WWDC17. Tim Parthemore, MusicKit Services Joel Lopes Da Silva, ios Music

Localization Best Practices on tvos

SceneKit: What s New Session 604

What s New in ARKit 2

Your Apps and the Future of macos Security

Introducing Metal 2. Graphics and Games #WWDC17. Michal Valient, GPU Software Engineer Richard Schreyer, GPU Software Engineer

Shrinath Shanbhag Senior Software Engineer Microsoft Corporation

A Deep Learning primer

Deep Learning Frameworks. COSC 7336: Advanced Natural Language Processing Fall 2017

HLS Authoring Update. Media #WWDC17. Eryk Vershen, AVFoundation Engineer

Engineering for Testability

NVIDIA DLI HANDS-ON TRAINING COURSE CATALOG

Adapting to the New UI of OS X Yosemite

Machine Learning in WAN Research

Finding Bugs Using Xcode Runtime Tools

Machine Learning in WAN Research

Mysteries of Auto Layout, Part 1

Code Mania Artificial Intelligence: a. Module - 1: Introduction to Artificial intelligence and Python:

Caffe2C: A Framework for Easy Implementation of CNN-based Mobile Applications

Neural Nets & Deep Learning

NVIDIA GPU CLOUD DEEP LEARNING FRAMEWORKS

Real Time Monitoring of CCTV Camera Images Using Object Detectors and Scene Classification for Retail and Surveillance Applications

Introducing the Modern WebKit API

What s New in Metal, Part 2

Vinnie Saini Cloud Solution Architect Big Data & AI

DECISION SUPPORT SYSTEM USING TENSOR FLOW

Improving the Accessibility and Usability of Complex Web Applications

Inference Optimization Using TensorRT with Use Cases. Jack Han / 한재근 Solutions Architect NVIDIA

How to Build Optimized ML Applications with Arm Software

Getting Published in Apple News

Designing for Apple Watch

Creating Complications with ClockKit Session 209

Managing Documents In Your ios Apps

What s New in Audio. Media #WWDC17. Akshatha Nagesh, AudioEngine-eer Béla Balázs, Audio Artisan Torrey Holbrook Walker, Audio/MIDI Black Ops

Beyond Training The next steps of Machine Learning. Chris /in/chrisparsonsdev

WatchKit In-Depth, Part 2

How GPUs Power Comcast's X1 Voice Remote and Smart Video Analytics. Jan Neumann Comcast Labs DC May 10th, 2017

Deep Learning: Transforming Engineering and Science The MathWorks, Inc.

Transcription:

System Frameworks #WWDC17 Core ML in Depth Krishna Sridhar, Core ML Zach Nation, Core ML 2017 Apple Inc. All rights reserved. Redistribution or public display not permitted without written permission from Apple.

The easiest way to integrate machine learning models into your app.

The easiest way to integrate machine learning models into your app.

The easiest way to integrate machine learning models into your app.

The easiest way to integrate machine learning models into your app.

The easiest way to integrate machine learning models into your app.

Think of models as code

Development Flow

Development Flow Xcode

Development Flow Xcode

Development Flow Xcode Your App

Development Flow Xcode Your App

Rose Confidence 95%

Rose Confidence 95% let model = FlowerClassifier() if let prediction = try? model.prediction(image: image) { return prediction.flowertype }

Rose Confidence 95% let model = FlowerClassifier() if let prediction = try? model.prediction(image: image) { return prediction.flowertype }

This Session Use Cases

This Session Use Cases Hardware Optimized Core ML Accelerate CPU MPS GPU

This Session Use Cases Hardware Optimized Obtaining Models Core ML Accelerate CPU MPS GPU

This Session Use Cases Hardware Optimized Obtaining Models Core ML Accelerate CPU MPS GPU

Sentiment Analysis Object Detection Personalization Style Transfer Music Tagging Gesture Recognition Summarization

Sentiment Analysis Object Detection Personalization Style Transfer Music Tagging Gesture Recognition Summarization

Sentiment Analysis Object Detection Personalization Style Transfer Music Tagging Gesture Recognition Summarization

Sentiment Analysis Object Detection Personalization Style Transfer Music Tagging Gesture Recognition Summarization

Sentiment Analysis Object Detection Personalization Style Transfer Music Tagging Gesture Recognition Summarization Generalized Linear Models Tree Ensembles Support Vector Machines Feedforward Neural Networks Convolution Neural Networks Recurrent Neural Networks

Feedforward Neural Networks Convolution Neural Networks Recurrent Neural Networks

Pipeline Vectorize Neural Network Map to String Rose

Sentiment Analysis Object Detection Personalization Style Transfer Music Tagging Gesture Recognition Summarization Focus on code, not models!

Models as Functions Numeric Categories Images Rose Arrays Dictionaries

Numeric and Categories developer.apple.com/machine-learning Numeric Categories Images Arrays Dictionaries Double, Int64 String, Int64 CVPixelBuffer MLMultiArray [String : Double], [Int64 : Double]

Images Numeric Categories Images Arrays Dictionaries Double, Int64 String, Int64 CVPixelBuffer MLMultiArray [String : Double], [Int64 : Double]

Multi-Dimensional Arrays Numeric Categories Images Arrays Dictionaries Double, Int64 String, Int64 CVPixelBuffer MLMultiArray [String : Double], [Int64 : Double]

Dictionaries Numeric Categories Images Arrays Dictionaries Double, Int64 String, Int64 CVPixelBuffer MLMultiArray [String : Double], [Int64 : Double]

Working with Text

CoreML is awesome. I love using it

Today s lunch was terrible and disappointing

Sentiment Analysis Application

Sentiment Analysis Application

Sentiment Analysis Application!!!

Sentiment Analysis Application!!!

Using Other Formats Word Counts { } "Core" : 1, "ML" : 1, "is" : 1, "awesome" : 1, "I" : 1, "love" : 1, "using" : 1, "it" : 1,

Using Other Formats Word Counts { } "Core" : 1, "ML" : 1, "is" : 1, "awesome" : 1, "I" : 1, "love" : 1, "using" : 1, "it" : 1,

Using Other Formats Word Counts { } "Core" : 1, "ML" : 1, "is" : 1, "awesome" : 1, "I" : 1, "love" : 1, "using" : 1, "it" : 1,!

Use NLP to Process Text Word Counts { } "Core" : 1, "ML" : 1, "is" : 1, "awesome" : 1, "I" : 1, "love" : 1, "using" : 1, "it" : 1,

Sentiment Analysis Application { } "Core" : 1, "ML" : 1, "is" : 1, "awesome" : 1, "I" : 1, "love" : 1, "using" : 1, "it" : 1,! Use NLP (NSLinguisticTagger) Use Core ML

Processing Text { } "Core" : 1, "ML" : 1, "is" : 1, "awesome" : 1, "I" : 1, "love" : 1, "using" : 1, "it" : 1, func tokenizeandcountwords(rawtxt: String) -> [String : Double] { // Tokenize using NSLinguisticTagger... } // Count occurrences of each token

Making Predictions { } "Core" : 1, "ML" : 1, "is" : 1, "awesome" : 1, "I" : 1, "love" : 1, "using" : 1, "it" : 1,! let model = SentimentAnalysis() if let prediction = try? model.prediction(wordcounts: counts) { print("sentiment: \(prediction.sentiment)") }

Text Gotchas! Most models don t work directly on raw text

Predictive Keyboard I m not sure Oliver will eat oysters, Love but he will

Predictive Keyboard I m not sure Oliver will eat oysters, Love but he will Task - Next word prediction

Language Models

Shakespeare Keyboard

Shakespeare Keyboard Current Word

Shakespeare Keyboard Current Word Next Word Choices State

Shakespeare Keyboard Next Word Current Word Next Word Choices State

Shakespeare Keyboard Next Word Current Word Next Word Choices State

Shakespeare Keyboard Next Word Current Word Next Word Choices State State

Sample Code if let output = try? model.prediction(input: input) { } // Send the best 3 words to the user displaytoppredictions(output.nextwordprob) // Update state for next prediction input.state = output.state input.currentword = getnextwordfromuser()

Sample Code if let output = try? model.prediction(input: input) { } // Send the best 3 words to the user displaytoppredictions(output.nextwordprob) // Update state for next prediction input.state = output.state input.currentword = getnextwordfromuser()

Sample Code if let output = try? model.prediction(input: input) { } // Send the best 3 words to the user displaytoppredictions(output.nextwordprob) // Update state for next prediction input.state = output.state input.currentword = getnextwordfromuser()

Sample Code if let output = try? model.prediction(input: input) { } // Send the best 3 words to the user displaytoppredictions(output.nextwordprob) // Update state for next prediction input.state = output.state input.currentword = getnextwordfromuser()

Come to the Labs Thursday 11:00 3:30 Friday 1:30 4:00

This Session Use Cases Hardware Optimized Obtaining Models Core ML Accelerate CPU MPS GPU

Built on Performance Primitives Your app Vision NLP Core ML ML Performance Primitives Accelerate MPS Hardware CPU GPU

Optimized for Hardware Runs on GPU MPS

Optimized for Hardware Runs on GPU Runs on CPU MPS Accelerate

Optimized for Hardware

Optimized for Hardware Runs on Core ML

Context Switching Runs on GPU Runs on CPU Dog playing in a soccer field

This Session Use Cases Hardware Optimized Obtaining Models Core ML Accelerate CPU MPS GPU

Deploying Core ML Models Xcode Your App

Deploying Core ML Models Xcode Your App Where do models come from?

Example Models Task specific Core ML models developer.apple.com/machine-learning

Tap into ML Community Popular ML libraries Many models Thriving communities

Tap into ML Community Popular ML libraries Many models Thriving communities

Core ML Tools

Core ML Tools Open Source

Conversion Workflow Xcode Your App

Conversion Workflow Model Source Xcode Your App e.g. Caffe

Conversion Workflow Model Source Xcode Your App e.g. Caffe

Getting Started ## Download and install python package > pip install coremltools

What Is coremltools? Converters Convert from other formats Core ML Bindings Converter Library Core ML Specification

What Is coremltools? Converters Convert from other formats Core ML Bindings Converter Library Build your own converter Core ML Specification

What Is coremltools? Converters Convert from other formats Core ML Bindings Converter Library Build your own converter Core ML Specification Write your own models

Compatible and Extensible Converters Compatible Core ML Bindings Converter Library Core ML Specification

Compatible and Extensible Converters Core ML Bindings Converter Library Core ML Specification Extensible

Core ML Model developer.apple.com/machine-learning Single document Converters Encapsulates Core ML Bindings Converter Library Functional description (inputs Trained parameters outputs) Core ML Specification Public format

Xcode Model View

Xcode Model View

Core ML Converters Model Source In Xcode Converters Core ML Bindings Converter Library Convert Core ML Specification e.g. Caffe Unified APIs to convert models from various formats to Core ML

Flower Classification in Caffe 74.caffemodel.prototxt

Flower Classification in Caffe 74 Rose.caffemodel.prototxt labels.txt

Flower Classification in Caffe 74 Rose.caffemodel.prototxt labels.txt Needed for conversion to Core ML format

Demo

Demo Summary import coremltools caffe_model = ('flowers.caffemodel','flowers.prototxt') model = coremltools.converters.caffe.convert( caffe_model, image_input_names = 'data', class_labels = 'labels.txt') model.save('flowerclassifier.mlmodel')

Demo Summary import coremltools keras_model = 'flowers.h5' model = coremltools.converters.keras.convert( keras_model, image_input_names = 'data', class_labels = 'labels.txt') model.save('flowerclassifier.mlmodel')

Supported Packages Neural Networks Pipelines Tree Ensembles Linear Models Support Vector Machines

Obtaining Models Summary Convert developer.apple.com/machine-learning

Summary

Summary Easy integration of ML models

Summary Easy integration of ML models Rich datatype support

Summary Easy integration of ML models Rich datatype support Hardware optimized

Summary Easy integration of ML models Rich datatype support Hardware optimized Compatible with popular formats

More Information https://developer.apple.com/wwdc17/710

Related Sessions Introducing Core ML WWDC 2017 Vision Framework: Building on Core ML WWDC 2017 Natural Language Processing and your Apps WWDC 2017 Accelerate and Sparse Solvers Grand Ballroom A Thursday 10:00AM Using Metal 2 for Compute Grand Ballroom A Thursday 4:10PM

Labs Core ML and Natural Language Processing Lab Technology Lab D Thu 11:00AM-3:30PM Core ML and Natural Language Processing Lab Technology Lab D Fri 1:50PM-4:00PM