SlideShare una empresa de Scribd logo
1 de 53
TF Dev Summit 2018 X
Modulab: Learn by Run!!
J. Kang Ph.D. et
al.
Machine Learning on Your Hand
- Introduction to Tensorflow Lite Preview
TF Dev Summit X ModuLABS
Jaewook Kang
Apr. 5th, 2018
1
All Copyright Reserved
@ MoT Lab 2018
TF Dev Summit 2018 X
Modulab: Learn by Run!!
J. Kang Ph.D. et
al.
▪ GIST EEC Ph.D. (2015)
▪ 신호처리 과학자, 삽질러
▪ MoT Lab Leader
▪ https://www.facebook.com/jwkkang
▪ 좋아하는 것:
▪ 통계적 신호처리 / 무선통신 신호처리
▪ C++ Native 라이브러리 구현
▪ Mobile Machine learning
▪ 수영 덕력 6년
2
▪ 대표논문:
Jaewook Kang, et al., "Bayesian Hypothesis Test using Nonparametric Belief Propagation for
Noisy Sparse Recovery," IEEE Trans. on Signal process., Feb. 2015
Jaewook Kang et al., "Fast Signal Separation of 2D Sparse Mixture via Approximate Message-
Passing," IEEE Signal Processing Letters, Nov. 2015
Jaewook Kang (강재욱)
소 개
TF Dev Summit 2018 X
Modulab: Learn by Run!!
J. Kang Ph.D. et
al.
MoT Contributors
3
Jaewook Kang (Soundlly)
Joon ho Lee (Neurophet) Yonggeun Lee
()
Jay Lee (Vingle)
SungJin Lee (DU) Seoyoen Yang (SNU) Yunbum Beak
(신호시스템)
TF Dev Summit 2018 X
Modulab: Learn by Run!!
J. Kang Ph.D. et
al.4
•Mobilenet_quant_v1_224.tflite
•테스트 디바이스: Samsung Galaxy S7
(SM-G930L) + Android 7.0 (Nougat)
•빌드 환경:
• Mac OSX 10.11.6
• bazel Version : 0.7
• Android Studio 3.0
• Android Build Tools Level: 26.1.1
• Android NDK Version: 16.04442984
1.mobilenet_v1_1.0_224 : 67.9 MB, Top-1
Accuracy=70.7, Top-5 Accuracy=89.5
1.mobilenet_quant_v1_224.tflite: 4.3 MB,
Top-1 Accuracy=??, Top-5 Accuracy=??
TF Dev Summit 2018 X
Modulab: Learn by Run!!
J. Kang Ph.D. et
al.5
•Mobilenet_quant_v1_224.tflite
•테스트 디바이스: Samsung Galaxy S7
(SM-G930L) + Android 7.0 (Nougat)
•빌드 환경:
• Mac OSX 10.11.6
• bazel Version : 0.7
• Android Studio 3.0
• Android Build Tools Level: 26.1.1
• Android NDK Version: 16.04442984
1.mobilenet_v1_1.0_224 : 67.9 MB, Top-1
Accuracy=70.7, Top-5 Accuracy=89.5
1.mobilenet_quant_v1_224.tflite: 4.3 MB,
Top-1 Accuracy=??, Top-5 Accuracy=??
TF Dev Summit 2018 X
Modulab: Learn by Run!!
J. Kang Ph.D. et
al.
Machine Learning of Things is
Coming!
❖MoT Lab은 모바일 머신러닝에 관심을 갖습니다
–1. 모바일에서 머신러닝을 한다는 것!
–2. Tensorflow Lite Preview version
• About
• Android NN API hardward acceleration
• Model converting to tflite
6
TF Dev Summit 2018 X
Modulab: Learn by Run!!
J. Kang Ph.D. et
al.
1. 모바일에서 머신러닝을 한다는것
- Why on-device ML?
- 해결해줘야 하는 부분
7
TF Dev Summit 2018 X
Modulab: Learn by Run!!
J. Kang Ph.D. et
al.
모바일 머신러닝
❖Why on-device ML?
– Cloud ML의 제약
• UX 측면
8
TF Dev Summit 2018 X
Modulab: Learn by Run!!
J. Kang Ph.D. et
al.
모바일 머신러닝
❖Why on-device ML?
– Cloud ML의 제약
• UX 측면
– 서비스 반응 속도=
» 입력 데이터 업로드시간
» +클라우드 Inference 시간
» +결과 다운로드 시간
9
TF Dev Summit 2018 X
Modulab: Learn by Run!!
J. Kang Ph.D. et
al.
모바일 머신러닝
❖Why on-device ML?
– Cloud ML의 제약
• UX 측면
– 서비스 반응 속도
– 오프라인 상황
10
TF Dev Summit 2018 X
Modulab: Learn by Run!!
J. Kang Ph.D. et
al.
모바일 머신러닝
❖Why on-device ML?
– Cloud ML의 제약
• 데이터 소모 측면
– Inference할때마다
» server call 필요
» 입력데이터 업로드 필요
– 큰 데이터 소비 APP → 순삭 ㅠ
11
TF Dev Summit 2018 X
Modulab: Learn by Run!!
J. Kang Ph.D. et
al.
모바일 머신러닝
❖Why on-device ML?
– Cloud ML의 제약
• 프라이버시 측면
– 개인화 ← → 프라이버시
» 개인화 서비스는 받고 싶은데 내데이터를 주는 건 싫다
• 데이터 퓨젼의 어려움
– 한 클라우드 서비스에서 다양한 개인정보를 수집하기 어려
움
» 모바일: 위치정보 / 사진 / 영상 /오디오
12
TF Dev Summit 2018 X
Modulab: Learn by Run!!
J. Kang Ph.D. et
al.
모바일 머신러닝
❖해결해줘야 하는 부분
– UX + 데이터 소모 측면 → On-device inference
• 반응 속도 (Fast Response)
• 배터리 (Efficient Computation)
• 모델 사이즈
• 메모리 제한?
– 프라이버시 측면→ On-device training
• 다른 사람 말고 내 얼굴을 잘 인식해라 이놈아
• Transfer learning?
• Personal Data fusion
13
TF Dev Summit 2018 X
Modulab: Learn by Run!!
J. Kang Ph.D. et
al.
모바일 머신러닝
❖해결해줘야 하는 부분
– UX + 비용 측면 → On-device inference
• 반응 속도 (Fast Response)
• 배터리 (Efficient Computation)
• 모델 사이즈
• 메모리 제한?
– 프라이버시 측면→ On-device training
• 다른 사람 말고 내 얼굴을 잘 인식해라 이놈아
• Transfer learning?
• Personal Data fusion
14
TF Dev Summit 2018 X
Modulab: Learn by Run!!
J. Kang Ph.D. et
al.
모바일 머신러닝
15
- 하이퍼커넥트 신범준님 발표자료 중 -
TF Dev Summit 2018 X
Modulab: Learn by Run!!
J. Kang Ph.D. et
al.
2. Tensorflow Lite Preview
- About Tensorflow Lite
- Android Neural Network API
- Model conversion to tflite
16
TF Dev Summit 2018 X
Modulab: Learn by Run!!
J. Kang Ph.D. et
al.
About
❖A lightweight ML library and tool or mobile
devices
– https://www.tensorflow.org/mobile/tflite/
– 지원 플랫폼:
• Android Mobile
• Raspberry Pi 3 (Android Things)
• iOS
– 지원 ops: Tensorflow >= Tensorflow Lite
– 사이즈: Core Interpreter (+supp. Ops) 70kB ( 400kB)
– 버전: Developer preview (2017 Nov, w/ TF v1.5)
17
TF Dev Summit 2018 X
Modulab: Learn by Run!!
J. Kang Ph.D. et
al.
About
18
이미지 출처:
https://www.t
ensorflow.org
/mobile/tflite/
TF Dev Summit 2018 X
Modulab: Learn by Run!!
J. Kang Ph.D. et
al.
About
❖A lightweight ML library and tool or mobile
devices
19
Tflite모델을
각 플랫폼의 커널에서
사용할 수 있도록
번역하는 Api
플랫폼 별 tflite
모델을 최적화
용 op set
on device HW
계산 자원 할당
최적화
이미지출처: https://www.youtube.com/watch?v=FAMfy7izB6A
- Android NNAPI
- iOS CoreML- Tensorflow lite framework
TF Dev Summit 2018 X
Modulab: Learn by Run!!
J. Kang Ph.D. et
al.
About
❖A lightweight ML library and tool or mobile
devices
20
Run on device!
Run on device!
Run on device!
이미지출처: https://www.youtube.com/watch?v=FAMfy7izB6A
- Android NNAPI
- iOS CoreML- Tensorflow lite framework
TF Dev Summit 2018 X
Modulab: Learn by Run!!
J. Kang Ph.D. et
al.
About
❖A lightweight ML library and tool or mobile
devices
– iOS develop has another option!
– coreML converter 따로 있음: tfcoreml github repo
• (tflite+coreml >>10배 속도>> tflite+nnapi)
21
이미지출처: https://www.youtube.com/watch?v=FAMfy7izB6A
TF Dev Summit 2018 X
Modulab: Learn by Run!!
J. Kang Ph.D. et
al.
About
❖Why TensorFlow Lite is faster?
– FlatBuffer:
• A new model file format
– Operation kernels optimized for NEON on ARM
– Hardware acceleration support
• Android NN API (Android Oreo)
– Qualcomm Hexagon DSP SDK (Android P)
– Direct GPU support
• iOS CoreML
– Metal2
– Quantization: Integer-arithmetic only support
• Quantize both weights and activation as 8-bit integers
• Just a few parameters(bias vectors) as 32-bit integers
• 가장 범용적인 multiply-add instruction HW에서의 개선
• 용량 줄이기 보다 Inference 속도개선에 집중
22
TF Dev Summit 2018 X
Modulab: Learn by Run!!
J. Kang Ph.D. et
al.
About
❖Why TensorFlow Lite is faster?
– FlatBuffer:
• A new model file format
– Operation kernels optimized for NEON on ARM
– Hardware acceleration support
• Android NN API (Android Oreo)
– Qualcomm Hexagon DSP SDK (Android P)
– Direct GPU support
• iOS CoreML
– Metal2
– Quantization: Integer-arithmetic only support
• Quantize both weights and activation as 8-bit integers
• Just a few parameters(bias vectors) as 32-bit integers
• 가장 범용적인 multiply-add instruction HW에서의 개선
• 용량 줄이기 보다 Inference 속도개선에 집중
23
TF Dev Summit 2018 X
Modulab: Learn by Run!!
J. Kang Ph.D. et
al.
Android Neural Network API
❖ Android NN API 개요
– On-deivce에서 계산효율적 ML을 위해서 설계된 Android C/C++ API
– TensorFlow Lite 모델은 Android NN API의 Kernel Interpreter로 재구
성 + 최적화 되어 계산 하드웨어에 연결됨.
– Hardware-specific processing을 통해서 neural net inference 속도 개
선!
• Android 에서 잘 돌아가도록 tflite모델을 재구성 + 계산 자원 분배
• 디바이스가 보유하는 계산 유닛(CPU/CPU/DSP)에 효율적으로 계산 workload를
할당 할 예정
• 현재는 CPU만 지원됨 (2018 Mar)
– Supporting Android 8.1 (API level 27 + NDK level 14) or higher
• - tflite + nnapi : api level >= 27, ndk level > 14 (neon arm processor 에 최적화)
• - tflite only : api level >=21 (안빠름)
– tflite는 nnapi가 없어도 돌지만 그 경우 전혀 빠르지 않다!
24
This slide is
powered by J. Lee
TF Dev Summit 2018 X
Modulab: Learn by Run!!
J. Kang Ph.D. et
al.
Android Neural Network API
❖ Android NN API 개요
– https://github.com/tensorflow/tensorflow/blob/master/tensorflow/contrib/lite/java/d
emo/app/src/main/java/com/example/android/tflitecamerademo/ImageClassifier.java
25
This slide is
powered by J. Lee
- .tflite파일은 JAVA의
Interpreter 클래스가 생성될
때 내부적으로 Native C++
API를 호출하고 그 안에서
로드된다.
TF Dev Summit 2018 X
Modulab: Learn by Run!!
J. Kang Ph.D. et
al.
Android Neural Network API
❖ Android NN API 개요
– https://github.com/tensorflow/tensorflow/blob/master/tensorflow/contrib/lite/java/d
emo/app/src/main/java/com/example/android/tflitecamerademo/ImageClassifier.java
26
This slide is
powered by J. Lee
- .tflite파일은 JAVA의
Interpreter 클래스가 생성될
때 내부적으로 Native C++
API를 호출하고 그 안에서
로드된다.
tflite inference 수행하는 class
내부에서 tflite Interpreter 실행
- tflite interpreter JAVA객체 생
성
TF Dev Summit 2018 X
Modulab: Learn by Run!!
J. Kang Ph.D. et
al.
Android Neural Network API
❖ Android NN API 개요
– https://github.com/tensorflow/tensorflow/blob/master/tensorflow/contrib/li
te/java/src/main/native/nativeinterpreterwrapper_jni.cc
27
This slide is
powered by J. Lee
1) JAVA API tflite.run() 이 실행되면
NativeInterpreterWrapper (JNI)를
경유해서 그 안에서 C++ API
Interpreter→Invoke()을 호출
TF Dev Summit 2018 X
Modulab: Learn by Run!!
J. Kang Ph.D. et
al.
Android Neural Network API
❖ Android NN API 개요
– https://github.com/tensorflow/tensorflow/blob/master/tensorflow/contrib/li
te/java/src/main/native/nativeinterpreterwrapper_jni.cc
28
This slide is
powered by J. Lee
1) JAVA API tflite.run() 이 실행되면
NativeInterpreterWrapper (JNI)를
경유해서 그 안에서 C++ API
Interpreter→Invoke()을 호출
Java_org_tensorflow_lite_NativeInterpreterWrapper_run()
TF Dev Summit 2018 X
Modulab: Learn by Run!!
J. Kang Ph.D. et
al.
2) C++ API Interpreter→Invoke()안
에서 nnapi_delegate→Invoke()
가 호출됨
Android Neural Network API
❖ Android NN API 개요
– https://github.com/tensorflow/tensorflow/blob/master/tensorflow/contrib/li
te/interpreter.cc
29
This slide is
powered by J. Lee
TF Dev Summit 2018 X
Modulab: Learn by Run!!
J. Kang Ph.D. et
al.
2) C++ API Interpreter→Invoke()안
에서 nnapi_delegate→Invoke()
가 호출됨
Android Neural Network API
❖ Android NN API 개요
– https://github.com/tensorflow/tensorflow/blob/master/tensorflow/contrib/li
te/interpreter.cc
30
This slide is
powered by J. Lee
TF Dev Summit 2018 X
Modulab: Learn by Run!!
J. Kang Ph.D. et
al.
3) nnapi_delegate→invoke()안에서
nnapi_delegate→BuildGraph()호출
Android Neural Network API
❖ Android NN API 개요
– https://github.com/tensorflow/tensorflow/tree/master/tensorflow/contrib/lite/nnapi
– https://github.com/tensorflow/tensorflow/blob/master/tensorflow/contrib/lite/nnapi_delegate.h
– https://github.com/tensorflow/tensorflow/blob/master/tensorflow/contrib/lite/nnapi_delegate.cc
31
This slide is
powered by J. Lee
TF Dev Summit 2018 X
Modulab: Learn by Run!!
J. Kang Ph.D. et
al.
3) nnapi_delegate→invoke()안에서
nnapi_delegate→BuildGraph()호출
Android Neural Network API
❖ Android NN API 개요
– https://github.com/tensorflow/tensorflow/tree/master/tensorflow/contrib/lite/nnapi
– https://github.com/tensorflow/tensorflow/blob/master/tensorflow/contrib/lite/nnapi_delegate.h
– https://github.com/tensorflow/tensorflow/blob/master/tensorflow/contrib/lite/nnapi_delegate.cc
32
This slide is
powered by J. Lee
TF Dev Summit 2018 X
Modulab: Learn by Run!!
J. Kang Ph.D. et
al.
Android Neural Network API
❖ Android NN API 개요
–
33
This slide is
powered by J. Lee
1) .tflite파일를 JAVA/C++ API
을 통해서 로드해서
2) C++ Android Kernal
Interpreter를 통해서 NNAPI
클래스로 넘겨주고
3) C++ NNAPI Op set을 이용해
서 내부에서 tflite 모델을 low-
level로 내부적으로 빌드한다.
4) low-level tflite 모델을
NNAPI를 통해서 실행한다.
TF Dev Summit 2018 X
Modulab: Learn by Run!!
J. Kang Ph.D. et
al.
Android Neural Network API
❖ Android NN API 개요
– https://developer.android.com/ndk/reference/neural_networks_8h.html
– https://github.com/tensorflow/tensorflow/blob/master/tensorflow/contrib/lite/nnapi_delegate.h
– https://github.com/tensorflow/tensorflow/blob/master/tensorflow/contrib/lite/nnapi_delegate.cc
34
This slide is
powered by J. Lee
NNAPI class methods
- For Model build and compile
- For Model execution
TF Dev Summit 2018 X
Modulab: Learn by Run!!
J. Kang Ph.D. et
al.
Hardware acceleration via Android NN API
❖ Android NN API 개요
– https://developer.android.com/ndk/guides/neuralnetworks/index.html
35
This slide is
powered by J. Lee
Android NN API Op set
- nnapi_delegate→BuildGraph()
에서 생성되는 Low-level 모델은
다음과 같은 NNAPI op set을 사용해서
구성된다.
TF Dev Summit 2018 X
Modulab: Learn by Run!!
J. Kang Ph.D. et
al.
Android Neural Network API
❖ Android NNAPI 프로그래밍 flow
– https://developer.android.com/ndk/guides/neuralnetworks/index.html
36
This slide is
powered by J. Lee
모델생성
Building and Compiling an
NNAPI model into lower-
level code
Inference실행
종료대기
TF Dev Summit 2018 X
Modulab: Learn by Run!!
J. Kang Ph.D. et
al.
Android Neural Network API
❖더 궁금하시면?
– https://developer.android.com/ndk/guides/neuralnetworks/index.html
– 또는 MoT로 오세요! 같이 공부해요!
– 머신러닝에 관심있는 안드로이드 개발자 모집중!
• Android NN API
• JAVA Native Interface
• Android Things
• Tensorflow Lite
37
TF Dev Summit 2018 X
Modulab: Learn by Run!!
J. Kang Ph.D. et
al.
From TF model to Android APP build
38
이미지 출처:
https://www.t
ensorflow.org
/mobile/tflite/
TF Dev Summit 2018 X
Modulab: Learn by Run!!
J. Kang Ph.D. et
al.
From TF model to Android APP build
39
이미지 출처:
https://www.t
ensorflow.org
/mobile/tflite/
TF Dev Summit 2018 X
Modulab: Learn by Run!!
J. Kang Ph.D. et
al.
Model converting to tflite
❖전체 Tf model to Tflite 변환 과정
40
Get a Model
Exporting
the
Inference
Graph
Freezing the
exported
Graph
Conversion
to TFLITE
• Model Design or Downloading
• Training with training graph
• Fine Tunning
• Evaluate the performance
with Inference graph
Convert
• Graph def
(.pb)
• Check point
(.ckpt)
• Frozen graph
(.pb)
• Tensorflow lite
(.tflite)
This slide is
powered by S. Yang
TF Dev Summit 2018 X
Modulab: Learn by Run!!
J. Kang Ph.D. et
al.
Model converting to tflite
❖두가지 방식
– Using frozen graph (.pb)
– Using Saved Model
41
This slide is
powered by S. Yang
TF Dev Summit 2018 X
Modulab: Learn by Run!!
J. Kang Ph.D. et
al.
Model converting to tflite
❖두가지 방식
– Using frozen graph (.pb)
– Using Saved Model (더 쉬운방식 ㅠ, 이쪽이 답이
다)
42
This slide is
powered by S. Yang
TF Dev Summit 2018 X
Modulab: Learn by Run!!
J. Kang Ph.D. et
al.
Model converting to tflite
❖ 1) Tensorflow에서 그래프정보 (.pb+ .ckpt) 추출!
• GraphDef (.pb): TF 계산그래프의 구조 정보만을 담고 있는 객체!
• 세션안에서 tf.train.write_graph()를 이용해서 저장!
• CheckPoint(.cpkt): TF계산 그래프의 훈련된
weight / bias 값이 저장된 lookup table 파일
• 세션안에서 tf.train.Savor()를 이용해서 저장
43
With tf.Session(graph=graph) as sess:
tf.train.write_graph(graph_or_graph_def = sess.graph_def,
logdir= "models/",
name= "graph.pb")
Saver = tf.train.Saver()
With tf.Session() as sess:
saver.save(sess=sess,
save_path= "models/model.ckpt”,
global_step=epoch)
This slide is
powered by S. Yang
TF Dev Summit 2018 X
Modulab: Learn by Run!!
J. Kang Ph.D. et
al.
❖ 2) Frozen Graph (.pb) 생성
• FrozenGraphDef (.pb) : GraphDef를 checkpoint파일정보를 결합해서 variable
노드를 constant노드로 변환하여 저장한 것
• 1) Command line interface를 이용하는 방법 (freeze_graph bazel빌드 필요!)
• 2) freeze_graph.py를 이용해서 파이썬 스크립트를 구성해서 변화하는 방법
Model converting to tflite
44
$ freeze_graph --input_graph=/tmp/mobilenet_v1_224.pb 
--input_checkpoint=/tmp/checkpoints/mobilenet-10202.ckpt 
--input_binary=true 
--output_graph=/tmp/frozen_mobilenet_v1_224.pb 
--output_node_names=MobileNetV1/Predictions/Reshape_1
This slide is
powered by S. Yang
freeze_graph.freeze_graph(
input_graph=“/tmp/mobilenet_v1_224_.pb”,
input_saver= "", # this argument is used with SavedModel
input_binary=True,
input_checkpoint=“/tmp/checkpoints/mobilenet-10202.cpkt”,
output_node_names=“MobileNetV1/Predictions/Reshape_1”,
restore_op_name="save/restore_all", # unused in freeze_graph()
filename_tensor_name="save/Const:0", # unused in freeze_graph()
output_graph=“/tmp/frozen_mobilenet_v1_224.pb ”,
clear_devices=False, # not clear how to use
initializer_nodes="")
TF Dev Summit 2018 X
Modulab: Learn by Run!!
J. Kang Ph.D. et
al.
❖ 3) tflite model 파일 (.tflite) 생성
• Tensorflow Lite Model (.tflite) : Tflite interpreter가 해석가능하도록 변환한
모델 파일
• 1) Command line interface를 이용하는 방법 (toco bazel빌드 필요!)
• Tensorflow source파일 git clone 필요
• Tensorflow source 파일을 local repository directory에서 실행 필요
Model converting to tflite
45
$ bazel clean –expunge
$ bazel run --config=opt //tensorflow/contrib/lite/toco:toco --
--input_file= input_frozen_graph_pb_path # 입력 frozen pb path
--output_file= output_tflite_path # 출력 tflite path
inference_type=FLOAT  # floating-poing conversion
input_shape=1,28,28,1  # model의 input shape
input_array=input  # model의 input node name (from Tensorboard)
output_array=model_out/Softmax # model의 output node name (from Tensorboard)
This slide is
powered by S. Yang
TF Dev Summit 2018 X
Modulab: Learn by Run!!
J. Kang Ph.D. et
al.
❖ 3) tflite model 파일 (.tflite) 생성
• Tensorflow Lite Model (.tflite) : Tflite interpreter가 해석가능하도록 변환한
모델 파일
• 2) tf.contrib.lite.toco_convert를 이용해서 Tensorflow 스크립트에서 바로 생
성가능! (3/30에 push됨 ㅜ )
• https://www.tensorflow.org/versions/master/api_docs/python/tf/contrib/lite/toco_convert
Model converting to tflite
46
TF Dev Summit 2018 X
Modulab: Learn by Run!!
J. Kang Ph.D. et
al.
Model converting to tflite
47
❖몇가지.. 정신건강을 위해
– Tensorflow 모델을 구성할때 TF lite에서 지원하는 operator만 사용
해야한다.
• 지원op리스트:
https://github.com/tensorflow/tensorflow/blob/master/tensorflow/contrib/lite/g3doc/tf_ops_compatibility.md
– Bazel 은 사전에 최신버전으로 업그레이드 하자
– Tensorboard로 input_shape/input node name/output node name확
인 필요
– 절대 경로를 사용하는게 좋다
– win10에서 동작 미확인ㅠ
TF Dev Summit 2018 X
Modulab: Learn by Run!!
J. Kang Ph.D. et
al.
Model converting to tflite
48
❖Further, 여러분의 정신건강을 위해 준비했습니다.
– jwkang's Tensorflow lite Github repo
• A GraphDef+Checkpoint Generation from Lenet5 Tensorflow
model example
• A GraphDef+Checkpoint to Frozen GraphDef conversion example
• A Frozen GraphDef to Tflite conversion example
TF Dev Summit 2018 X
Modulab: Learn by Run!!
J. Kang Ph.D. et
al.
Future Direction of Tflite
❖ More suppoting ops
❖ On-device training
❖ Improved tools
➢ Easier tflite conversion
➢ Easier platform adaptation
49
TF Dev Summit 2018 X
Modulab: Learn by Run!!
J. Kang Ph.D. et
al.
참고자료
❖ The Tensorflow GitHub doc (updated):
– https://github.com/tensorflow/tensorflow/blob/master/tensorflow/contrib/lit
e/toco/g3doc/cmdline_examples.md#savedmodel
❖ The Tensorflow Lite contrib repo documents
– https://github.com/tensorflow/tensorflow/tree/master/tensorflow/co
ntrib/lite/g3doc
❖ The Tensorflow.org documents for prepare model
– https://www.tensorflow.org/mobile/prepare_models
❖ Tensorflow Lite support prebuilt models
– https://github.com/tensorflow/tensorflow/blob/master/tensorflow/contrib/lit
e/g3doc/models.md
50
TF Dev Summit 2018 X
Modulab: Learn by Run!!
J. Kang Ph.D. et
al.
Reviewers
❖ 김승일님 (모두연)
❖ 이일구님 (모두연)
❖ 박은수님 (모두연)
❖ 전태균님 (쎄트렉아이)
❖ 신범준님 (하이퍼커넥트)
❖ 신정규님 (레블업)
51
TF Dev Summit 2018 X
Modulab: Learn by Run!!
J. Kang Ph.D. et
al.
모두연 MoT랩 소개
❖딥러닝을 활용하여 세상을 이롭게 할 IoT/Mobile App
개발에 대한 연구를 같이 해봐요!!
❖ https://www.facebook.com/lab4all/posts/761099760749661
❖ jwkang10@gmail.com 로 메일
❖MoT 추가 멤버 모집중!
– 모바일앱에 포팅하고 싶지만
엄두가 안나는 연구자
– 머신러닝에 관심있는
안드로이드 개발자
– TF코딩은 잘하지만 이론을
더 공부하고 싶은 TF개발자!
- 서비스 기획자
52
TF Dev Summit 2018 X
Modulab: Learn by Run!!
J. Kang Ph.D. et
al.53
The End
All copyright reserved @ MoT Lab 2018

