Slide 1

Slide 1 text

TensorFlow for Mobile Developers Enrique López Mañas Google Developer Expert

Slide 2

Slide 2 text

Ego Slide • Freelance Dev • Google Developer Expert • @eenriquelopez

Slide 3

Slide 3 text

Machine Learning / AI

Slide 4

Slide 4 text

Machine Learning / AI

Slide 5

Slide 5 text

Machine Learning / AI

Slide 6

Slide 6 text

Buzzwords classification Artificial intelligence Machine Learning The science of making machines smarts Building machines that can learn Neural Networks One of the many different algorithms in Machine Learning

Slide 7

Slide 7 text

Buzzwords classification

Slide 8

Slide 8 text

Neural Network

Slide 9

Slide 9 text

Machine Learning

Slide 10

Slide 10 text

Machine Learning

Slide 11

Slide 11 text

Machine Learning 12% of all responses on mobile

Slide 12

Slide 12 text

Machine Learning

Slide 13

Slide 13 text

Machine Learning

Slide 14

Slide 14 text

Machine Learning

Slide 15

Slide 15 text

Cloud vs. Mobile Less Traffic & Faster Response Motion Sensors

Slide 16

Slide 16 text

TensorFlow OpenSource library for Machine Learning tensorflow.org Today most popular ML framework

Slide 17

Slide 17 text

TensorFlow You can train: - Mac / Windows - GPU Server - GPU/TPU on Cloud Prediction: - Android - iOS - Raspberry

Slide 18

Slide 18 text

TensorFlow CIFAR10

Slide 19

Slide 19 text

TensorFlow ecosystem

Slide 20

Slide 20 text

From Training to App (@yufengg)

Slide 21

Slide 21 text

Data Gathering?

Slide 22

Slide 22 text

From Training to App (@yufengg)

Slide 23

Slide 23 text

From Training to App (@yufengg)

Slide 24

Slide 24 text

Convolutional Neural Networks (@yufengg)

Slide 25

Slide 25 text

Convolutional Neural Networks (@yufengg)

Slide 26

Slide 26 text

Convolutional Neural Networks (@yufengg)

Slide 27

Slide 27 text

Convolutional Neural Networks (@yufengg)

Slide 28

Slide 28 text

Convolutional Neural Networks (@yufengg)

Slide 29

Slide 29 text

Convolutional Neural Networks (@yufengg)

Slide 30

Slide 30 text

Convolutional Neural Networks (@yufengg)

Slide 31

Slide 31 text

Convolutional Neural Networks (@yufengg)

Slide 32

Slide 32 text

From Training to App (@yufengg)

Slide 33

Slide 33 text

Optimizing model for Mobile (@yufengg)

Slide 34

Slide 34 text

From Training to App (@yufengg) Other inception versions (inception v1 quantised is 7 MB)

Slide 35

Slide 35 text

From Training to App (@yufengg) TensorFlow increases APK in 12 MB

Slide 36

Slide 36 text

From Training to App (@yufengg)

Slide 37

Slide 37 text

From Training to App (@yufengg)

Slide 38

Slide 38 text

TensorFlow community 1000+ contributors 22.000+ commits 18.000+ repositories with name “TensorFlow”

Slide 39

Slide 39 text

TensorFlow community

Slide 40

Slide 40 text

Building with Android Studio Uses Bazel to build Set Bazel binary location in /tensorflow/examples/ android/build.gradle Add project in tensorflor/examples/android folder to Android Studio

Slide 41

Slide 41 text

Building with Android Studio Installing Bazel first: Download from https://github.com/bazelbuild/bazel/releases Install instructions in https://docs.bazel.build/versions/master/install.html

Slide 42

Slide 42 text

Building with Android Studio Download Android SDK (23) Download Android NDK (12b)
 
 (recommend it with Android SDK Manager)

Slide 43

Slide 43 text

Building with Android Studio WORKSPACE FILE

Slide 44

Slide 44 text

Building with Android Studio Run Bazel bazel build -c opt //tensorflow/examples/ android:tensorflow_demo

Slide 45

Slide 45 text

Building with Android Studio Install APK adb install -r bazel-bin/tensorflow/examples/android/ tensorflow_demo.apk

Slide 46

Slide 46 text

Building with Android Studio OR… TensorFlow AAR from JCenter YUV -> RGB less efficient Object tracking not available

Slide 47

Slide 47 text

Android Samples TF Classify 
 TF Detect
 
 TF Stylize

Slide 48

Slide 48 text

TF Classify Uses Google Inception (v3) to label images Model easy to swap No “person label” Volume button up for statistics

Slide 49

Slide 49 text

TF Classify

Slide 50

Slide 50 text

TF Classify

Slide 51

Slide 51 text

TF Detect

Slide 52

Slide 52 text

TF Detect - Draw bounding boxes around people - Useful to count objects - No training yet

Slide 53

Slide 53 text

TF Style

Slide 54

Slide 54 text

TF Style - Real time style transfer algorithm - Pick/mix different styles - Can train Magenta models

Slide 55

Slide 55 text

TF Style

Slide 56

Slide 56 text

TensorFlow Written in C++ Android uses Kotlin/Java?
 
 HowTo? Android inference Library https://github.com/tensorflow/tensorflow/tree/master/tensorflow/contrib/android

Slide 57

Slide 57 text

Building for iOS Install requirements: - Xcode 8 - Command line tools (xcode-select install) - brew install automake - brew install lib tool - tensorflow/contrib/makefile_build_all_ios.sh (takes 20 minutes)

Slide 58

Slide 58 text

iOS Examples: simple

Slide 59

Slide 59 text

iOS Examples: camera

Slide 60

Slide 60 text

iOS Examples: camera - Run inception each frame - Models can be replaced

Slide 61

Slide 61 text

iOS Examples: benchmark

Slide 62

Slide 62 text

Raspberry Pi

Slide 63

Slide 63 text

Resources TensorFlow: https://www.tensorflow.org/ Magenta: https://magenta.tensorflow.org/welcome-to-magenta TensorFlow for Poets: https://codelabs.developers.google.com/codelabs/ tensorflow-for-poets/index.html#0

Slide 64

Slide 64 text

Shameless self-promotion www.kotlinweekly.net

Slide 65

Slide 65 text

Feedback! http://bit.ly/droidkaigi

Slide 66

Slide 66 text

No content