Slide 1

Slide 1 text

移動裝置上的
 機器學習應⽤用 Elvis Lin @KKday 2018-07-19

Slide 2

Slide 2 text

⼤大綱 • 什什麼是(我理理解的)機器學習 • 移動裝置上實作機器學習應⽤用的限制 • TensorFlow Lite 與 ML Kit

Slide 3

Slide 3 text

機器學習的應⽤用

Slide 4

Slide 4 text

機器學習 • 從資料中歸納出有⽤用的規則 • 訓練模型 • 使⽤用模型 • Mobile Application Engineer 參參與開發主要是在「使⽤用模型」 這個範圍

Slide 5

Slide 5 text

Data Result (Trained)
 Model

Slide 6

Slide 6 text

移動裝置上
 實作機器學習應⽤用的限制 • 記憶體有限與儲存空間有限 • 計算能⼒力力不如⼤大型伺服器 • 電池容量量有限

Slide 7

Slide 7 text

移動裝置上
 實作機器學習應⽤用的改良⽅方向 • 記憶體有限與儲存空間有限 —> 減少模型(Model)的體積 • 計算能⼒力力不如⼤大型伺服器 —> 降低演算法的複雜度 • 電池容量量有限 —> 降低演算法的複雜度

Slide 8

Slide 8 text

Google 推出的解決⽅方案 • TensorFlow Lite • ML Kit

Slide 9

Slide 9 text

Tensorflow Lite https://youtu.be/ByJnpbDd-zc

Slide 10

Slide 10 text

https://www.tensorflow.org/mobile/tflite/

Slide 11

Slide 11 text

轉換 Tensorflow 檔案的⼯工具 • Tensorflow converter • 轉成 Tensorflow Lite 格式
 • Tensorflow-CoreML converter • 轉成 CoreML 格式 • https://github.com/tf-coreml/tf-coreml

Slide 12

Slide 12 text

ML Kit https://youtu.be/Z-dqGRSsaBs

Slide 13

Slide 13 text

Neural Networks API Metal

Slide 14

Slide 14 text

ML Kit • Cloud Vision API / Mobile Vision API • Tensorflow Lite • 整合 Firebase,託管「客製化的模型」

Slide 15

Slide 15 text

ML Kit Base APIs • Image labeling • Text recognition (OCR) • Face detection • Barcode scanning • Landmark detection • others……

Slide 16

Slide 16 text

圖片內容標注 On-device Cloud Pricing Free Free for first 1000 uses of this feature per month Label coverage 400+ labels that cover the most commonly- found concepts in photos. 10,000+ labels in many categories

Slide 17

Slide 17 text

辨識⽂文字 On-device Cloud Pricing Free Free for first 1000 uses of this feature per month Ideal use cases Real-time processing —ideal for a camera or video feed High-accuracy text recognition Language support Recognizes Latin characters Recognizes and identifies a broad range of languages and special characters

Slide 18

Slide 18 text

⽀支援的 barcode 格式 • Code 128 (FORMAT_CODE_128) • Code 39 (FORMAT_CODE_39) • Code 93 (FORMAT_CODE_93) • Codabar (FORMAT_CODABAR) • EAN-13 (FORMAT_EAN_13) • EAN-8 (FORMAT_EAN_8) • ITF (FORMAT_ITF) • UPC-A (FORMAT_UPC_A) • UPC-E (FORMAT_UPC_E) •QR Code (FORMAT_QR_CODE) • PDF417 (FORMAT_PDF417) • Aztec (FORMAT_AZTEC) • Data Matrix (FORMAT_DATA_MATRIX)

Slide 19

Slide 19 text

託管客製化的模型 ⽬目前只⽀支援 Tensorflow Lite 格式

Slide 20

Slide 20 text

使⽤用 ML Kit

Slide 21

Slide 21 text

建立⼀一個 Firebase 專案

Slide 22

Slide 22 text

建立⼀一個 Android app
 然後下載設定檔 設定好 Package Name 下載 google-service.json

Slide 23

Slide 23 text

建立⼀一個 iOS app
 然後下載設定檔 設定好 Bundle ID 下載 GoogleService-info.plist

Slide 24

Slide 24 text

程式碼範例例 • ML Kit 簡介 (for Android)
 https://blog.elvismetaphor.me/ml-kit-fundamentals-for- android-6444e2db0fdb • ML Kit 簡介 (for iOS)
 https://blog.elvismetaphor.me/ml-kit-fundamentals-for- ios-cb705044e69b • 不論是使⽤用本機端或雲端的 API,提供類似的程式碼編寫⽅方 式

Slide 25

Slide 25 text

在其他 Framework 上的⽀支援程度 • React Native • 預計在 RNFirebase v5.x.x 的時候提供⽀支援 • https://github.com/invertase/react-native-firebase • Flutter • mlkit - A Flutter plugin to use the Firebase ML Kit • https://pub.dartlang.org/packages/mlkit

Slide 26

Slide 26 text

One more things Two

Slide 27

Slide 27 text

React Native Camera • https://github.com/react-native-community/react-native-camera • ⽀支援的功能: • photographs • videos • face detection • barcode scanning • text recognition (Android only)

Slide 28

Slide 28 text

PWA • Progressive Web Apps + (Google) Cloud Vision API • What Web Can Do Today — 介紹⽬目前瀏覽器已經⽀支援的功能
 https://whatwebcando.today/ • PWA Rocks — 精選⼀一些 PWA 的網站 • https://pwa.rocks/ • 掃描 QRCode: https://qrcodescan.in/

Slide 29

Slide 29 text

參參考資料 • https://youtu.be/Z-dqGRSsaBs • https://codelabs.developers.google.com/codelabs/mlkit- android/ • https://codelabs.developers.google.com/codelabs/mlkit-ios/ • https://github.com/firebase/quickstart-android/tree/ master/mlkit • https://github.com/firebase/quickstart-ios/tree/master/ mlvision

Slide 30

Slide 30 text

No content