
์๋ ํ์ธ์.
๋ง์ฝ, ์ฒ์ ์ด ๊ธ์ ๋ณด์ ๋ค๋ฉด ์๋ ๊ธ์ ๋จผ์ ์ฝ์ด๋ณด์๋ ๊ฒ์ ์ถ์ฒ๋๋ฆฝ๋๋ค.
1ํธ : Coral Board ๋์ ๋ผ์ฆ๋ฒ ๋ฆฌํ์ด๋ฅผ ์ฌ์ฉํ๋ ์ด์ : https://coding-yoon.tistory.com/85?category=866905
2ํธ : USB Accelerator(Edge TPU) ํ๊ฒฝ์ค์ : https://coding-yoon.tistory.com/87?category=866905
3ํธ : Coral Edge TPU ์์ ๋๋ฆฌ๊ธฐ : https://coding-yoon.tistory.com/88



Edge TPU๋ CNN๊ณผ ๊ฐ์ Deep feed-forward ์ ๊ฒฝ๋ง์ ์คํํ ์ ์์ต๋๋ค.
8๋นํธ Edge TPU ์ฉ์ผ๋ก ์ปดํ์ผ ๋ TensorFlow Lite ๋ชจ๋ธ๋ง ์ง์ํ๋ฉฐ, 32๋นํธ TensorFlow๋ ์ง์ํ์ง ์์ต๋๋ค.
Tensor Lite๋ก ์ง์ ๋ชจ๋ธ์ ํ์ต์ํฌ ์ ์๊ณ , Transfer Learning(์ ์ด ํ์ต)์ ํตํด ๋ชจ๋ธ์ ํฅ์น์ํฌ ์ ์์ต๋๋ค.
TensorFlow(.pb)๋ Keras(.h5)(32bit)๋ฅผ ํตํด ํ์ต๋ ๋ชจ๋ธ์ TensorFlow Lite Converter๋ฅผ ์ฌ์ฉํ์ฌ TensorFlow ํ์ผ์์ TensorFlow Lite (.tflite)๋ก ๋ชจ๋ธ์ ๋ณํํด์ผํฉ๋๋ค.
<์ฐธ๊ณ >
์ ๋ Coral๋ก ๊ฐ๋ฐ์ ํ ๋ ๊ฐ์ธ์ ์ผ๋ก Keras๋ฅผ ์ถ์ฒ๋๋ฆฌ๊ณ ์ถ์ต๋๋ค.
Edge TPU๊ฐ ๋ชจ๋ ์ฐ์ฐ์ ํ๋ ๊ฒ์ ์๋๋๋ค. ๊ณต์ ํํ์ด์ง์์ Edge TPU๊ฐ ์ง์ํ๋ ์ฐ์ฐ๋ค์ ์๊ฐํฉ๋๋ค.
๋ชจ๋ฐ์ผ๋ท๊ณผ ๊ฐ์ ๊ฒฝ๋ ๋ชจ๋ธ์์ ์ฌ์ฉํ๋ ์ฐ์ฐ๋ค์ ์ง์ํ๋ฉฐ, ์์ ๋ค ๋ํ Keras๋ชจ๋ธ์ ๋ถ๋ฌ์ ํ์ต์์ผฐ์ต๋๋ค.
์๋ฅผ ๋ค๋ฉด Depthwise Seperable Convolution์ ์ฐพ์ ์ ์๊ณ , ๊ฒฝ๋ ๋ชจ๋ธ : MobileNet, Xception ๋ฑ์ ๋ณผ ์ ์์ต๋๋ค.
https://coding-yoon.tistory.com/77?category=825914
[๋ฅ๋ฌ๋] Depthwise Separable Covolution with Pytorch( feat. Convolution parameters VS Depthwise Separable Covolution paramet
์๋ ํ์ธ์. Google Coral์์ ํ์ต๋ ๋ชจ๋ธ์ ํตํด ์ถ๋ก ์ ํ ์ ์๋ Coral Board & USB Accelator ๊ฐ ์์ต๋๋ค. ์ ๋ Coral Board๋ฅผ ์ฌ์ฉํ์ง ์๊ณ , ๋ผ์ฆ๋ฒ ๋ฆฌํ์ด4์ USB Accelator๋ฅผ ์ฐ๊ฒฐํ์ฌ ์ฌ์ฉํ ์๊ฐ์ ๋..
coding-yoon.tistory.com


์ฐ์ , TensorFlow๋ Keras๋ก ํ์ต๋ ๋ชจ๋ธ์ ์ ์ฅํด์ผ ํฉ๋๋ค.
TensorFlow๋ก ํ์ตํ๋ค๋ฉด, (.pb)ํ์ผ,
Keras๋ก ํ์ตํ๋ค๋ฉด (.h5)ํ์ผ





ํ์ต๋ ๋ชจ๋ธ(32bit)์ TensorFlow Lite Converter(8bit)๋ก ๋ณํํด์ผํฉ๋๋ค.


๋ณํํ ๋ชจ๋ธ์ ์ ์ฅํฉ๋๋ค.


์ด์ ๋ชจ๋ธ์ด ์ค๋น๊ฐ ๋๋ฌ์ต๋๋ค. ์ต์ํ์ ์ฝ๋๋ก ์์ฑํ์ต๋๋ค.




Operation name |
Runtime version* |
Known limitations |
Add |
All |
|
AveragePool2d |
All |
No fused activation function. |
Concatenation |
All |
No fused activation function. |
Conv2d |
All |
Must use the same dilation in x and y dimensions. |
DepthwiseConv2d |
โค12 |
Dilated conv kernels are not supported. |
โฅ13 |
Must use the same dilation in x and y dimensions. |
|
ExpandDims |
โฅ13 |
|
FullyConnected |
All |
Only the default format is supported for fully-connected weights. Output tensor is one-dimensional. |
L2Normalization |
All |
|
Logistic |
All |
|
Maximum |
All |
|
MaxPool2d |
All |
No fused activation function. |
Mean |
โค12 |
No reduction in batch dimension. Supports reduction along x- and/or y-dimensions only. |
โฅ13 |
No reduction in batch dimension. If a z-reduction, the z-dimension must be multiple of 4. |
์ง์ํ๋ ์ฐ์ฐ์ ๋๋ค. ์ง์ํ๋ ์ฐ์ฐ์ ๋ ๋ณด๊ณ ์ถ์ผ์๋ฉด ์๋ ์ฃผ์๋ฅผ ๋ฌ์๋์ํ ๋ ๋ณด์๋ฉด ์ข์ ๊ฒ ๊ฐ์ต๋๋ค.


ํ๋์ Input_data๊ฐ ์ถ๋ก ํ๊ณ ์ ํ๋ ์ค์ ๋ฐ์ดํฐ์ ๋๋ค.
input์ชฝ์ด ์ฝ๋๊ฐ ๊ธธ์ด์ ธ input_tensor๋ก ๋ฐ๋ก ํจ์ํ๋ฅผ ์์ผฐ์ต๋๋ค.
Coral ๊ณต์ GitHub์์ ๋ฅผ ๋ฐ๋ผํ์ต๋๋ค.
output์ชฝ์ ๊ทธ๋ ๊ฒ ๊ธธ์ง ์๊ธฐ ๋๋ฌธ์ tensorflow lite ๊ณต์ ํํ์ด์ง๋ฅผ ๋ฐ๋ผํ์ต๋๋ค.
์ถ๋ก ์ ์์ํ๋ ์ฝ๋๋ Interpreter.invoke()์ ๋๋ค.
์ถ๋ก ์ ์๋ฃํ๋ฉด output_data์ ์ถ๋ก ๊ฐ์ด ๋ด๊ฒจ ์์ต๋๋ค.
๋ค์ ๊ธ์ ๊ฐ๋จํ ๋ชจ๋ธ์ ํ๋ ๋ถ๋ฌ์ ์ค์ ๋ก ์ถ๋ก ์ ํ ๋ฒ ํด๋ณด๊ฒ ์ต๋๋ค.
https://coral.ai/docs/edgetpu/models-intro/#compatibility-overview
https://www.tensorflow.org/tutorials/keras/save_and_load?hl=ko
https://www.tensorflow.org/lite/convert/python_api
https://coral.ai/docs/edgetpu/tflite-python/#load-tensorflow-lite-and-run-an-inference
https://www.tensorflow.org/api_docs/python/tf/lite/Interpreter
'๐ Embeded SW > Raspberry Pi' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ

์๋ ํ์ธ์.
๋ง์ฝ, ์ฒ์ ์ด ๊ธ์ ๋ณด์ ๋ค๋ฉด ์๋ ๊ธ์ ๋จผ์ ์ฝ์ด๋ณด์๋ ๊ฒ์ ์ถ์ฒ๋๋ฆฝ๋๋ค.
1ํธ : Coral Board ๋์ ๋ผ์ฆ๋ฒ ๋ฆฌํ์ด๋ฅผ ์ฌ์ฉํ๋ ์ด์ : https://coding-yoon.tistory.com/85?category=866905
2ํธ : USB Accelerator(Edge TPU) ํ๊ฒฝ์ค์ : https://coding-yoon.tistory.com/87?category=866905
3ํธ : Coral Edge TPU ์์ ๋๋ฆฌ๊ธฐ : https://coding-yoon.tistory.com/88



Edge TPU๋ CNN๊ณผ ๊ฐ์ Deep feed-forward ์ ๊ฒฝ๋ง์ ์คํํ ์ ์์ต๋๋ค.
8๋นํธ Edge TPU ์ฉ์ผ๋ก ์ปดํ์ผ ๋ TensorFlow Lite ๋ชจ๋ธ๋ง ์ง์ํ๋ฉฐ, 32๋นํธ TensorFlow๋ ์ง์ํ์ง ์์ต๋๋ค.
Tensor Lite๋ก ์ง์ ๋ชจ๋ธ์ ํ์ต์ํฌ ์ ์๊ณ , Transfer Learning(์ ์ด ํ์ต)์ ํตํด ๋ชจ๋ธ์ ํฅ์น์ํฌ ์ ์์ต๋๋ค.
TensorFlow(.pb)๋ Keras(.h5)(32bit)๋ฅผ ํตํด ํ์ต๋ ๋ชจ๋ธ์ TensorFlow Lite Converter๋ฅผ ์ฌ์ฉํ์ฌ TensorFlow ํ์ผ์์ TensorFlow Lite (.tflite)๋ก ๋ชจ๋ธ์ ๋ณํํด์ผํฉ๋๋ค.
<์ฐธ๊ณ >
์ ๋ Coral๋ก ๊ฐ๋ฐ์ ํ ๋ ๊ฐ์ธ์ ์ผ๋ก Keras๋ฅผ ์ถ์ฒ๋๋ฆฌ๊ณ ์ถ์ต๋๋ค.
Edge TPU๊ฐ ๋ชจ๋ ์ฐ์ฐ์ ํ๋ ๊ฒ์ ์๋๋๋ค. ๊ณต์ ํํ์ด์ง์์ Edge TPU๊ฐ ์ง์ํ๋ ์ฐ์ฐ๋ค์ ์๊ฐํฉ๋๋ค.
๋ชจ๋ฐ์ผ๋ท๊ณผ ๊ฐ์ ๊ฒฝ๋ ๋ชจ๋ธ์์ ์ฌ์ฉํ๋ ์ฐ์ฐ๋ค์ ์ง์ํ๋ฉฐ, ์์ ๋ค ๋ํ Keras๋ชจ๋ธ์ ๋ถ๋ฌ์ ํ์ต์์ผฐ์ต๋๋ค.
์๋ฅผ ๋ค๋ฉด Depthwise Seperable Convolution์ ์ฐพ์ ์ ์๊ณ , ๊ฒฝ๋ ๋ชจ๋ธ : MobileNet, Xception ๋ฑ์ ๋ณผ ์ ์์ต๋๋ค.
https://coding-yoon.tistory.com/77?category=825914
[๋ฅ๋ฌ๋] Depthwise Separable Covolution with Pytorch( feat. Convolution parameters VS Depthwise Separable Covolution paramet
์๋ ํ์ธ์. Google Coral์์ ํ์ต๋ ๋ชจ๋ธ์ ํตํด ์ถ๋ก ์ ํ ์ ์๋ Coral Board & USB Accelator ๊ฐ ์์ต๋๋ค. ์ ๋ Coral Board๋ฅผ ์ฌ์ฉํ์ง ์๊ณ , ๋ผ์ฆ๋ฒ ๋ฆฌํ์ด4์ USB Accelator๋ฅผ ์ฐ๊ฒฐํ์ฌ ์ฌ์ฉํ ์๊ฐ์ ๋..
coding-yoon.tistory.com


์ฐ์ , TensorFlow๋ Keras๋ก ํ์ต๋ ๋ชจ๋ธ์ ์ ์ฅํด์ผ ํฉ๋๋ค.
TensorFlow๋ก ํ์ตํ๋ค๋ฉด, (.pb)ํ์ผ,
Keras๋ก ํ์ตํ๋ค๋ฉด (.h5)ํ์ผ





ํ์ต๋ ๋ชจ๋ธ(32bit)์ TensorFlow Lite Converter(8bit)๋ก ๋ณํํด์ผํฉ๋๋ค.


๋ณํํ ๋ชจ๋ธ์ ์ ์ฅํฉ๋๋ค.


์ด์ ๋ชจ๋ธ์ด ์ค๋น๊ฐ ๋๋ฌ์ต๋๋ค. ์ต์ํ์ ์ฝ๋๋ก ์์ฑํ์ต๋๋ค.




Operation name |
Runtime version* |
Known limitations |
Add |
All |
|
AveragePool2d |
All |
No fused activation function. |
Concatenation |
All |
No fused activation function. |
Conv2d |
All |
Must use the same dilation in x and y dimensions. |
DepthwiseConv2d |
โค12 |
Dilated conv kernels are not supported. |
โฅ13 |
Must use the same dilation in x and y dimensions. |
|
ExpandDims |
โฅ13 |
|
FullyConnected |
All |
Only the default format is supported for fully-connected weights. Output tensor is one-dimensional. |
L2Normalization |
All |
|
Logistic |
All |
|
Maximum |
All |
|
MaxPool2d |
All |
No fused activation function. |
Mean |
โค12 |
No reduction in batch dimension. Supports reduction along x- and/or y-dimensions only. |
โฅ13 |
No reduction in batch dimension. If a z-reduction, the z-dimension must be multiple of 4. |
์ง์ํ๋ ์ฐ์ฐ์ ๋๋ค. ์ง์ํ๋ ์ฐ์ฐ์ ๋ ๋ณด๊ณ ์ถ์ผ์๋ฉด ์๋ ์ฃผ์๋ฅผ ๋ฌ์๋์ํ ๋ ๋ณด์๋ฉด ์ข์ ๊ฒ ๊ฐ์ต๋๋ค.


ํ๋์ Input_data๊ฐ ์ถ๋ก ํ๊ณ ์ ํ๋ ์ค์ ๋ฐ์ดํฐ์ ๋๋ค.
input์ชฝ์ด ์ฝ๋๊ฐ ๊ธธ์ด์ ธ input_tensor๋ก ๋ฐ๋ก ํจ์ํ๋ฅผ ์์ผฐ์ต๋๋ค.
Coral ๊ณต์ GitHub์์ ๋ฅผ ๋ฐ๋ผํ์ต๋๋ค.
output์ชฝ์ ๊ทธ๋ ๊ฒ ๊ธธ์ง ์๊ธฐ ๋๋ฌธ์ tensorflow lite ๊ณต์ ํํ์ด์ง๋ฅผ ๋ฐ๋ผํ์ต๋๋ค.
์ถ๋ก ์ ์์ํ๋ ์ฝ๋๋ Interpreter.invoke()์ ๋๋ค.
์ถ๋ก ์ ์๋ฃํ๋ฉด output_data์ ์ถ๋ก ๊ฐ์ด ๋ด๊ฒจ ์์ต๋๋ค.
๋ค์ ๊ธ์ ๊ฐ๋จํ ๋ชจ๋ธ์ ํ๋ ๋ถ๋ฌ์ ์ค์ ๋ก ์ถ๋ก ์ ํ ๋ฒ ํด๋ณด๊ฒ ์ต๋๋ค.
https://coral.ai/docs/edgetpu/models-intro/#compatibility-overview
https://www.tensorflow.org/tutorials/keras/save_and_load?hl=ko
https://www.tensorflow.org/lite/convert/python_api
https://coral.ai/docs/edgetpu/tflite-python/#load-tensorflow-lite-and-run-an-inference
https://www.tensorflow.org/api_docs/python/tf/lite/Interpreter