์ฝ˜ํ…์ธ ๋กœ ๊ฑด๋„ˆ๋›ฐ๊ธฐ

Ultralytics YOLOv8 ๐Ÿš€์™€ ํ•จ๊ป˜ ๋ผ์ฆˆ๋ฒ ๋ฆฌ ํŒŒ์ด์— ์ฝ”๋ž„ ์—ฃ์ง€ TPU

USB Edge ๊ฐ€์†๊ธฐ๊ฐ€ ์žฅ์ฐฉ๋œ ๋ผ์ฆˆ๋ฒ ๋ฆฌํŒŒ์ด ์‹ฑ๊ธ€ ๋ณด๋“œ ์ปดํ“จํ„ฐ TPU

์ฝ”๋ž„ ์—ฃ์ง€๋ž€ ๋ฌด์—‡์ธ๊ฐ€์š” TPU?

Coral Edge TPU ๋Š” ์‹œ์Šคํ…œ์— Edge TPU ์ฝ”ํ”„๋กœ์„ธ์„œ๋ฅผ ์ถ”๊ฐ€ํ•˜๋Š” ์†Œํ˜• ์žฅ์น˜์ž…๋‹ˆ๋‹ค. TensorFlow ๋ผ์ดํŠธ ๋ชจ๋ธ์—์„œ ์ €์ „๋ ฅ, ๊ณ ์„ฑ๋Šฅ ML ์ถ”๋ก ์„ ๊ฐ€๋Šฅํ•˜๊ฒŒ ํ•ฉ๋‹ˆ๋‹ค. ์ž์„ธํ•œ ๋‚ด์šฉ์€ Coral Edge TPU ํ™ˆํŽ˜์ด์ง€์—์„œ ํ™•์ธํ•˜์„ธ์š”.

์ฝ”๋ž„ ์—ฃ์ง€๋กœ ๋ผ์ฆˆ๋ฒ ๋ฆฌํŒŒ์ด ๋ชจ๋ธ ์„ฑ๋Šฅ ํ–ฅ์ƒํ•˜๊ธฐ TPU

๋งŽ์€ ์‚ฌ๋žŒ๋“ค์ด ์ „๋ ฅ ํšจ์œจ์ด ๋†’๊ณ  ๋‹ค์–‘ํ•œ ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์— ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋Š” Raspberry Pi์™€ ๊ฐ™์€ ์ž„๋ฒ ๋””๋“œ ๋˜๋Š” ๋ชจ๋ฐ”์ผ ์žฅ์น˜์—์„œ ๋ชจ๋ธ์„ ์‹คํ–‰ํ•˜๋ ค๊ณ  ํ•ฉ๋‹ˆ๋‹ค. ๊ทธ๋Ÿฌ๋‚˜ ์ด๋Ÿฌํ•œ ์žฅ์น˜์—์„œ๋Š” ์ผ๋ฐ˜์ ์œผ๋กœ ๋‹ค์Œ๊ณผ ๊ฐ™์€ ํ˜•์‹์„ ์‚ฌ์šฉํ•˜๋Š” ๊ฒฝ์šฐ์—๋„ ์ถ”๋ก  ์„ฑ๋Šฅ์ด ์ข‹์ง€ ์•Š์Šต๋‹ˆ๋‹ค. onnx ๋˜๋Š” openvino. ์ฝ”๋ž„ ์—ฃ์ง€( TPU )๋Š” ๋ผ์ฆˆ๋ฒ ๋ฆฌ ํŒŒ์ด์™€ ํ•จ๊ป˜ ์‚ฌ์šฉํ•˜๋ฉด ์ถ”๋ก  ์„ฑ๋Šฅ์„ ํฌ๊ฒŒ ํ–ฅ์ƒ์‹œํ‚ฌ ์ˆ˜ ์žˆ๊ธฐ ๋•Œ๋ฌธ์— ์ด ๋ฌธ์ œ์— ๋Œ€ํ•œ ํ›Œ๋ฅญํ•œ ํ•ด๊ฒฐ์ฑ…์ด ๋  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

