$30 off During Our Annual Pro Sale. View Details »

TensorFlow for Mobile Developers

TensorFlow for Mobile Developers

TensorFlow for Mobile Developers @ DroidKaigi

Enrique López Mañas

February 22, 2018

More Decks by Enrique López Mañas

Other Decks in Programming


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

  2. Ego Slide • Freelance Dev • Google Developer Expert •

  3. Machine Learning / AI

  4. Machine Learning / AI

  5. Machine Learning / AI

  6. 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
  7. Buzzwords classification

  8. Neural Network

  9. Machine Learning

  10. Machine Learning

  11. Machine Learning 12% of all responses on mobile

  12. Machine Learning

  13. Machine Learning

  14. Machine Learning

  15. Cloud vs. Mobile Less Traffic & Faster Response Motion Sensors

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

    ML framework
  17. TensorFlow You can train: - Mac / Windows - GPU

    Server - GPU/TPU on Cloud Prediction: - Android - iOS - Raspberry
  18. TensorFlow CIFAR10

  19. TensorFlow ecosystem

  20. From Training to App (@yufengg)

  21. Data Gathering?

  22. From Training to App (@yufengg)

  23. From Training to App (@yufengg)

  24. Convolutional Neural Networks (@yufengg)

  25. Convolutional Neural Networks (@yufengg)

  26. Convolutional Neural Networks (@yufengg)

  27. Convolutional Neural Networks (@yufengg)

  28. Convolutional Neural Networks (@yufengg)

  29. Convolutional Neural Networks (@yufengg)

  30. Convolutional Neural Networks (@yufengg)

  31. Convolutional Neural Networks (@yufengg)

  32. From Training to App (@yufengg)

  33. Optimizing model for Mobile (@yufengg)

  34. From Training to App (@yufengg) Other inception versions (inception v1

    quantised is 7 MB)
  35. From Training to App (@yufengg) TensorFlow increases APK in 12

  36. From Training to App (@yufengg)

  37. From Training to App (@yufengg)

  38. TensorFlow community 1000+ contributors 22.000+ commits 18.000+ repositories with name

  39. TensorFlow community

  40. 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
  41. 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
  42. Building with Android Studio Download Android SDK (23) Download Android

    NDK (12b)
 (recommend it with Android SDK Manager)
  43. Building with Android Studio WORKSPACE FILE

  44. Building with Android Studio Run Bazel bazel build -c opt

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

  46. Building with Android Studio OR… TensorFlow AAR from JCenter YUV

    -> RGB less efficient Object tracking not available
  47. Android Samples TF Classify 
 TF Detect
 TF Stylize

  48. TF Classify Uses Google Inception (v3) to label images Model

    easy to swap No “person label” Volume button up for statistics
  49. TF Classify

  50. TF Classify

  51. TF Detect

  52. TF Detect - Draw bounding boxes around people - Useful

    to count objects - No training yet
  53. TF Style

  54. TF Style - Real time style transfer algorithm - Pick/mix

    different styles - Can train Magenta models
  55. TF Style

  56. TensorFlow Written in C++ Android uses Kotlin/Java?
 HowTo? Android

    inference Library https://github.com/tensorflow/tensorflow/tree/master/tensorflow/contrib/android
  57. 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)
  58. iOS Examples: simple

  59. iOS Examples: camera

  60. iOS Examples: camera - Run inception each frame - Models

    can be replaced
  61. iOS Examples: benchmark

  62. Raspberry Pi

  63. 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

  64. Shameless self-promotion www.kotlinweekly.net

  65. Feedback! http://bit.ly/droidkaigi

  66. None