Más contenido relacionado

La actualidad más candente

Plug-ins & Third-Party SDKs in UE4
Plug-ins & Third-Party SDKs in UE4Plug-ins & Third-Party SDKs in UE4
Plug-ins & Third-Party SDKs in UE4Gerke Max Preussner
 
C++20에서 리플렉션 기능 구현
C++20에서 리플렉션 기능 구현C++20에서 리플렉션 기능 구현
C++20에서 리플렉션 기능 구현Bongseok Cho
 
[KGC 2012]Boost.asio를 이용한 네트웍 프로그래밍
[KGC 2012]Boost.asio를 이용한 네트웍 프로그래밍[KGC 2012]Boost.asio를 이용한 네트웍 프로그래밍
[KGC 2012]Boost.asio를 이용한 네트웍 프로그래밍흥배 최
 
TensorFlow Lite for mobile & IoT
TensorFlow Lite for mobile & IoT   TensorFlow Lite for mobile & IoT
TensorFlow Lite for mobile & IoT Mia Chang
 
DoS and DDoS mitigations with eBPF, XDP and DPDK
DoS and DDoS mitigations with eBPF, XDP and DPDKDoS and DDoS mitigations with eBPF, XDP and DPDK
DoS and DDoS mitigations with eBPF, XDP and DPDKMarian Marinov
 
