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
63
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
責務を分離するための例外設計 - PHPカンファレンス 2024
kajitack
3
700
たのしいparse.y
ydah
3
120
선언형 UI에서의 상태관리
l2hyunwoo
0
160
今年のアップデートで振り返るCDKセキュリティのシフトレフト/2024-cdk-security-shift-left
tomoki10
0
200
return文におけるstd::moveについて
onihusube
1
1.1k
DevFest Tokyo 2025 - Flutter のアプリアーキテクチャ現在地点
wasabeef
5
910
Cloudflare MCP ServerでClaude Desktop からWeb APIを構築
kutakutat
1
540
今年一番支援させていただいたのは認証系サービスでした
satoshi256kbyte
1
250
Refactor your code - refactor yourself
xosofox
1
260
tidymodelsによるtidyな生存時間解析 / Japan.R2024
dropout009
1
770
これが俺の”自分戦略” プロセスを楽しんでいこう! - Developers CAREER Boost 2024
niftycorp
PRO
0
190
生成AIでGitHubソースコード取得して仕様書を作成
shukob
0
360
Featured
See All Featured
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
159
15k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
26
1.5k
We Have a Design System, Now What?
morganepeng
51
7.3k
How GitHub (no longer) Works
holman
311
140k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
28
900
What’s in a name? Adding method to the madness
productmarketing
PRO
22
3.2k
Rails Girls Zürich Keynote
gr2m
94
13k
Done Done
chrislema
181
16k
Side Projects
sachag
452
42k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
656
59k
Building Your Own Lightsaber
phodgson
103
6.1k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
28
4.4k
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