1ํธ : Coral Board ๋์ ๋ผ์ฆ๋ฒ ๋ฆฌํ์ด๋ฅผ ์ฌ์ฉํ๋ ์ด์ : https://coding-yoon.tistory.com/85?category=866905
2ํธ : USB Accelerator(Edge TPU) ํ๊ฒฝ์ค์ : https://coding-yoon.tistory.com/87?category=866905
์๋ ํ์ธ์.
๋ผ์ฆ๋ฒ ๋ฆฌํ์ด์์ ์ธ๊ณต์ง๋ฅ ์์ ๋ฅผ ๊ฐ๋จํ๊ฒ ๋๋ ค๋ณด๊ฒ ์ต๋๋ค.
ํน์ ์ค๋น๊ฐ ๋์ง ์์ผ์ จ๋ค๋ฉด 2ํธ์ ์ฝ๊ณ ์ค์๋ ๊ฒ์ ์ถ์ฒ๋๋ฆฝ๋๋ค.
mkdir coral && cd coral # coral ๋๋ ํ ๋ฆฌ ์์ฑ
git clone https://github.com/google-coral/tflite.git
cd tflite/python/examples/classification
bash install_requirements.sh
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 189 100 189 0 0 314 0 --:--:-- --:--:-- --:--:-- 313
100 3972k 100 3972k 0 0 1622k 0 0:00:02 0:00:02 --:--:-- 4012k
100 181 0 181 0 0 332 0 --:--:-- --:--:-- --:--:-- 332
100 3448k 100 3448k 0 0 1739k 0 0:00:01 0:00:01 --:--:-- 6748k
100 158 100 158 0 0 541 0 --:--:-- --:--:-- --:--:-- 541
100 40895 100 40895 0 0 63699 0 --:--:-- --:--:-- --:--:-- 3968k
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 148 100 148 0 0 361 0 --:--:-- --:--:-- --:--:-- 361
100 582k 100 582k 0 0 483k 0 0:00:01 0:00:01 --:--:-- 2277k
github์์ classification๊ณผ detection์ด ๊ฐ์ด ์ค์น๊ฐ ๋ฉ๋๋ค.
document์ฒ๋ผ classification์ ๋ฐ๋ผํ ๊ฒ๋๋ค. detection read.md๋ฅผ ๋ณด์๊ณ ๋ฐ๋ผํ์๋ฉด ๋ฉ๋๋ค.
python3 classify_image.py \
--model models/mobilenet_v2_1.0_224_inat_bird_quant_edgetpu.tflite \
--labels models/inat_bird_labels.txt \
--input images/parrot.jpg
classify_image.py๋ฅผ ์คํํ๊ณ ๋ค์ 3๊ฐ์ Argumnets๊ฐ ๋ฐ๋ผ์ต๋๋ค.
python์ argparse ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ฅผ ์ฌ์ฉํด ์ธ์ ๊ฐ์ ๋ฌ๋ฆฌ ์ค์ ๋ค๋ฅด๊ฒ ๋์์ํฌ ์ ์์ต๋๋ค.
๋จธ์ ๋ฌ๋์์ ๋ง์ด ์ฌ์ฉํ๋ ํจ์์ธ๋ฐ, ์ด๊ฒ์ ์ค๋ช ํ ์ ์๋ ๊ธฐํ๊ฐ ์์ผ๋ฉด ์์ธํ ์ค๋ช ํ๋๋ก ํ๊ฒ ์ต๋๋ค.
์ธ์ ๊ฐ์ผ๋ก ์ธ ๊ฐ์ ํ๋ผ๋ฏธํฐ๊ฐ ์ ๋ฌ๋ฉ๋๋ค.
๊ผญ argparse๋ฅผ ์ฌ์ฉํ ํ์๋ ์์ต๋๋ค. ๋์ค์ tensorflow lite interpreter๋ฅผ ์ฌ์ฉํ๋ ๋ฐฉ๋ฒ์ ๋ํด ์ค๋ช ํ ๊ฒ์ ๋๋ค.
์ง๊ธ์ ์ ๊ทธ๋ฐ๊ฐ๋ณด๋ค ํ๊ณ ๋์ด๊ฐ์๋ฉด ๋ฉ๋๋ค.
์คํํด๋ณด๊ฒ ์ต๋๋ค.
----INFERENCE TIME----
Note: The first inference on Edge TPU is slow because it includes loading the model into Edge TPU memory.
17.1ms
4.4ms
4.4ms
4.3ms
4.5ms
-------RESULTS--------
Ara macao (Scarlet Macaw): 0.77734
# 77% Ara macao ๋ผ๋ ์๋ผ๊ณ ์์ธกํจ
์์ธก์ ์ํ ๊ฒ ๊ฐ์ต๋๋ค. ์๋๋ ms ๋จ์๋ก ๋๋ฆ ๋น ๋ฅด๊ฒ inferenceํด์คํ๋ค.
libedgetpu1-max๋ฅผ ์์ผ์ฃผ๋ฉด ๋ ๋นจ๋ผ์ง๊ฒ ์ฃ ?
๋ค์ ๊ธ์ ์์ ์ด ๋ง๋ ๋ชจ๋ธ์ TPU์ ๋ฃ๊ธฐ ์ข์ ๋ชจ์์ผ๋ก ๋ง๋๋ ๋ฐฉ๋ฒ์ ์ฌ๋ฆฌ๊ฒ ์ต๋๋ค.
https://coral.ai/docs/accelerator/get-started/#3-run-a-model-using-the-tensorflow-lite-api
Get started with the USB Accelerator | Coral
Learn how to set up the Coral USB Accelerator and run some demo code.
coral.ai