윤석주, 인하우스 웹 프레임워크 Jul8 제작기, NDC2018
윤석주, 인하우스 웹 프레임워크 Jul8 제작기, NDC2018윤석주, 인하우스 웹 프레임워크 Jul8 제작기, NDC2018
윤석주, 인하우스 웹 프레임워크 Jul8 제작기, NDC2018devCAT Studio, NEXON
 
Azure로 MMO게임 서비스하기
Azure로 MMO게임 서비스하기Azure로 MMO게임 서비스하기
Azure로 MMO게임 서비스하기YEONG-CHEON YOU
 
빌드관리 및 디버깅 (2010년 자료)
빌드관리 및 디버깅 (2010년 자료)빌드관리 및 디버깅 (2010년 자료)
빌드관리 및 디버깅 (2010년 자료)YEONG-CHEON YOU
 
멀티스레드 렌더링 (Multithreaded rendering)
멀티스레드 렌더링 (Multithreaded rendering)멀티스레드 렌더링 (Multithreaded rendering)
멀티스레드 렌더링 (Multithreaded rendering)Bongseok Cho
 
Instruction Combine in LLVM
Instruction Combine in LLVMInstruction Combine in LLVM
Instruction Combine in LLVMWang Hsiangkai
 
NDC12_Lockless게임서버설계와구현
NDC12_Lockless게임서버설계와구현NDC12_Lockless게임서버설계와구현
NDC12_Lockless게임서버설계와구현noerror
 
