On-device machine learning: TensorFlow on Android

35
@YufengG On-device machine learning: TensorFlow on Android Yufeng Guo Developer Advocate @YufengG yufengg.com

Transcript of On-device machine learning: TensorFlow on Android

@YufengG

On-device machine learning: TensorFlow on Android

Yufeng GuoDeveloper [email protected]

@YufengG

We now live in an AI-first world

@YufengG

Over half of the companies on the Fortune 500 have disappeared since 2000Source: World economic forum

@YufengG

Train on the server

Predict on mobile

@YufengG@YufengG

@YufengG@YufengG

@YufengG

How can I make that?ML is hard...

@YufengG

@YufengG

Demo: custom image recognitionLet's make an Android app

@YufengG

@YufengG

@YufengG

From training to app

Gather training data

Load into Android app

? ? ?

??

@YufengG

VideoCapture video of what you want to classify

@YufengG

From training to app

Gather training data

Load into Android app

?

??

Convert to imagesFolders of images

@YufengG

Split the video up into pictures for training

Pictures

@YufengG

From training to app

Gather training data

Load into Android app

?

Convert to imagesFolders of images

StorageCloud Storage

Object storage with global edge-caching

TrainingCloud ML Engine

Fast, scalable, and easy-to-use ML services

@YufengG

Sidebar: Convolutional neural networks

@YufengG@YufengG

@YufengG

@YufengG

@YufengG

@YufengG

@YufengG

@YufengG

@YufengG

Training the InceptionV3 model

Use the pictures to retrain the InceptionV3 model

@YufengG

From training to app

Gather training data

Load into Android app

Convert to imagesFolders of images

StorageCloud Storage

Object storage with global edge-caching

TrainingCloud ML Engine

Fast, scalable, and easy-to-use ML services

Optimize for mobile

@YufengG

Downsizing with the graph transform tool

@YufengG

One more thing...

App

Model

App

Model

@YufengG

From training to app

Gather training data Convert to images

TrainingCloud ML Engine

Fast, scalable, and easy-to-use ML services

StorageCloud Storage

Object storage with global edge-caching

Folders of images

Optimize for mobile

Load into Android app

@YufengG

Load into Android app

Add the model into your app and ship it!

@YufengG

What makes all of this possible?

@YufengG

Supported platforms

Raspberry PiAndroid iOS

TPU

GPUCPU

@YufengG

Community

● 475+ non-Google contributors to TensorFlow 1.0● 14,000+ commits in 14 months● Many community created tutorials, models,

translations, and projects○ ~5,500 GitHub repositories with ‘TensorFlow’

in the title

@YufengG

Machine learning on mobile — awesomeness

@YufengG

From training to app

Gather training data Convert to images

TrainingCloud ML Engine

Fast, scalable, and easy-to-use ML services

StorageCloud Storage

Object storage with global edge-caching

Folders of images

Optimize for mobile

Load into Android app

@YufengG

Codelab to retrain your own InceptionV3 networkbit.ly/tf-retrain

Mobile Tensorflowtensorflow.org/mobile

Cloud Machine Learning Enginecloud.google.com/ml

Thank you!

Yufeng GuoDeveloper Advocate

yufengg.com

@YufengG

Mobile machine learning, now with extra fast

Just-In-Time Compilationvia XLA, "Accelerated Linear Algebra" compiler

0x00000000 movq (%rdx), %rax0x00000003 vmovaps (%rax), %xmm00x00000007 vmulps %xmm0, %xmm0, %xmm00x0000000b vmovaps %xmm0, (%rdi)

...

TF graphs go in

Optimized & specialized assembly comes out.