Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
ML Kit Introduction (for Android)
Search
Elvis Lin
July 18, 2018
Programming
0
290
ML Kit Introduction (for Android)
Introduce the basic concept of ML Kit and how to use it in Android development
Elvis Lin
July 18, 2018
Tweet
Share
More Decks by Elvis Lin
See All by Elvis Lin
Protect Users' Privacy in iOS 14
elvismetaphor
0
46
Dubugging Tips and Tricks for iOS development
elvismetaphor
0
48
Strategies of Facebook LightSpeed project
elvismetaphor
0
62
Background Execution And WorkManager
elvismetaphor
2
480
作為一個跨平台的 Mobile App 開發者,從入門到放棄!?
elvismetaphor
2
480
Dependency Injection for testability of iOS app
elvismetaphor
1
1.4k
Briefly Introduction of Kotlin coroutines
elvismetaphor
1
270
MotionLayout Brief Introduction
elvismetaphor
1
320
Chapter 10. Pattern Matching with Regular Expressions
elvismetaphor
0
38
Other Decks in Programming
See All in Programming
ECS Service Connectのこれまでのアップデートと今後のRoadmapを見てみる
tkikuc
2
250
Jakarta EE meets AI
ivargrimstad
0
670
Figma Dev Modeで変わる!Flutterの開発体験
watanave
0
140
macOS でできる リアルタイム動画像処理
biacco42
9
2.4k
ふかぼれ!CSSセレクターモジュール / Fukabore! CSS Selectors Module
petamoriken
0
150
CSC509 Lecture 11
javiergs
PRO
0
180
ピラミッド、アイスクリームコーン、SMURF: 自動テストの最適バランスを求めて / Pyramid Ice-Cream-Cone and SMURF
twada
PRO
10
1.3k
Arm移行タイムアタック
qnighy
0
330
Amazon Qを使ってIaCを触ろう!
maruto
0
410
OnlineTestConf: Test Automation Friend or Foe
maaretp
0
120
3 Effective Rules for Using Signals in Angular
manfredsteyer
PRO
0
100
.NET のための通信フレームワーク MagicOnion 入門 / Introduction to MagicOnion
mayuki
1
1.7k
Featured
See All Featured
A better future with KSS
kneath
238
17k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
47
2.1k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
8
900
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
280
13k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
16
2.1k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
0
100
How to Ace a Technical Interview
jacobian
276
23k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
42
9.2k
Building Flexible Design Systems
yeseniaperezcruz
327
38k
How To Stay Up To Date on Web Technology
chriscoyier
788
250k
Large-scale JavaScript Application Architecture
addyosmani
510
110k
The Cost Of JavaScript in 2023
addyosmani
45
6.8k
Transcript
ML Kit 使⽤用簡介 Elvis Lin @Android Taipei 2018-07-18
關於我 • Elvis Lin • Android 與 iOS 永遠的初學者 •
Twitter: @elvismetaphor • Blog: https://blog.elvismetaphor.me
不是業配 https://youtu.be/Z-dqGRSsaBs
⼤大綱 • 什什麼是(我理理解的)機器學習 • 移動裝置上實作機器學習應⽤用的限制 • TensorFlow Lite 與 ML
Kit • 範例例
機器學習的應⽤用
機器學習 • 從資料中歸納出有⽤用的規則 • 訓練模型 • 使⽤用模型 • Mobile Application
Engineer 參參與開發主要是在「使⽤用模型」 這個範圍
Data Result (Trained) Model
移動裝置上 實作機器學習應⽤用的限制 • 記憶體有限與儲存空間有限 • 計算能⼒力力不如⼤大型伺服器 • 電池容量量有限
移動裝置上 實作機器學習應⽤用的改良⽅方向 • 記憶體有限與儲存空間有限 —> 減少模型(Model)的體積 • 計算能⼒力力不如⼤大型伺服器 —> 降低演算法的複雜度
• 電池容量量有限 —> 降低演算法的複雜度
Google 推出的解決⽅方案 • TensorFlow Lite • ML Kit
https://www.tensorflow.org/mobile/tflite/
Neural Networks API Metal
ML Kit • Cloud Vision API / Mobile Vision API
• Tensorflow Lite • 整合 Firebase,託管「客製化的模型」
ML Kit Base APIs • Image labeling • Text recognition
(OCR) • Face detection • Barcode scanning • Landmark detection • others……
使⽤用 ML Kit
建立⼀一個 Firebase 專案
建立⼀一個 Android app 下載設定檔 設定好 Package Name 下載 google-service.json
<root>/build.gradle dependencies { classpath 'com.android.tools.build:gradle:3.1.3' classpath 'com.google.gms:google-services:4.0.2' }
<root>/app/build.gradle dependencies { // ... implementation 'com.google.firebase:firebase-ml-vision:16.0.0' }
掃描 barcode (local) FirebaseVisionImage image = FirebaseVisionImage.fromBitmap(image); FirebaseVisionBarcodeDetectorOptions options =
new FirebaseVisionBarcodeDetectorOptions.Builder() .setBarcodeFormats( FirebaseVisionBarcode.FORMAT_QR_CODE, FirebaseVisionBarcode.FORMAT_AZTEC ) .build(); FirebaseVisionBarcodeDetector detector = FirebaseVision.getInstance() .getVisionBarcodeDetector(options); detector.detectInImage(image) .addOnSuccessListener( new OnSuccessListener<List<FirebaseVisionBarcode>>() { @Override public void onSuccess(List<FirebaseVisionBarcode> barcodes) {} }) .addOnFailureListener(new OnFailureListener() { @Override public void onFailure(@NonNull Exception e) {} });
初始化 Detector FirebaseVisionImage image = FirebaseVisionImage.fromBitmap(image); FirebaseVisionBarcodeDetectorOptions options = new
FirebaseVisionBarcodeDetectorOptions.Builder() .setBarcodeFormats( FirebaseVisionBarcode.FORMAT_QR_CODE, FirebaseVisionBarcode.FORMAT_AZTEC ) .build(); FirebaseVisionBarcodeDetector detector = FirebaseVision .getInstance() .getVisionBarcodeDetector(options);
取得結果 detector.detectInImage(image) .addOnSuccessListener( new OnSuccessListener<List<FirebaseVisionBarcode>>() { @Override public void onSuccess(List<FirebaseVisionBarcode>
barcodes) {} }) .addOnFailureListener(new OnFailureListener() { @Override public void onFailure(@NonNull Exception e) {} });
⽀支援的 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)
辨識⽂文字 (local) FirebaseVisionImage image = FirebaseVisionImage.fromBitmap(selectedImage); FirebaseVisionTextDetector detector = FirebaseVision.getInstance().getVisionTextDetector();
detector.detectInImage(image) .addOnSuccessListener(new OnSuccessListener<FirebaseVisionText>() { @Override public void onSuccess(FirebaseVisionText text) {} }) .addOnFailureListener(new OnFailureListener() { @Override public void onFailure(@NonNull Exception e) {} });
辨識⽂文字 (cloud) FirebaseVisionCloudDetectorOptions options = new FirebaseVisionCloudDetectorOptions.Builder() .setModelType(FirebaseVisionCloudDetectorOptions.LATEST_MODEL) .setMaxResults(15) .build();
FirebaseVisionImage image = FirebaseVisionImage.fromBitmap(selectedImage); FirebaseVisionCloudDocumentTextDetector detector = FirebaseVision.getInstance() .getVisionCloudDocumentTextDetector(options); detector.detectInImage(image) .addOnSuccessListener(new OnSuccessListener<FirebaseVisionCloudText>() { @Override public void onSuccess(FirebaseVisionCloudText text) {} }) .addOnFailureListener(new OnFailureListener() { @Override public void onFailure(@NonNull Exception e) {} });
補充資料 • 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
參參考資料 • https://youtu.be/Z-dqGRSsaBs • https://codelabs.developers.google.com/codelabs/mlkit- android/ • https://github.com/firebase/quickstart-android/tree/ master/mlkit
None