인프콘 2022 - Rust 크로스 플랫폼 프로그래밍
인프콘 2022 - Rust 크로스 플랫폼 프로그래밍인프콘 2022 - Rust 크로스 플랫폼 프로그래밍
인프콘 2022 - Rust 크로스 플랫폼 프로그래밍Chris Ohk
 
Iocp 기본 구조 이해
Iocp 기본 구조 이해Iocp 기본 구조 이해
Iocp 기본 구조 이해Nam Hyeonuk
 
C# ゲームプログラミングはホントにメモリのことに無頓着でいいの?
C# ゲームプログラミングはホントにメモリのことに無頓着でいいの?C# ゲームプログラミングはホントにメモリのことに無頓着でいいの?
C# ゲームプログラミングはホントにメモリのことに無頓着でいいの?京大 マイコンクラブ
 
Profiling your Applications using the Linux Perf Tools
Profiling your Applications using the Linux Perf ToolsProfiling your Applications using the Linux Perf Tools
Profiling your Applications using the Linux Perf ToolsemBO_Conference
 
언리얼을 활용한 오브젝트 풀링
언리얼을 활용한 오브젝트 풀링언리얼을 활용한 오브젝트 풀링
언리얼을 활용한 오브젝트 풀링TonyCms
 
Ndc2014 시즌 2 : 멀티쓰레드 프로그래밍이 왜 이리 힘드나요? (Lock-free에서 Transactional Memory까지)
Ndc2014 시즌 2 : 멀티쓰레드 프로그래밍이  왜 이리 힘드나요?  (Lock-free에서 Transactional Memory까지)Ndc2014 시즌 2 : 멀티쓰레드 프로그래밍이  왜 이리 힘드나요?  (Lock-free에서 Transactional Memory까지)
Ndc2014 시즌 2 : 멀티쓰레드 프로그래밍이 왜 이리 힘드나요? (Lock-free에서 Transactional Memory까지)내훈 정
 

La actualidad más candente (20)

Plug-ins & Third-Party SDKs in UE4
Plug-ins & Third-Party SDKs in UE4Plug-ins & Third-Party SDKs in UE4
Plug-ins & Third-Party SDKs in UE4
 
C++20에서 리플렉션 기능 구현
C++20에서 리플렉션 기능 구현C++20에서 리플렉션 기능 구현
C++20에서 리플렉션 기능 구현
 
[KGC 2012]Boost.asio를 이용한 네트웍 프로그래밍
[KGC 2012]Boost.asio를 이용한 네트웍 프로그래밍[KGC 2012]Boost.asio를 이용한 네트웍 프로그래밍
[KGC 2012]Boost.asio를 이용한 네트웍 프로그래밍
 
TensorFlow Lite for mobile & IoT
TensorFlow Lite for mobile & IoT   TensorFlow Lite for mobile & IoT
TensorFlow Lite for mobile & IoT
 
DoS and DDoS mitigations with eBPF, XDP and DPDK
DoS and DDoS mitigations with eBPF, XDP and DPDKDoS and DDoS mitigations with eBPF, XDP and DPDK
DoS and DDoS mitigations with eBPF, XDP and DPDK
 
윤석주, 인하우스 웹 프레임워크 Jul8 제작기, NDC2018
윤석주, 인하우스 웹 프레임워크 Jul8 제작기, NDC2018윤석주, 인하우스 웹 프레임워크 Jul8 제작기, NDC2018
윤석주, 인하우스 웹 프레임워크 Jul8 제작기, NDC2018
 
Azure로 MMO게임 서비스하기
Azure로 MMO게임 서비스하기Azure로 MMO게임 서비스하기
Azure로 MMO게임 서비스하기
 
빌드관리 및 디버깅 (2010년 자료)
빌드관리 및 디버깅 (2010년 자료)빌드관리 및 디버깅 (2010년 자료)
빌드관리 및 디버깅 (2010년 자료)
 
멀티스레드 렌더링 (Multithreaded rendering)
멀티스레드 렌더링 (Multithreaded rendering)멀티스레드 렌더링 (Multithreaded rendering)
멀티스레드 렌더링 (Multithreaded rendering)
 
Instruction Combine in LLVM
Instruction Combine in LLVMInstruction Combine in LLVM
Instruction Combine in LLVM
 
Linux : PSCI
Linux : PSCILinux : PSCI
Linux : PSCI
 
NDC12_Lockless게임서버설계와구현
NDC12_Lockless게임서버설계와구현NDC12_Lockless게임서버설계와구현
NDC12_Lockless게임서버설계와구현
 
인프콘 2022 - Rust 크로스 플랫폼 프로그래밍
인프콘 2022 - Rust 크로스 플랫폼 프로그래밍인프콘 2022 - Rust 크로스 플랫폼 프로그래밍
인프콘 2022 - Rust 크로스 플랫폼 프로그래밍
 
Qemu Introduction
Qemu IntroductionQemu Introduction
Qemu Introduction
 
UE4 MultiPlayer Online Deep Dive 基礎編1 -Getting Started- (historia様ご講演) #UE4DD
UE4 MultiPlayer Online Deep Dive 基礎編1 -Getting Started-  (historia様ご講演) #UE4DDUE4 MultiPlayer Online Deep Dive 基礎編1 -Getting Started-  (historia様ご講演) #UE4DD
UE4 MultiPlayer Online Deep Dive 基礎編1 -Getting Started- (historia様ご講演) #UE4DD
 
Iocp 기본 구조 이해
Iocp 기본 구조 이해Iocp 기본 구조 이해
Iocp 기본 구조 이해
 
C# ゲームプログラミングはホントにメモリのことに無頓着でいいの?
C# ゲームプログラミングはホントにメモリのことに無頓着でいいの?C# ゲームプログラミングはホントにメモリのことに無頓着でいいの?
C# ゲームプログラミングはホントにメモリのことに無頓着でいいの?
 
Profiling your Applications using the Linux Perf Tools
Profiling your Applications using the Linux Perf ToolsProfiling your Applications using the Linux Perf Tools
Profiling your Applications using the Linux Perf Tools
 
언리얼을 활용한 오브젝트 풀링
언리얼을 활용한 오브젝트 풀링언리얼을 활용한 오브젝트 풀링
언리얼을 활용한 오브젝트 풀링
 
Ndc2014 시즌 2 : 멀티쓰레드 프로그래밍이 왜 이리 힘드나요? (Lock-free에서 Transactional Memory까지)
Ndc2014 시즌 2 : 멀티쓰레드 프로그래밍이  왜 이리 힘드나요?  (Lock-free에서 Transactional Memory까지)Ndc2014 시즌 2 : 멀티쓰레드 프로그래밍이  왜 이리 힘드나요?  (Lock-free에서 Transactional Memory까지)
Ndc2014 시즌 2 : 멀티쓰레드 프로그래밍이 왜 이리 힘드나요? (Lock-free에서 Transactional Memory까지)
 

Similar a Machine Learning on Your Hand - Introduction to Tensorflow Lite Preview

Google APAC Machine Learning Expert Day
Google APAC Machine Learning Expert DayGoogle APAC Machine Learning Expert Day
Google APAC Machine Learning Expert DayEvan Lin
 
Koss Lab 세미나 오픈소스 인공지능(AI) 프레임웍파헤치기
Koss Lab 세미나 오픈소스 인공지능(AI) 프레임웍파헤치기 Koss Lab 세미나 오픈소스 인공지능(AI) 프레임웍파헤치기
Koss Lab 세미나 오픈소스 인공지능(AI) 프레임웍파헤치기 Mario Cho
 