๋ผ์ฆˆ๋ฒ ๋ฆฌ ํŒŒ์ด์˜ ์—ฃ์ง€ TPU TensorFlow ๋ผ์ดํŠธ(์‹ ๊ทœ)โญ (์‹ ๊ทœ)

๋ผ์ฆˆ๋ฒ ๋ฆฌ ํŒŒ์ด์—์„œ Edge๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ๋ฐฉ๋ฒ•์— ๋Œ€ํ•œ Coral์˜ ๊ธฐ์กด ๊ฐ€์ด๋“œ TPU ๋Š” ์˜ค๋ž˜๋˜์—ˆ์œผ๋ฉฐ, ํ˜„์žฌ Coral Edge TPU ๋Ÿฐํƒ€์ž„ ๋นŒ๋“œ๋Š” ํ˜„์žฌ TensorFlow ๋ผ์ดํŠธ ๋Ÿฐํƒ€์ž„ ๋ฒ„์ „์—์„œ ๋” ์ด์ƒ ์ž‘๋™ํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค. ๊ฒŒ๋‹ค๊ฐ€ Google์€ Coral ํ”„๋กœ์ ํŠธ๋ฅผ ์™„์ „ํžˆ ํฌ๊ธฐํ•œ ๊ฒƒ์œผ๋กœ ๋ณด์ด๋ฉฐ 2021๋…„๋ถ€ํ„ฐ 2024๋…„ ์‚ฌ์ด์— ์—…๋ฐ์ดํŠธ๊ฐ€ ์ด๋ฃจ์–ด์ง€์ง€ ์•Š์•˜์Šต๋‹ˆ๋‹ค. ์ด ๊ฐ€์ด๋“œ์—์„œ๋Š” ์ตœ์‹  ๋ฒ„์ „์˜ TensorFlow ๋ผ์ดํŠธ ๋Ÿฐํƒ€์ž„ ๋ฐ ์—…๋ฐ์ดํŠธ๋œ Coral Edge TPU ๋Ÿฐํƒ€์ž„์œผ๋กœ Edge TPU ๋ฅผ Raspberry Pi ๋‹จ์ผ ๋ณด๋“œ ์ปดํ“จํ„ฐ(SBC)์—์„œ ์ž‘๋™์‹œํ‚ค๋Š” ๋ฐฉ๋ฒ•์„ ๋ณด์—ฌ๋“œ๋ฆฝ๋‹ˆ๋‹ค.

์ „์ œ ์กฐ๊ฑด

์„ค์น˜ ์—ฐ์Šต

์ด ๊ฐ€์ด๋“œ๋Š” ์ด๋ฏธ ์ž‘๋™ํ•˜๋Š” ๋ผ์ฆˆ๋ฒ ๋ฆฌ ํŒŒ์ด OS๊ฐ€ ์„ค์น˜๋˜์–ด ์žˆ๊ณ  ๋‹ค์Œ์„ ์„ค์น˜ํ–ˆ๋‹ค๊ณ  ๊ฐ€์ •ํ•ฉ๋‹ˆ๋‹ค. ultralytics ๋ฐ ๋ชจ๋“  ์ข…์†์„ฑ. ์–ป์œผ๋ ค๋ฉด ultralytics ์„ค์น˜๋œ ๊ฒฝ์šฐ ๋น ๋ฅธ ์‹œ์ž‘ ๊ฐ€์ด๋“œ ๋ฅผ ํด๋ฆญํ•˜์—ฌ ์„ค์ •์„ ์™„๋ฃŒํ•œ ํ›„ ๊ณ„์† ์ง„ํ–‰ํ•˜์„ธ์š”.

Edge TPU ๋Ÿฐํƒ€์ž„ ์„ค์น˜

๋จผ์ € Edge TPU ๋Ÿฐํƒ€์ž„์„ ์„ค์น˜ํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. ๋‹ค์–‘ํ•œ ๋ฒ„์ „์ด ์žˆ์œผ๋ฏ€๋กœ ์‚ฌ์šฉ ์ค‘์ธ ์šด์˜ ์ฒด์ œ์— ๋งž๋Š” ๋ฒ„์ „์„ ์„ ํƒํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.

