There is a lot of Hype with ML and AI lately, and TensorFlow is the framework of choice from Google. But as a Mobile Developer you might have asked yourself, how can I benefit from it? In this talk, you will learn your first steps into the fascinating ML world for mobile.During this talk I will show how to set up TensorFlow for Android, and how to perform some initial operations with it:
- Classifying example
- Detection example
- Analyzing example
I will also show a model to develop a Mobile App with a Model and integration TensorFlow (from Zero to App), showcase demos in Android, iOS and Raspberry and showing as well some Real Use Cases.
19. TensorFlow Lite vs. TensorFlow Mobile
- TensorFlow Lite: smaller binary size, fewer dependencies, better
performance
- TensorFlow Lite: developer preview, not for production!
- TensorFlow Lite: supports limited set of operators, not all models will
work.
20. TensorFlow
You can train:
- Mac / Windows
- GPU Server
- GPU/TPU on Cloud
Prediction:
- Android
- iOS
- Raspberry
43. 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
44. 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
45. Building with Android Studio
Download Android SDK (23)
Download Android NDK (12b)
(recommend it with Android SDK Manager)
59. TensorFlow
Written in C++
Android uses Kotlin/Java?
HowTo?
Android inference Library
https://github.com/tensorflow/tensorflow/tree/master/tensorflow/contrib/android
60. 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)
48 layers
It is too much?To provide context: in 2011, a neural network with more than 4 layers deep.
If you try to put the model as it comes from the training into the Android platform it will not work, because there are certain operations not allowed in Android.
We need to strip the model. The output of a trained model is around 84 MB. This is a Whopper XXL.
We want to downsize and optimise it to Android.
Graph Transform Tool.
We quantize the model.
What this means? The model is a file filed with numbers. Floating point numbers with 32 bits and a high precision and high space requirement. We are going to downsize it to 8 bit.
Would not this affect the accuracy? Fair question. Neural Networks are designed to be tolerant of fuzzy inputs.
We can save 4x in space and have a marginal decay in accuracy.
If you develop for Android you write code in Kotlin or Java.
TensorFlow is written in C++
How do you call it?
If you develop for Android you write code in Kotlin or Java.
TensorFlow is written in C++
How do you call it?