Bringing TensorFlow to Android: a war story - Yoni Tsafir, JoyTunes
Bringing TensorFlow to Android: a war story - Yoni Tsafir, JoyTunesBringing TensorFlow to Android: a war story - Yoni Tsafir, JoyTunes
Bringing TensorFlow to Android: a war story - Yoni Tsafir, JoyTunesDroidConTLV
 
Bringing TensorFlow to Android - a War Story
Bringing TensorFlow to Android - a War StoryBringing TensorFlow to Android - a War Story
Bringing TensorFlow to Android - a War StoryYoni Tsafir
 
Python enterprise vento di liberta
Python enterprise vento di libertaPython enterprise vento di liberta
Python enterprise vento di libertaSimone Federici
 
TFLite NNAPI and GPU Delegates
TFLite NNAPI and GPU DelegatesTFLite NNAPI and GPU Delegates
TFLite NNAPI and GPU DelegatesKoan-Sin Tan
 
Technology and AI sharing - From 2016 to Y2017 and Beyond
Technology and AI sharing - From 2016 to Y2017 and BeyondTechnology and AI sharing - From 2016 to Y2017 and Beyond
Technology and AI sharing - From 2016 to Y2017 and BeyondJames Huang
 
Deep learning on mobile
Deep learning on mobileDeep learning on mobile
Deep learning on mobileAnirudh Koul
 
Simplifying training deep and serving learning models with big data in python...
Simplifying training deep and serving learning models with big data in python...Simplifying training deep and serving learning models with big data in python...
Simplifying training deep and serving learning models with big data in python...Holden Karau
 
Powering Tensorflow with big data using Apache Beam, Flink, and Spark - OSCON...
Powering Tensorflow with big data using Apache Beam, Flink, and Spark - OSCON...Powering Tensorflow with big data using Apache Beam, Flink, and Spark - OSCON...
Powering Tensorflow with big data using Apache Beam, Flink, and Spark - OSCON...Holden Karau
 
Monitoring of GPU Usage with Tensorflow Models Using Prometheus
Monitoring of GPU Usage with Tensorflow Models Using PrometheusMonitoring of GPU Usage with Tensorflow Models Using Prometheus
Monitoring of GPU Usage with Tensorflow Models Using PrometheusDatabricks
 
Flutter Beta but Better and Better
Flutter Beta but Better and BetterFlutter Beta but Better and Better
Flutter Beta but Better and BetterDonghyeok Kang
 
Aprendizaje automático aplicado utilizando TensorFlow
Aprendizaje automático aplicado utilizando TensorFlowAprendizaje automático aplicado utilizando TensorFlow
Aprendizaje automático aplicado utilizando TensorFlowNicolas Bortolotti
 
How to Choose a Deep Learning Framework
How to Choose a Deep Learning FrameworkHow to Choose a Deep Learning Framework
How to Choose a Deep Learning FrameworkNavid Kalaei
 
Nautral Langauge Processing - Basics / Non Technical
Nautral Langauge Processing - Basics / Non Technical Nautral Langauge Processing - Basics / Non Technical
Nautral Langauge Processing - Basics / Non Technical Dhruv Gohil
 
Session 1 - The Current Landscape of Big Data Benchmarks
Session 1 - The Current Landscape of Big Data BenchmarksSession 1 - The Current Landscape of Big Data Benchmarks
Session 1 - The Current Landscape of Big Data BenchmarksDataBench
 
Geoscience and Microservices
Geoscience and Microservices Geoscience and Microservices
Geoscience and Microservices Matthew Gerring
 
SpringOne 2016 in a nutshell
SpringOne 2016 in a nutshellSpringOne 2016 in a nutshell
SpringOne 2016 in a nutshellJeroen Resoort
 

Similar a Machine Learning on Your Hand - Introduction to Tensorflow Lite Preview (20)

Google APAC Machine Learning Expert Day
Google APAC Machine Learning Expert DayGoogle APAC Machine Learning Expert Day
Google APAC Machine Learning Expert Day
 
Koss Lab 세미나 오픈소스 인공지능(AI) 프레임웍파헤치기
Koss Lab 세미나 오픈소스 인공지능(AI) 프레임웍파헤치기 Koss Lab 세미나 오픈소스 인공지능(AI) 프레임웍파헤치기
Koss Lab 세미나 오픈소스 인공지능(AI) 프레임웍파헤치기
 
Bringing TensorFlow to Android: a war story - Yoni Tsafir, JoyTunes
Bringing TensorFlow to Android: a war story - Yoni Tsafir, JoyTunesBringing TensorFlow to Android: a war story - Yoni Tsafir, JoyTunes
Bringing TensorFlow to Android: a war story - Yoni Tsafir, JoyTunes
 
Bringing TensorFlow to Android - a War Story
Bringing TensorFlow to Android - a War StoryBringing TensorFlow to Android - a War Story
Bringing TensorFlow to Android - a War Story
 
Python enterprise vento di liberta
Python enterprise vento di libertaPython enterprise vento di liberta
Python enterprise vento di liberta
 
2019 04-23-tf lite-avid-f
2019 04-23-tf lite-avid-f2019 04-23-tf lite-avid-f
2019 04-23-tf lite-avid-f
 
TFLite NNAPI and GPU Delegates
TFLite NNAPI and GPU DelegatesTFLite NNAPI and GPU Delegates
TFLite NNAPI and GPU Delegates
 
Technology and AI sharing - From 2016 to Y2017 and Beyond
Technology and AI sharing - From 2016 to Y2017 and BeyondTechnology and AI sharing - From 2016 to Y2017 and Beyond
Technology and AI sharing - From 2016 to Y2017 and Beyond
 
Deep learning on mobile
Deep learning on mobileDeep learning on mobile
Deep learning on mobile
 
Simplifying training deep and serving learning models with big data in python...
Simplifying training deep and serving learning models with big data in python...Simplifying training deep and serving learning models with big data in python...
Simplifying training deep and serving learning models with big data in python...
 
Powering Tensorflow with big data using Apache Beam, Flink, and Spark - OSCON...
Powering Tensorflow with big data using Apache Beam, Flink, and Spark - OSCON...Powering Tensorflow with big data using Apache Beam, Flink, and Spark - OSCON...
Powering Tensorflow with big data using Apache Beam, Flink, and Spark - OSCON...
 
Monitoring of GPU Usage with Tensorflow Models Using Prometheus
Monitoring of GPU Usage with Tensorflow Models Using PrometheusMonitoring of GPU Usage with Tensorflow Models Using Prometheus
Monitoring of GPU Usage with Tensorflow Models Using Prometheus
 
Flutter Beta but Better and Better
Flutter Beta but Better and BetterFlutter Beta but Better and Better
Flutter Beta but Better and Better
 
Aprendizaje automático aplicado utilizando TensorFlow
Aprendizaje automático aplicado utilizando TensorFlowAprendizaje automático aplicado utilizando TensorFlow
Aprendizaje automático aplicado utilizando TensorFlow
 
How to Choose a Deep Learning Framework
How to Choose a Deep Learning FrameworkHow to Choose a Deep Learning Framework
How to Choose a Deep Learning Framework
 
Nautral Langauge Processing - Basics / Non Technical
Nautral Langauge Processing - Basics / Non Technical Nautral Langauge Processing - Basics / Non Technical
Nautral Langauge Processing - Basics / Non Technical
 
Session 1 - The Current Landscape of Big Data Benchmarks
Session 1 - The Current Landscape of Big Data BenchmarksSession 1 - The Current Landscape of Big Data Benchmarks
Session 1 - The Current Landscape of Big Data Benchmarks
 
Geoscience and Microservices
Geoscience and Microservices Geoscience and Microservices
Geoscience and Microservices
 
SpringOne 2016 in a nutshell
SpringOne 2016 in a nutshellSpringOne 2016 in a nutshell
SpringOne 2016 in a nutshell
 
Big data made easy with a Spark
Big data made easy with a SparkBig data made easy with a Spark
Big data made easy with a Spark
 

Más de Modulabs

Debugging with tensor board
Debugging with tensor boardDebugging with tensor board
Debugging with tensor boardModulabs
 
TensorFlow.js & Applied AI at the Coca-Cola Company
TensorFlow.js & Applied AI at the Coca-Cola CompanyTensorFlow.js & Applied AI at the Coca-Cola Company
TensorFlow.js & Applied AI at the Coca-Cola CompanyModulabs
 
Rear-World Robot Learning
Rear-World Robot LearningRear-World Robot Learning
Rear-World Robot LearningModulabs
 
TF.data & Eager Execution
TF.data & Eager ExecutionTF.data & Eager Execution
TF.data & Eager ExecutionModulabs
 
Machine learnig with ModuLABS
Machine learnig with ModuLABSMachine learnig with ModuLABS
Machine learnig with ModuLABSModulabs
 
쫄지말자딥러닝2 - CNN RNN 포함버전
쫄지말자딥러닝2 - CNN RNN 포함버전쫄지말자딥러닝2 - CNN RNN 포함버전
쫄지말자딥러닝2 - CNN RNN 포함버전Modulabs
 
[모두의연구소] 쫄지말자딥러닝
[모두의연구소] 쫄지말자딥러닝[모두의연구소] 쫄지말자딥러닝
[모두의연구소] 쫄지말자딥러닝Modulabs
 

Más de Modulabs (7)

Debugging with tensor board
Debugging with tensor boardDebugging with tensor board
Debugging with tensor board
 
TensorFlow.js & Applied AI at the Coca-Cola Company
TensorFlow.js & Applied AI at the Coca-Cola CompanyTensorFlow.js & Applied AI at the Coca-Cola Company
TensorFlow.js & Applied AI at the Coca-Cola Company
 