๋ผ์ฆˆ๋ฒ ๋ฆฌ ํŒŒ์ด OS ๊ณ ์ฃผํŒŒ ๋ชจ๋“œ ๋‹ค์šด๋กœ๋“œํ•  ๋ฒ„์ „
Bullseye 32๋น„ํŠธ ์•„๋‹ˆ์š” libedgetpu1-std_ ... .bullseye_armhf.deb
Bullseye 64๋น„ํŠธ ์•„๋‹ˆ์š” libedgetpu1-std_ ... .bullseye_arm64.deb
Bullseye 32๋น„ํŠธ ์˜ˆ libedgetpu1-max_ ... .bullseye_armhf.deb
Bullseye 64๋น„ํŠธ ์˜ˆ libedgetpu1-max_ ... .bullseye_arm64.deb
๋ถ์›œ 32๋น„ํŠธ ์•„๋‹ˆ์š” libedgetpu1-std_ ... .bookworm_armhf.deb
๋ถ์›œ 64๋น„ํŠธ ์•„๋‹ˆ์š” libedgetpu1-std_ ... .bookworm_arm64.deb
๋ถ์›œ 32๋น„ํŠธ ์˜ˆ libedgetpu1-max_ ... .bookworm_armhf.deb
๋ถ์›œ 64๋น„ํŠธ ์˜ˆ libedgetpu1-max_ ... .bookworm_arm64.deb

์—ฌ๊ธฐ์—์„œ ์ตœ์‹  ๋ฒ„์ „์„ ๋‹ค์šด๋กœ๋“œํ•˜์„ธ์š”.

ํŒŒ์ผ์„ ๋‹ค์šด๋กœ๋“œํ•œ ํ›„ ๋‹ค์Œ ๋ช…๋ น์–ด๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์„ค์น˜ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค:

sudo dpkg -i path/to/package.deb

๋Ÿฐํƒ€์ž„์„ ์„ค์น˜ํ•œ ํ›„, ์ฝ”๋ž„ ์—ฃ์ง€( TPU )๋ฅผ ๋ผ์ฆˆ๋ฒ ๋ฆฌํŒŒ์ด์˜ USB 3.0 ํฌํŠธ์— ์—ฐ๊ฒฐํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. ์ด๋Š” ๊ณต์‹ ๊ฐ€์ด๋“œ์— ๋”ฐ๋ฅด๋ฉด ์ƒˆ๋กœ์šด udev ๊ทœ์น™์„ ์„ค์น˜ํ•œ ํ›„์— ์ ์šฉํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.

์ค‘์š”

Coral Edge TPU ๋Ÿฐํƒ€์ž„์ด ์ด๋ฏธ ์„ค์น˜๋˜์–ด ์žˆ๋Š” ๊ฒฝ์šฐ ๋‹ค์Œ ๋ช…๋ น์„ ์‚ฌ์šฉํ•˜์—ฌ ์ œ๊ฑฐํ•˜์„ธ์š”.

# If you installed the standard version
sudo apt remove libedgetpu1-std 

# If you installed the high frequency version
sudo apt remove libedgetpu1-max 

๋ชจ๋ธ์„ Edge TPU ํ˜ธํ™˜ ๋ชจ๋ธ๋กœ ๋‚ด๋ณด๋‚ด๊ธฐ

