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
45
Dubugging Tips and Tricks for iOS development
elvismetaphor
0
48
Strategies of Facebook LightSpeed project
elvismetaphor
0
60
Background Execution And WorkManager
elvismetaphor
2
480
作為一個跨平台的 Mobile App 開發者,從入門到放棄!?
elvismetaphor
2
470
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
hotwire_or_react
harunatsujita
8
4.1k
生成 AI を活用した toitta 切片分類機能の裏側 / Inside toitta's AI-Based Factoid Clustering
pokutuna
0
570
詳細解説! ArrayListの仕組みと実装
yujisoftware
0
480
Synchronizationを支える技術
s_shimotori
1
150
Content Security Policy入門 セキュリティ設定と 違反レポートのはじめ方 / Introduction to Content Security Policy Getting Started with Security Configuration and Violation Reporting
uskey512
1
430
弊社の「意識チョット低いアーキテクチャ」10選
texmeijin
5
23k
推し活の ハイトラフィックに立ち向かう Railsとアーキテクチャ - Kaigi on Rails 2024
falcon8823
6
2.2k
PagerDuty を軸にした On-Call 構築と運用課題の解決 / PagerDuty Japan Community Meetup 4
horimislime
1
110
Vue3の一歩踏み込んだパフォーマンスチューニング2024
hal_spidernight
3
3.1k
PLoP 2024: The evolution of the microservice architecture pattern language
cer
PRO
0
1.6k
僕がつくった48個のWebサービス達
yusukebe
18
17k
Boost Performance and Developer Productivity with Jakarta EE 11
ivargrimstad
0
830
Featured
See All Featured
Git: the NoSQL Database
bkeepers
PRO
425
64k
Building an army of robots
kneath
302
42k
Statistics for Hackers
jakevdp
796
220k
5 minutes of I Can Smell Your CMS
philhawksworth
202
19k
Teambox: Starting and Learning
jrom
132
8.7k
[RailsConf 2023] Rails as a piece of cake
palkan
51
4.9k
Typedesign – Prime Four
hannesfritz
39
2.4k
StorybookのUI Testing Handbookを読んだ
zakiyama
26
5.2k
Building a Modern Day E-commerce SEO Strategy
aleyda
38
6.9k
Embracing the Ebb and Flow
colly
84
4.4k
Visualization
eitanlees
144
15k
Java REST API Framework Comparison - PWX 2021
mraible
PRO
28
7.9k
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