Rear-World Robot Learning
Rear-World Robot LearningRear-World Robot Learning
Rear-World Robot Learning
 
TF.data & Eager Execution
TF.data & Eager ExecutionTF.data & Eager Execution
TF.data & Eager Execution
 
Machine learnig with ModuLABS
Machine learnig with ModuLABSMachine learnig with ModuLABS
Machine learnig with ModuLABS
 
쫄지말자딥러닝2 - CNN RNN 포함버전
쫄지말자딥러닝2 - CNN RNN 포함버전쫄지말자딥러닝2 - CNN RNN 포함버전
쫄지말자딥러닝2 - CNN RNN 포함버전
 
[모두의연구소] 쫄지말자딥러닝
[모두의연구소] 쫄지말자딥러닝[모두의연구소] 쫄지말자딥러닝
[모두의연구소] 쫄지말자딥러닝
 

Último

Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...OnePlan Solutions
 
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceCALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceanilsa9823
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerThousandEyes
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsArshad QA
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsJhone kinadey
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...Health
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AIABDERRAOUF MEHENNI
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionSolGuruz
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsAndolasoft Inc
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 

Último (20)

Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
 
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceCALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 

Machine Learning on Your Hand - Introduction to Tensorflow Lite Preview

  • 1. TF Dev Summit 2018 X Modulab: Learn by Run!! J. Kang Ph.D. et al. Machine Learning on Your Hand - Introduction to Tensorflow Lite Preview TF Dev Summit X ModuLABS Jaewook Kang Apr. 5th, 2018 1 All Copyright Reserved @ MoT Lab 2018
  • 2. TF Dev Summit 2018 X Modulab: Learn by Run!! J. Kang Ph.D. et al. ▪ GIST EEC Ph.D. (2015) ▪ 신호처리 과학자, 삽질러 ▪ MoT Lab Leader ▪ https://www.facebook.com/jwkkang ▪ 좋아하는 것: ▪ 통계적 신호처리 / 무선통신 신호처리 ▪ C++ Native 라이브러리 구현 ▪ Mobile Machine learning ▪ 수영 덕력 6년 2 ▪ 대표논문: Jaewook Kang, et al., "Bayesian Hypothesis Test using Nonparametric Belief Propagation for Noisy Sparse Recovery," IEEE Trans. on Signal process., Feb. 2015 Jaewook Kang et al., "Fast Signal Separation of 2D Sparse Mixture via Approximate Message- Passing," IEEE Signal Processing Letters, Nov. 2015 Jaewook Kang (강재욱) 소 개
  • 3. TF Dev Summit 2018 X Modulab: Learn by Run!! J. Kang Ph.D. et al. MoT Contributors 3 Jaewook Kang (Soundlly) Joon ho Lee (Neurophet) Yonggeun Lee () Jay Lee (Vingle) SungJin Lee (DU) Seoyoen Yang (SNU) Yunbum Beak (신호시스템)
  • 4. TF Dev Summit 2018 X Modulab: Learn by Run!! J. Kang Ph.D. et al.4 •Mobilenet_quant_v1_224.tflite •테스트 디바이스: Samsung Galaxy S7 (SM-G930L) + Android 7.0 (Nougat) •빌드 환경: • Mac OSX 10.11.6 • bazel Version : 0.7 • Android Studio 3.0 • Android Build Tools Level: 26.1.1 • Android NDK Version: 16.04442984 1.mobilenet_v1_1.0_224 : 67.9 MB, Top-1 Accuracy=70.7, Top-5 Accuracy=89.5 1.mobilenet_quant_v1_224.tflite: 4.3 MB, Top-1 Accuracy=??, Top-5 Accuracy=??
  • 5. TF Dev Summit 2018 X Modulab: Learn by Run!! J. Kang Ph.D. et al.5 •Mobilenet_quant_v1_224.tflite •테스트 디바이스: Samsung Galaxy S7 (SM-G930L) + Android 7.0 (Nougat) •빌드 환경: • Mac OSX 10.11.6 • bazel Version : 0.7 • Android Studio 3.0 • Android Build Tools Level: 26.1.1 • Android NDK Version: 16.04442984 1.mobilenet_v1_1.0_224 : 67.9 MB, Top-1 Accuracy=70.7, Top-5 Accuracy=89.5 1.mobilenet_quant_v1_224.tflite: 4.3 MB, Top-1 Accuracy=??, Top-5 Accuracy=??
  • 6. TF Dev Summit 2018 X Modulab: Learn by Run!! J. Kang Ph.D. et al. Machine Learning of Things is Coming! ❖MoT Lab은 모바일 머신러닝에 관심을 갖습니다 –1. 모바일에서 머신러닝을 한다는 것! –2. Tensorflow Lite Preview version • About • Android NN API hardward acceleration • Model converting to tflite 6
  • 7. TF Dev Summit 2018 X Modulab: Learn by Run!! J. Kang Ph.D. et al. 1. 모바일에서 머신러닝을 한다는것 - Why on-device ML? - 해결해줘야 하는 부분 7
  • 8. TF Dev Summit 2018 X Modulab: Learn by Run!! J. Kang Ph.D. et al. 모바일 머신러닝 ❖Why on-device ML? – Cloud ML의 제약 • UX 측면 8
  • 9. TF Dev Summit 2018 X Modulab: Learn by Run!! J. Kang Ph.D. et al. 모바일 머신러닝 ❖Why on-device ML? – Cloud ML의 제약 • UX 측면 – 서비스 반응 속도= » 입력 데이터 업로드시간 » +클라우드 Inference 시간 » +결과 다운로드 시간 9
  • 10. TF Dev Summit 2018 X Modulab: Learn by Run!! J. Kang Ph.D. et al. 모바일 머신러닝 ❖Why on-device ML? – Cloud ML의 제약 • UX 측면 – 서비스 반응 속도 – 오프라인 상황 10
  • 11. TF Dev Summit 2018 X Modulab: Learn by Run!! J. Kang Ph.D. et al. 모바일 머신러닝 ❖Why on-device ML? – Cloud ML의 제약 • 데이터 소모 측면 – Inference할때마다 » server call 필요 » 입력데이터 업로드 필요 – 큰 데이터 소비 APP → 순삭 ㅠ 11
  • 12. TF Dev Summit 2018 X Modulab: Learn by Run!! J. Kang Ph.D. et al. 모바일 머신러닝 ❖Why on-device ML? – Cloud ML의 제약 • 프라이버시 측면 – 개인화 ← → 프라이버시 » 개인화 서비스는 받고 싶은데 내데이터를 주는 건 싫다 • 데이터 퓨젼의 어려움 – 한 클라우드 서비스에서 다양한 개인정보를 수집하기 어려 움 » 모바일: 위치정보 / 사진 / 영상 /오디오 12
  • 13. TF Dev Summit 2018 X Modulab: Learn by Run!! J. Kang Ph.D. et al. 모바일 머신러닝 ❖해결해줘야 하는 부분 – UX + 데이터 소모 측면 → On-device inference • 반응 속도 (Fast Response) • 배터리 (Efficient Computation) • 모델 사이즈 • 메모리 제한? – 프라이버시 측면→ On-device training • 다른 사람 말고 내 얼굴을 잘 인식해라 이놈아 • Transfer learning? • Personal Data fusion 13
  • 14. TF Dev Summit 2018 X Modulab: Learn by Run!! J. Kang Ph.D. et al. 모바일 머신러닝 ❖해결해줘야 하는 부분 – UX + 비용 측면 → On-device inference • 반응 속도 (Fast Response) • 배터리 (Efficient Computation) • 모델 사이즈 • 메모리 제한? – 프라이버시 측면→ On-device training • 다른 사람 말고 내 얼굴을 잘 인식해라 이놈아 • Transfer learning? • Personal Data fusion 14
  • 15. TF Dev Summit 2018 X Modulab: Learn by Run!! J. Kang Ph.D. et al. 모바일 머신러닝 15 - 하이퍼커넥트 신범준님 발표자료 중 -
  • 16. TF Dev Summit 2018 X Modulab: Learn by Run!! J. Kang Ph.D. et al. 2. Tensorflow Lite Preview - About Tensorflow Lite - Android Neural Network API - Model conversion to tflite 16
  • 17. TF Dev Summit 2018 X Modulab: Learn by Run!! J. Kang Ph.D. et al. About ❖A lightweight ML library and tool or mobile devices – https://www.tensorflow.org/mobile/tflite/ – 지원 플랫폼: • Android Mobile • Raspberry Pi 3 (Android Things) • iOS – 지원 ops: Tensorflow >= Tensorflow Lite – 사이즈: Core Interpreter (+supp. Ops) 70kB ( 400kB) – 버전: Developer preview (2017 Nov, w/ TF v1.5) 17
  • 18. TF Dev Summit 2018 X Modulab: Learn by Run!! J. Kang Ph.D. et al. About 18 이미지 출처: https://www.t ensorflow.org /mobile/tflite/
  • 19. TF Dev Summit 2018 X Modulab: Learn by Run!! J. Kang Ph.D. et al. About ❖A lightweight ML library and tool or mobile devices 19 Tflite모델을 각 플랫폼의 커널에서 사용할 수 있도록 번역하는 Api 플랫폼 별 tflite 모델을 최적화 용 op set on device HW 계산 자원 할당 최적화 이미지출처: https://www.youtube.com/watch?v=FAMfy7izB6A - Android NNAPI - iOS CoreML- Tensorflow lite framework
  • 20. TF Dev Summit 2018 X Modulab: Learn by Run!! J. Kang Ph.D. et al. About ❖A lightweight ML library and tool or mobile devices 20 Run on device! Run on device! Run on device! 이미지출처: https://www.youtube.com/watch?v=FAMfy7izB6A - Android NNAPI - iOS CoreML- Tensorflow lite framework
  • 21. TF Dev Summit 2018 X Modulab: Learn by Run!! J. Kang Ph.D. et al. About ❖A lightweight ML library and tool or mobile devices – iOS develop has another option! – coreML converter 따로 있음: tfcoreml github repo • (tflite+coreml >>10배 속도>> tflite+nnapi) 21 이미지출처: https://www.youtube.com/watch?v=FAMfy7izB6A
  • 22. TF Dev Summit 2018 X Modulab: Learn by Run!! J. Kang Ph.D. et al. About ❖Why TensorFlow Lite is faster? – FlatBuffer: • A new model file format – Operation kernels optimized for NEON on ARM – Hardware acceleration support • Android NN API (Android Oreo) – Qualcomm Hexagon DSP SDK (Android P) – Direct GPU support • iOS CoreML – Metal2 – Quantization: Integer-arithmetic only support • Quantize both weights and activation as 8-bit integers • Just a few parameters(bias vectors) as 32-bit integers • 가장 범용적인 multiply-add instruction HW에서의 개선 • 용량 줄이기 보다 Inference 속도개선에 집중 22
  • 23. TF Dev Summit 2018 X Modulab: Learn by Run!! J. Kang Ph.D. et al. About ❖Why TensorFlow Lite is faster? – FlatBuffer: • A new model file format – Operation kernels optimized for NEON on ARM – Hardware acceleration support • Android NN API (Android Oreo) – Qualcomm Hexagon DSP SDK (Android P) – Direct GPU support • iOS CoreML – Metal2 – Quantization: Integer-arithmetic only support • Quantize both weights and activation as 8-bit integers • Just a few parameters(bias vectors) as 32-bit integers • 가장 범용적인 multiply-add instruction HW에서의 개선 • 용량 줄이기 보다 Inference 속도개선에 집중 23
  • 24. TF Dev Summit 2018 X Modulab: Learn by Run!! J. Kang Ph.D. et al. Android Neural Network API ❖ Android NN API 개요 – On-deivce에서 계산효율적 ML을 위해서 설계된 Android C/C++ API – TensorFlow Lite 모델은 Android NN API의 Kernel Interpreter로 재구 성 + 최적화 되어 계산 하드웨어에 연결됨. – Hardware-specific processing을 통해서 neural net inference 속도 개 선! • Android 에서 잘 돌아가도록 tflite모델을 재구성 + 계산 자원 분배 • 디바이스가 보유하는 계산 유닛(CPU/CPU/DSP)에 효율적으로 계산 workload를 할당 할 예정 • 현재는 CPU만 지원됨 (2018 Mar) – Supporting Android 8.1 (API level 27 + NDK level 14) or higher • - tflite + nnapi : api level >= 27, ndk level > 14 (neon arm processor 에 최적화) • - tflite only : api level >=21 (안빠름) – tflite는 nnapi가 없어도 돌지만 그 경우 전혀 빠르지 않다! 24 This slide is powered by J. Lee
  • 25. TF Dev Summit 2018 X Modulab: Learn by Run!! J. Kang Ph.D. et al. Android Neural Network API ❖ Android NN API 개요 – https://github.com/tensorflow/tensorflow/blob/master/tensorflow/contrib/lite/java/d emo/app/src/main/java/com/example/android/tflitecamerademo/ImageClassifier.java 25 This slide is powered by J. Lee - .tflite파일은 JAVA의 Interpreter 클래스가 생성될 때 내부적으로 Native C++ API를 호출하고 그 안에서 로드된다.
  • 26. TF Dev Summit 2018 X Modulab: Learn by Run!! J. Kang Ph.D. et al. Android Neural Network API ❖ Android NN API 개요 – https://github.com/tensorflow/tensorflow/blob/master/tensorflow/contrib/lite/java/d emo/app/src/main/java/com/example/android/tflitecamerademo/ImageClassifier.java 26 This slide is powered by J. Lee - .tflite파일은 JAVA의 Interpreter 클래스가 생성될 때 내부적으로 Native C++ API를 호출하고 그 안에서 로드된다. tflite inference 수행하는 class 내부에서 tflite Interpreter 실행 - tflite interpreter JAVA객체 생 성
  • 27. TF Dev Summit 2018 X Modulab: Learn by Run!! J. Kang Ph.D. et al. Android Neural Network API ❖ Android NN API 개요 – https://github.com/tensorflow/tensorflow/blob/master/tensorflow/contrib/li te/java/src/main/native/nativeinterpreterwrapper_jni.cc 27 This slide is powered by J. Lee 1) JAVA API tflite.run() 이 실행되면 NativeInterpreterWrapper (JNI)를 경유해서 그 안에서 C++ API Interpreter→Invoke()을 호출
  • 28. TF Dev Summit 2018 X Modulab: Learn by Run!! J. Kang Ph.D. et al. Android Neural Network API ❖ Android NN API 개요 – https://github.com/tensorflow/tensorflow/blob/master/tensorflow/contrib/li te/java/src/main/native/nativeinterpreterwrapper_jni.cc 28 This slide is powered by J. Lee 1) JAVA API tflite.run() 이 실행되면 NativeInterpreterWrapper (JNI)를 경유해서 그 안에서 C++ API Interpreter→Invoke()을 호출 Java_org_tensorflow_lite_NativeInterpreterWrapper_run()
  • 29. TF Dev Summit 2018 X Modulab: Learn by Run!! J. Kang Ph.D. et al. 2) C++ API Interpreter→Invoke()안 에서 nnapi_delegate→Invoke() 가 호출됨 Android Neural Network API ❖ Android NN API 개요 – https://github.com/tensorflow/tensorflow/blob/master/tensorflow/contrib/li te/interpreter.cc 29 This slide is powered by J. Lee
  • 30. TF Dev Summit 2018 X Modulab: Learn by Run!! J. Kang Ph.D. et al. 2) C++ API Interpreter→Invoke()안 에서 nnapi_delegate→Invoke() 가 호출됨 Android Neural Network API ❖ Android NN API 개요 – https://github.com/tensorflow/tensorflow/blob/master/tensorflow/contrib/li te/interpreter.cc 30 This slide is powered by J. Lee
  • 31. TF Dev Summit 2018 X Modulab: Learn by Run!! J. Kang Ph.D. et al. 3) nnapi_delegate→invoke()안에서 nnapi_delegate→BuildGraph()호출 Android Neural Network API ❖ Android NN API 개요 – https://github.com/tensorflow/tensorflow/tree/master/tensorflow/contrib/lite/nnapi – https://github.com/tensorflow/tensorflow/blob/master/tensorflow/contrib/lite/nnapi_delegate.h – https://github.com/tensorflow/tensorflow/blob/master/tensorflow/contrib/lite/nnapi_delegate.cc 31 This slide is powered by J. Lee
  • 32. TF Dev Summit 2018 X Modulab: Learn by Run!! J. Kang Ph.D. et al. 3) nnapi_delegate→invoke()안에서 nnapi_delegate→BuildGraph()호출 Android Neural Network API ❖ Android NN API 개요 – https://github.com/tensorflow/tensorflow/tree/master/tensorflow/contrib/lite/nnapi – https://github.com/tensorflow/tensorflow/blob/master/tensorflow/contrib/lite/nnapi_delegate.h – https://github.com/tensorflow/tensorflow/blob/master/tensorflow/contrib/lite/nnapi_delegate.cc 32 This slide is powered by J. Lee
  • 33. TF Dev Summit 2018 X Modulab: Learn by Run!! J. Kang Ph.D. et al. Android Neural Network API ❖ Android NN API 개요 – 33 This slide is powered by J. Lee 1) .tflite파일를 JAVA/C++ API 을 통해서 로드해서 2) C++ Android Kernal Interpreter를 통해서 NNAPI 클래스로 넘겨주고 3) C++ NNAPI Op set을 이용해 서 내부에서 tflite 모델을 low- level로 내부적으로 빌드한다. 4) low-level tflite 모델을 NNAPI를 통해서 실행한다.
  • 34. TF Dev Summit 2018 X Modulab: Learn by Run!! J. Kang Ph.D. et al. Android Neural Network API ❖ Android NN API 개요 – https://developer.android.com/ndk/reference/neural_networks_8h.html – https://github.com/tensorflow/tensorflow/blob/master/tensorflow/contrib/lite/nnapi_delegate.h – https://github.com/tensorflow/tensorflow/blob/master/tensorflow/contrib/lite/nnapi_delegate.cc 34 This slide is powered by J. Lee NNAPI class methods - For Model build and compile - For Model execution
  • 35. TF Dev Summit 2018 X Modulab: Learn by Run!! J. Kang Ph.D. et al. Hardware acceleration via Android NN API ❖ Android NN API 개요 – https://developer.android.com/ndk/guides/neuralnetworks/index.html 35 This slide is powered by J. Lee Android NN API Op set - nnapi_delegate→BuildGraph() 에서 생성되는 Low-level 모델은 다음과 같은 NNAPI op set을 사용해서 구성된다.
  • 36. TF Dev Summit 2018 X Modulab: Learn by Run!! J. Kang Ph.D. et al. Android Neural Network API ❖ Android NNAPI 프로그래밍 flow – https://developer.android.com/ndk/guides/neuralnetworks/index.html 36 This slide is powered by J. Lee 모델생성 Building and Compiling an NNAPI model into lower- level code Inference실행 종료대기
  • 37. TF Dev Summit 2018 X Modulab: Learn by Run!! J. Kang Ph.D. et al. Android Neural Network API ❖더 궁금하시면? – https://developer.android.com/ndk/guides/neuralnetworks/index.html – 또는 MoT로 오세요! 같이 공부해요! – 머신러닝에 관심있는 안드로이드 개발자 모집중! • Android NN API • JAVA Native Interface • Android Things • Tensorflow Lite 37
  • 38. TF Dev Summit 2018 X Modulab: Learn by Run!! J. Kang Ph.D. et al. From TF model to Android APP build 38 이미지 출처: https://www.t ensorflow.org /mobile/tflite/
  • 39. TF Dev Summit 2018 X Modulab: Learn by Run!! J. Kang Ph.D. et al. From TF model to Android APP build 39 이미지 출처: https://www.t ensorflow.org /mobile/tflite/
  • 40. TF Dev Summit 2018 X Modulab: Learn by Run!! J. Kang Ph.D. et al. Model converting to tflite ❖전체 Tf model to Tflite 변환 과정 40 Get a Model Exporting the Inference Graph Freezing the exported Graph Conversion to TFLITE • Model Design or Downloading • Training with training graph • Fine Tunning • Evaluate the performance with Inference graph Convert • Graph def (.pb) • Check point (.ckpt) • Frozen graph (.pb) • Tensorflow lite (.tflite) This slide is powered by S. Yang
  • 41. TF Dev Summit 2018 X Modulab: Learn by Run!! J. Kang Ph.D. et al. Model converting to tflite ❖두가지 방식 – Using frozen graph (.pb) – Using Saved Model 41 This slide is powered by S. Yang
  • 42. TF Dev Summit 2018 X Modulab: Learn by Run!! J. Kang Ph.D. et al. Model converting to tflite ❖두가지 방식 – Using frozen graph (.pb) – Using Saved Model (더 쉬운방식 ㅠ, 이쪽이 답이 다) 42 This slide is powered by S. Yang
  • 43. TF Dev Summit 2018 X Modulab: Learn by Run!! J. Kang Ph.D. et al. Model converting to tflite ❖ 1) Tensorflow에서 그래프정보 (.pb+ .ckpt) 추출! • GraphDef (.pb): TF 계산그래프의 구조 정보만을 담고 있는 객체! • 세션안에서 tf.train.write_graph()를 이용해서 저장! • CheckPoint(.cpkt): TF계산 그래프의 훈련된 weight / bias 값이 저장된 lookup table 파일 • 세션안에서 tf.train.Savor()를 이용해서 저장 43 With tf.Session(graph=graph) as sess: tf.train.write_graph(graph_or_graph_def = sess.graph_def, logdir= "models/", name= "graph.pb") Saver = tf.train.Saver() With tf.Session() as sess: saver.save(sess=sess, save_path= "models/model.ckpt”, global_step=epoch) This slide is powered by S. Yang
  • 44. TF Dev Summit 2018 X Modulab: Learn by Run!! J. Kang Ph.D. et al. ❖ 2) Frozen Graph (.pb) 생성 • FrozenGraphDef (.pb) : GraphDef를 checkpoint파일정보를 결합해서 variable 노드를 constant노드로 변환하여 저장한 것 • 1) Command line interface를 이용하는 방법 (freeze_graph bazel빌드 필요!) • 2) freeze_graph.py를 이용해서 파이썬 스크립트를 구성해서 변화하는 방법 Model converting to tflite 44 $ freeze_graph --input_graph=/tmp/mobilenet_v1_224.pb --input_checkpoint=/tmp/checkpoints/mobilenet-10202.ckpt --input_binary=true --output_graph=/tmp/frozen_mobilenet_v1_224.pb --output_node_names=MobileNetV1/Predictions/Reshape_1 This slide is powered by S. Yang freeze_graph.freeze_graph( input_graph=“/tmp/mobilenet_v1_224_.pb”, input_saver= "", # this argument is used with SavedModel input_binary=True, input_checkpoint=“/tmp/checkpoints/mobilenet-10202.cpkt”, output_node_names=“MobileNetV1/Predictions/Reshape_1”, restore_op_name="save/restore_all", # unused in freeze_graph() filename_tensor_name="save/Const:0", # unused in freeze_graph() output_graph=“/tmp/frozen_mobilenet_v1_224.pb ”, clear_devices=False, # not clear how to use initializer_nodes="")
  • 45. TF Dev Summit 2018 X Modulab: Learn by Run!! J. Kang Ph.D. et al. ❖ 3) tflite model 파일 (.tflite) 생성 • Tensorflow Lite Model (.tflite) : Tflite interpreter가 해석가능하도록 변환한 모델 파일 • 1) Command line interface를 이용하는 방법 (toco bazel빌드 필요!) • Tensorflow source파일 git clone 필요 • Tensorflow source 파일을 local repository directory에서 실행 필요 Model converting to tflite 45 $ bazel clean –expunge $ bazel run --config=opt //tensorflow/contrib/lite/toco:toco -- --input_file= input_frozen_graph_pb_path # 입력 frozen pb path --output_file= output_tflite_path # 출력 tflite path inference_type=FLOAT # floating-poing conversion input_shape=1,28,28,1 # model의 input shape input_array=input # model의 input node name (from Tensorboard) output_array=model_out/Softmax # model의 output node name (from Tensorboard) This slide is powered by S. Yang
  • 46. TF Dev Summit 2018 X Modulab: Learn by Run!! J. Kang Ph.D. et al. ❖ 3) tflite model 파일 (.tflite) 생성 • Tensorflow Lite Model (.tflite) : Tflite interpreter가 해석가능하도록 변환한 모델 파일 • 2) tf.contrib.lite.toco_convert를 이용해서 Tensorflow 스크립트에서 바로 생 성가능! (3/30에 push됨 ㅜ ) • https://www.tensorflow.org/versions/master/api_docs/python/tf/contrib/lite/toco_convert Model converting to tflite 46
  • 47. TF Dev Summit 2018 X Modulab: Learn by Run!! J. Kang Ph.D. et al. Model converting to tflite 47 ❖몇가지.. 정신건강을 위해 – Tensorflow 모델을 구성할때 TF lite에서 지원하는 operator만 사용 해야한다. • 지원op리스트: https://github.com/tensorflow/tensorflow/blob/master/tensorflow/contrib/lite/g3doc/tf_ops_compatibility.md – Bazel 은 사전에 최신버전으로 업그레이드 하자 – Tensorboard로 input_shape/input node name/output node name확 인 필요 – 절대 경로를 사용하는게 좋다 – win10에서 동작 미확인ㅠ
  • 48. TF Dev Summit 2018 X Modulab: Learn by Run!! J. Kang Ph.D. et al. Model converting to tflite 48 ❖Further, 여러분의 정신건강을 위해 준비했습니다. – jwkang's Tensorflow lite Github repo • A GraphDef+Checkpoint Generation from Lenet5 Tensorflow model example • A GraphDef+Checkpoint to Frozen GraphDef conversion example • A Frozen GraphDef to Tflite conversion example
  • 49. TF Dev Summit 2018 X Modulab: Learn by Run!! J. Kang Ph.D. et al. Future Direction of Tflite ❖ More suppoting ops ❖ On-device training ❖ Improved tools ➢ Easier tflite conversion ➢ Easier platform adaptation 49
  • 50. TF Dev Summit 2018 X Modulab: Learn by Run!! J. Kang Ph.D. et al. 참고자료 ❖ The Tensorflow GitHub doc (updated): – https://github.com/tensorflow/tensorflow/blob/master/tensorflow/contrib/lit e/toco/g3doc/cmdline_examples.md#savedmodel ❖ The Tensorflow Lite contrib repo documents – https://github.com/tensorflow/tensorflow/tree/master/tensorflow/co ntrib/lite/g3doc ❖ The Tensorflow.org documents for prepare model – https://www.tensorflow.org/mobile/prepare_models ❖ Tensorflow Lite support prebuilt models – https://github.com/tensorflow/tensorflow/blob/master/tensorflow/contrib/lit e/g3doc/models.md 50
  • 51. TF Dev Summit 2018 X Modulab: Learn by Run!! J. Kang Ph.D. et al. Reviewers ❖ 김승일님 (모두연) ❖ 이일구님 (모두연) ❖ 박은수님 (모두연) ❖ 전태균님 (쎄트렉아이) ❖ 신범준님 (하이퍼커넥트) ❖ 신정규님 (레블업) 51
  • 52. TF Dev Summit 2018 X Modulab: Learn by Run!! J. Kang Ph.D. et al. 모두연 MoT랩 소개 ❖딥러닝을 활용하여 세상을 이롭게 할 IoT/Mobile App 개발에 대한 연구를 같이 해봐요!! ❖ https://www.facebook.com/lab4all/posts/761099760749661 ❖ jwkang10@gmail.com 로 메일 ❖MoT 추가 멤버 모집중! – 모바일앱에 포팅하고 싶지만 엄두가 안나는 연구자 – 머신러닝에 관심있는 안드로이드 개발자 – TF코딩은 잘하지만 이론을 더 공부하고 싶은 TF개발자! - 서비스 기획자 52
  • 53. TF Dev Summit 2018 X Modulab: Learn by Run!! J. Kang Ph.D. et al.53 The End All copyright reserved @ MoT Lab 2018