Edge TPU ๋ฅผ ์‚ฌ์šฉํ•˜๋ ค๋ฉด ๋ชจ๋ธ์„ ํ˜ธํ™˜ ๊ฐ€๋Šฅํ•œ ํ˜•์‹์œผ๋กœ ๋ณ€ํ™˜ํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. ๊ณต์‹ Ultralytics Docker ์ปจํ…Œ์ด๋„ˆ๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ Google Colab, x86_64 Linux ๋จธ์‹ ์—์„œ ๋‚ด๋ณด๋‚ด๊ธฐ๋ฅผ ์‹คํ–‰ํ•˜๊ฑฐ๋‚˜ Ultralytics HUB๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ๊ฒƒ์ด ์ข‹์Šต๋‹ˆ๋‹ค(ARM์—์„œ๋Š” Edge TPU ์ปดํŒŒ์ผ๋Ÿฌ๋ฅผ ์‚ฌ์šฉํ•  ์ˆ˜ ์—†์œผ๋ฏ€๋กœ). ์‚ฌ์šฉ ๊ฐ€๋Šฅํ•œ ์ธ์ˆ˜๋Š” ๋‚ด๋ณด๋‚ด๊ธฐ ๋ชจ๋“œ๋ฅผ ์ฐธ์กฐํ•˜์„ธ์š”.

๋‚ด๋ณด๋‚ด๊ธฐ

from ultralytics import YOLO

# Load a model
model = YOLO('path/to/model.pt')  # Load a official model or custom model

# Export the model
model.export(format='edgetpu')
yolo export model=path/to/model.pt format=edgetpu  # Export a official model or custom model

๋‚ด๋ณด๋‚ธ ๋ชจ๋ธ์€ <model_name>_saved_model/ ํด๋”์— <model_name>_full_integer_quant_edgetpu.tflite.

๋ชจ๋ธ ์‹คํ–‰

๋ชจ๋ธ์„ ๋‚ด๋ณด๋‚ธ ํ›„ ๋‹ค์Œ ์ฝ”๋“œ๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์ถ”๋ก ์„ ์‹คํ–‰ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค:

์‹คํ–‰ ์ค‘

from ultralytics import YOLO

# Load a model
model = YOLO('path/to/edgetpu_model.tflite')  # Load a official model or custom model

# Run Prediction
model.predict("path/to/source.png")
yolo predict model=path/to/edgetpu_model.tflite source=path/to/source.png  # Load a official model or custom model

์ „์ฒด ์˜ˆ์ธก ๋ชจ๋“œ์— ๋Œ€ํ•œ ์ž์„ธํ•œ ๋‚ด์šฉ์€ ์˜ˆ์ธก ํŽ˜์ด์ง€์—์„œ ์ข…ํ•ฉ ์ •๋ณด๋ฅผ ํ™•์ธํ•˜์„ธ์š”.

์ค‘์š”

๋‹ค์Œ์„ ์‚ฌ์šฉํ•˜์—ฌ ๋ชจ๋ธ์„ ์‹คํ–‰ํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. tflite-runtime ์•„๋‹Œ tensorflow. ๋งŒ์•ฝ tensorflow ๊ฐ€ ์„ค์น˜๋˜์–ด ์žˆ์œผ๋ฉด ๋‹ค์Œ ๋ช…๋ น์œผ๋กœ tensorflow ์„ ์ œ๊ฑฐํ•ฉ๋‹ˆ๋‹ค:

pip uninstall tensorflow tensorflow-aarch64

๊ทธ๋Ÿฐ ๋‹ค์Œ ์„ค์น˜/์—…๋ฐ์ดํŠธ tflite-runtime:

pip install -U tflite-runtime

์›ํ•˜๋Š” ๊ฒฝ์šฐ tflite-runtime ํœ  tensorflow 2.15.0 ๋‹ค์Œ์—์„œ ๋‹ค์šด๋กœ๋“œ ์—ฌ๊ธฐ ๋ฅผ ํด๋ฆญํ•˜๊ณ  ๋‹ค์Œ์„ ์‚ฌ์šฉํ•˜์—ฌ ์„ค์น˜ํ•ฉ๋‹ˆ๋‹ค. pip ๋˜๋Š” ์„ ํƒํ•œ ํŒจํ‚ค์ง€ ๊ด€๋ฆฌ์ž.



์ƒ์„ฑ 2024-02-12, ์—…๋ฐ์ดํŠธ 2024-03-03
์ž‘์„ฑ์ž: glenn-jocher (2), Skillnoob (1)

๋Œ“๊ธ€