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

๋น ๋ฅธ ์‹œ์ž‘ ๊ฐ€์ด๋“œ: ๋ผ์ฆˆ๋ฒ ๋ฆฌ ํŒŒ์ด์™€ Ultralytics YOLOv8

์ด ์ข…ํ•ฉ ๊ฐ€์ด๋“œ๋Š” ๋ผ์ฆˆ๋ฒ ๋ฆฌํŒŒ์ด ๋””๋ฐ”์ด์Šค์— Ultralytics YOLOv8 ๋ฐฐํฌ์— ๋Œ€ํ•œ ์ž์„ธํ•œ ์•ˆ๋‚ด๋ฅผ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค. ๋˜ํ•œ ์ด ์ž‘๊ณ  ๊ฐ•๋ ฅํ•œ ์žฅ์น˜์—์„œ YOLOv8 ์˜ ๊ธฐ๋Šฅ์„ ๋ณด์—ฌ์ฃผ๊ธฐ ์œ„ํ•œ ์„ฑ๋Šฅ ๋ฒค์น˜๋งˆํฌ๋„ ์†Œ๊ฐœํ•ฉ๋‹ˆ๋‹ค.



Watch: ๋ผ์ฆˆ๋ฒ ๋ฆฌ ํŒŒ์ด 5 ์—…๋ฐ์ดํŠธ ๋ฐ ๊ฐœ์„  ์‚ฌํ•ญ.

์ฐธ๊ณ 

์ด ๊ฐ€์ด๋“œ๋Š” ์ตœ์‹  Raspberry Pi OS Bookworm(๋ฐ๋น„์•ˆ 12)์„ ์‹คํ–‰ํ•˜๋Š” Raspberry Pi 4 ๋ฐ Raspberry Pi 5๋กœ ํ…Œ์ŠคํŠธ๋˜์—ˆ์Šต๋‹ˆ๋‹ค. Raspberry Pi 3์™€ ๊ฐ™์€ ๊ตฌํ˜• Raspberry Pi ๊ธฐ๊ธฐ์—์„œ ์ด ๊ฐ€์ด๋“œ๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ๊ฒƒ์€ ๋™์ผํ•œ Raspberry Pi OS Bookworm์ด ์„ค์น˜๋˜์–ด ์žˆ๋Š” ํ•œ ์ •์ƒ์ ์œผ๋กœ ์ž‘๋™ํ•  ๊ฒƒ์œผ๋กœ ์˜ˆ์ƒ๋ฉ๋‹ˆ๋‹ค.

๋ผ์ฆˆ๋ฒ ๋ฆฌ ํŒŒ์ด๋ž€ ๋ฌด์—‡์ธ๊ฐ€์š”?

๋ผ์ฆˆ๋ฒ ๋ฆฌ ํŒŒ์ด๋Š” ์ž‘๊ณ  ์ €๋ ดํ•œ ์‹ฑ๊ธ€ ๋ณด๋“œ ์ปดํ“จํ„ฐ์ž…๋‹ˆ๋‹ค. ์ทจ๋ฏธ์šฉ ํ™ˆ ์˜คํ† ๋ฉ”์ด์…˜๋ถ€ํ„ฐ ์‚ฐ์—…์šฉ์— ์ด๋ฅด๊ธฐ๊นŒ์ง€ ๋‹ค์–‘ํ•œ ํ”„๋กœ์ ํŠธ์™€ ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์— ๋„๋ฆฌ ์‚ฌ์šฉ๋˜๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค. ๋ผ์ฆˆ๋ฒ ๋ฆฌ ํŒŒ์ด ๋ณด๋“œ๋Š” ๋‹ค์–‘ํ•œ ์šด์˜ ์ฒด์ œ๋ฅผ ์‹คํ–‰ํ•  ์ˆ˜ ์žˆ์œผ๋ฉฐ, ์„ผ์„œ, ์•ก์ถ”์—์ดํ„ฐ ๋ฐ ๊ธฐํƒ€ ํ•˜๋“œ์›จ์–ด ๊ตฌ์„ฑ ์š”์†Œ์™€ ์‰ฝ๊ฒŒ ํ†ตํ•ฉํ•  ์ˆ˜ ์žˆ๋Š” GPIO(๋ฒ”์šฉ ์ž…๋ ฅ/์ถœ๋ ฅ) ํ•€์„ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค. ๋‹ค์–‘ํ•œ ์‚ฌ์–‘์˜ ๋‹ค์–‘ํ•œ ๋ชจ๋ธ๋กœ ์ œ๊ณต๋˜์ง€๋งŒ, ๋ชจ๋‘ ์ €๋ ดํ•˜๊ณ  ์ปดํŒฉํŠธํ•˜๋ฉฐ ๋‹ค์šฉ๋„๋กœ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋‹ค๋Š” ๊ธฐ๋ณธ ์„ค๊ณ„ ์ฒ ํ•™์€ ๋™์ผํ•ฉ๋‹ˆ๋‹ค.

๋ผ์ฆˆ๋ฒ ๋ฆฌ ํŒŒ์ด ์‹œ๋ฆฌ์ฆˆ ๋น„๊ต

๋ผ์ฆˆ๋ฒ ๋ฆฌ ํŒŒ์ด 3 ๋ผ์ฆˆ๋ฒ ๋ฆฌ ํŒŒ์ด 4 ๋ผ์ฆˆ๋ฒ ๋ฆฌ ํŒŒ์ด 5
CPU ๋ธŒ๋กœ๋“œ์ปด BCM2837, Cortex-A53 64๋น„ํŠธ SoC Broadcom BCM2711, Cortex-A72 64Bit SoC Broadcom BCM2712, Cortex-A76 64Bit SoC
CPU ์ตœ๋Œ€ ์ฃผํŒŒ์ˆ˜ 1.4GHz 1.8GHz 2.4GHz
GPU ๋น„๋””์˜ค์ฝ”์–ด IV ๋น„๋””์˜ค์ฝ”์–ด VI ๋น„๋””์˜ค์ฝ”์–ด VII
GPU ์ตœ๋Œ€ ์ฃผํŒŒ์ˆ˜ 400Mhz 500Mhz 800Mhz
๋ฉ”๋ชจ๋ฆฌ 1GB LPDDR2 SDRAM 1GB, 2GB, 4GB, 8GB LPDDR4-3200 SDRAM 4GB, 8GB LPDDR4X-4267 SDRAM
PCIe N/A N/A 1xPCIe 2.0 ์ธํ„ฐํŽ˜์ด์Šค
์ตœ๋Œ€ ์ „๋ ฅ ์†Œ๋ชจ 2.5A@5V 3A@5V 5A@5V(PD ์‚ฌ์šฉ)

๋ผ์ฆˆ๋ฒ ๋ฆฌ ํŒŒ์ด OS๋ž€ ๋ฌด์—‡์ธ๊ฐ€์š”?

๋ผ์ฆˆ๋ฒ ๋ฆฌํŒŒ์ด OS (์ด์ „์˜ ๋ผ์ฆˆ๋น„์•ˆ)๋Š” ๋ผ์ฆˆ๋ฒ ๋ฆฌํŒŒ์ด ์žฌ๋‹จ์—์„œ ๋ฐฐํฌํ•˜๋Š” ์†Œํ˜• ์‹ฑ๊ธ€ ๋ณด๋“œ ์ปดํ“จํ„ฐ์ธ ๋ผ์ฆˆ๋ฒ ๋ฆฌํŒŒ์ด ์ œํ’ˆ๊ตฐ์„ ์œ„ํ•œ ๋ฐ๋น„์•ˆ GNU/Linux ๋ฐฐํฌํŒ์„ ๊ธฐ๋ฐ˜์œผ๋กœ ํ•˜๋Š” ์œ ๋‹‰์Šค ๊ณ„์—ด ์šด์˜์ฒด์ œ์ž…๋‹ˆ๋‹ค. ๋ผ์ฆˆ๋ฒ ๋ฆฌํŒŒ์ด OS๋Š” ARM CPU๊ฐ€ ํƒ‘์žฌ๋œ ๋ผ์ฆˆ๋ฒ ๋ฆฌํŒŒ์ด์— ๊ณ ๋„๋กœ ์ตœ์ ํ™”๋˜์–ด ์žˆ์œผ๋ฉฐ, Openbox ์Šคํƒœํ‚น ์œˆ๋„์šฐ ๋งค๋‹ˆ์ €์™€ ํ•จ๊ป˜ ์ˆ˜์ •๋œ LXDE ๋ฐ์Šคํฌํ†ฑ ํ™˜๊ฒฝ์„ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค. ๋ผ์ฆˆ๋ฒ ๋ฆฌ ํŒŒ์ด OS๋Š” ๋ผ์ฆˆ๋ฒ ๋ฆฌ ํŒŒ์ด์—์„œ ๊ฐ€๋Šฅํ•œ ํ•œ ๋งŽ์€ ๋ฐ๋น„์•ˆ ํŒจํ‚ค์ง€์˜ ์•ˆ์ •์„ฑ๊ณผ ์„ฑ๋Šฅ์„ ํ–ฅ์ƒ์‹œํ‚ค๋Š” ๋ฐ ์ค‘์ ์„ ๋‘๊ณ  ํ™œ๋ฐœํžˆ ๊ฐœ๋ฐœ ์ค‘์ž…๋‹ˆ๋‹ค.

๋ผ์ฆˆ๋ฒ ๋ฆฌ ํŒŒ์ด OS๋ฅผ ๋ผ์ฆˆ๋ฒ ๋ฆฌ ํŒŒ์ด๋กœ ํ”Œ๋ž˜์‹œํ•˜๊ธฐ

๋ผ์ฆˆ๋ฒ ๋ฆฌ ํŒŒ์ด๋ฅผ ์†์— ๋„ฃ์€ ํ›„ ๊ฐ€์žฅ ๋จผ์ € ํ•ด์•ผ ํ•  ์ผ์€ ๋งˆ์ดํฌ๋กœ SD ์นด๋“œ์— ๋ผ์ฆˆ๋ฒ ๋ฆฌ ํŒŒ์ด OS๋ฅผ ํ”Œ๋ž˜์‹œํ•˜๊ณ , ์žฅ์น˜์— ์‚ฝ์ž…ํ•œ ํ›„ OS๋กœ ๋ถ€ํŒ…ํ•˜๋Š” ๊ฒƒ์ž…๋‹ˆ๋‹ค. ๋ผ์ฆˆ๋ฒ ๋ฆฌํŒŒ์ด์˜ ์ž์„ธํ•œ ์‹œ์ž‘ํ•˜๊ธฐ ์„ค๋ช…์„œ๋ฅผ ๋”ฐ๋ผ ์žฅ์น˜๋ฅผ ์ฒ˜์Œ ์‚ฌ์šฉํ•  ์ค€๋น„๋ฅผ ํ•˜์„ธ์š”.

์„ค์ • Ultralytics

๋‹ค์Œ ์ปดํ“จํ„ฐ ๋น„์ „ ํ”„๋กœ์ ํŠธ๋ฅผ ๊ตฌ์ถ•ํ•˜๊ธฐ ์œ„ํ•ด ๋ผ์ฆˆ๋ฒ ๋ฆฌ ํŒŒ์ด์—์„œ Ultralytics ํŒจํ‚ค์ง€๋ฅผ ์„ค์ •ํ•˜๋Š” ๋ฐฉ๋ฒ•์—๋Š” ๋‘ ๊ฐ€์ง€๊ฐ€ ์žˆ์Šต๋‹ˆ๋‹ค. ๋‘˜ ์ค‘ ํ•˜๋‚˜๋ฅผ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

Docker๋กœ ์‹œ์ž‘ํ•˜๊ธฐ

๋ผ์ฆˆ๋ฒ ๋ฆฌํŒŒ์ด์—์„œ Ultralytics YOLOv8 ๋ฅผ ์‹œ์ž‘ํ•˜๋Š” ๊ฐ€์žฅ ๋น ๋ฅธ ๋ฐฉ๋ฒ•์€ ๋ฏธ๋ฆฌ ๋นŒ๋“œ๋œ ๋ผ์ฆˆ๋ฒ ๋ฆฌํŒŒ์ด์šฉ ๋„์ปค ์ด๋ฏธ์ง€๋กœ ์‹คํ–‰ํ•˜๋Š” ๊ฒƒ์ž…๋‹ˆ๋‹ค.

์•„๋ž˜ ๋ช…๋ น์–ด๋ฅผ ์‹คํ–‰ํ•˜์—ฌ Docker ์ปจํ…Œ์ด๋„ˆ๋ฅผ ๊ฐ€์ ธ์™€ ๋ผ์ฆˆ๋ฒ ๋ฆฌํŒŒ์ด์—์„œ ์‹คํ–‰ํ•ฉ๋‹ˆ๋‹ค. ์ด ์˜ˆ์ œ๋Š” ํŒŒ์ด์ฌ3 ํ™˜๊ฒฝ์˜ ๋ฐ๋น„์•ˆ 12(Bookworm)๊ฐ€ ํฌํ•จ๋œ arm64v8/debian ๋„์ปค ์ด๋ฏธ์ง€๋ฅผ ๊ธฐ๋ฐ˜์œผ๋กœ ํ•ฉ๋‹ˆ๋‹ค.

t=ultralytics/ultralytics:latest-arm64 && sudo docker pull $t && sudo docker run -it --ipc=host $t

์ด ์ž‘์—…์ด ์™„๋ฃŒ๋˜๋ฉด ๋ผ์ฆˆ๋ฒ ๋ฆฌ ํŒŒ์ด์—์„œ NCNN ์‚ฌ์šฉ ์„น์…˜์œผ๋กœ ๊ฑด๋„ˆ๋œ๋‹ˆ๋‹ค.

Docker ์—†์ด ์‹œ์ž‘

Ultralytics ํŒจํ‚ค์ง€ ์„ค์น˜

Here we will install Ultralytics package on the Raspberry Pi with optional dependencies so that we can export the PyTorch models to other different formats.

  1. ํŒจํ‚ค์ง€ ๋ชฉ๋ก ์—…๋ฐ์ดํŠธ, pip ์„ค์น˜ ๋ฐ ์ตœ์‹  ๋ฒ„์ „์œผ๋กœ ์—…๊ทธ๋ ˆ์ด๋“œ

    sudo apt update
    sudo apt install python3-pip -y
    pip install -U pip
    
  2. ์„ค์น˜ ultralytics ์„ ํƒ์  ์ข…์†์„ฑ์ด ์žˆ๋Š” pip ํŒจํ‚ค์ง€

    pip install ultralytics[export]
    
  3. ๋””๋ฐ”์ด์Šค ์žฌ๋ถ€ํŒ…

    sudo reboot
    

๋ผ์ฆˆ๋ฒ ๋ฆฌ ํŒŒ์ด์—์„œ NCNN ์‚ฌ์šฉ

Out of all the model export formats supported by Ultralytics, NCNN delivers the best inference performance when working with Raspberry Pi devices because NCNN is highly optimized for mobile/ embedded platforms (such as ARM architecture). Therefor our recommendation is to use NCNN with Raspberry Pi.

๋ชจ๋ธ์„ NCNN ๋กœ ๋ณ€ํ™˜ํ•˜๊ณ  ์ถ”๋ก  ์‹คํ–‰

PyTorch ํ˜•์‹์˜ YOLOv8n ๋ชจ๋ธ์€ ๋‚ด๋ณด๋‚ธ ๋ชจ๋ธ์„ ์‚ฌ์šฉํ•˜์—ฌ ์ถ”๋ก ์„ ์‹คํ–‰ํ•˜๊ธฐ ์œ„ํ•ด NCNN ๋กœ ๋ณ€ํ™˜๋ฉ๋‹ˆ๋‹ค.

์˜ˆ

from ultralytics import YOLO

# Load a YOLOv8n PyTorch model
model = YOLO("yolov8n.pt")

# Export the model to NCNN format
model.export(format="ncnn")  # creates 'yolov8n_ncnn_model'

# Load the exported NCNN model
ncnn_model = YOLO("yolov8n_ncnn_model")

# Run inference
results = ncnn_model("https://ultralytics.com/images/bus.jpg")
# Export a YOLOv8n PyTorch model to NCNN format
yolo export model=yolov8n.pt format=ncnn  # creates 'yolov8n_ncnn_model'

# Run inference with the exported model
yolo predict model='yolov8n_ncnn_model' source='https://ultralytics.com/images/bus.jpg'

ํŒ

์ง€์›๋˜๋Š” ๋‚ด๋ณด๋‚ด๊ธฐ ์˜ต์…˜์— ๋Œ€ํ•œ ์ž์„ธํ•œ ๋‚ด์šฉ์€ ๋ฐฐํฌ ์˜ต์…˜์— ๋Œ€ํ•œUltralytics ๋ฌธ์„œ ํŽ˜์ด์ง€๋ฅผ ์ฐธ์กฐํ•˜์„ธ์š”.

๋ผ์ฆˆ๋ฒ ๋ฆฌ ํŒŒ์ด 5 vs ๋ผ์ฆˆ๋ฒ ๋ฆฌ ํŒŒ์ด 4 YOLOv8 ๋ฒค์น˜๋งˆํฌ

YOLOv8 benchmarks were run by the Ultralytics team on nine different model formats measuring speed and accuracy: PyTorch, TorchScript, ONNX, OpenVINO, TF SavedModel, TF GraphDef, TF Lite, PaddlePaddle, NCNN. Benchmarks were run on both Raspberry Pi 5 and Raspberry Pi 4 at FP32 precision with default input image size of 640.

์ฐธ๊ณ 

๋‹ค๋ฅธ ๋ชจ๋ธ์€ ํฌ๊ธฐ๊ฐ€ ๋„ˆ๋ฌด ์ปค์„œ ๋ผ์ฆˆ๋ฒ ๋ฆฌ ํŒŒ์ด์—์„œ ์‹คํ–‰ํ•˜๊ธฐ ์–ด๋ ต๊ณ  ์ ์ ˆํ•œ ์„ฑ๋Šฅ์„ ์ œ๊ณตํ•˜์ง€ ์•Š๊ธฐ ๋•Œ๋ฌธ์— YOLOv8n ๋ฐ YOLOv8s ๋ชจ๋ธ์— ๋Œ€ํ•œ ๋ฒค์น˜๋งˆํฌ๋งŒ ํฌํ•จํ–ˆ์Šต๋‹ˆ๋‹ค.

๋น„๊ต ์ฐจํŠธ

์„ฑ๋Šฅ

NVIDIA ์ ฏ์Šจ ์—์ฝ”์‹œ์Šคํ…œ

NVIDIA ์ ฏ์Šจ ์—์ฝ”์‹œ์Šคํ…œ

์ƒ์„ธ ๋น„๊ต ํ‘œ

The below table represents the benchmark results for two different models (YOLOv8n, YOLOv8s) across nine different formats (PyTorch, TorchScript, ONNX, OpenVINO, TF SavedModel, TF GraphDef, TF Lite, PaddlePaddle, NCNN), running on both Raspberry Pi 4 and Raspberry Pi 5, giving us the status, size, mAP50-95(B) metric, and inference time for each combination.

์„ฑ๋Šฅ

ํ˜•์‹ ์ƒํƒœ ๋””์Šคํฌ ํฌ๊ธฐ(MB) mAP50-95(B) ์ถ”๋ก  ์‹œ๊ฐ„(ms/im)
PyTorch โœ… 6.2 0.6381 508.61
TorchScript โœ… 12.4 0.6092 558.38
ONNX โœ… 12.2 0.6092 198.69
OpenVINO โœ… 12.3 0.6092 704.70
TF SavedModel โœ… 30.6 0.6092 367.64
TF GraphDef โœ… 12.3 0.6092 473.22
TF Lite โœ… 12.3 0.6092 380.67
PaddlePaddle โœ… 24.4 0.6092 703.51
NCNN โœ… 12.2 0.6034 94.28
ํ˜•์‹ ์ƒํƒœ ๋””์Šคํฌ ํฌ๊ธฐ(MB) mAP50-95(B) ์ถ”๋ก  ์‹œ๊ฐ„(ms/im)
PyTorch โœ… 21.5 0.6967 969.49
TorchScript โœ… 43.0 0.7136 1110.04
ONNX โœ… 42.8 0.7136 451.37
OpenVINO โœ… 42.9 0.7136 873.51
TF SavedModel โœ… 107.0 0.7136 658.15
TF GraphDef โœ… 42.8 0.7136 946.01
TF Lite โœ… 42.8 0.7136 1013.27
PaddlePaddle โœ… 85.5 0.7136 1560.23
NCNN โœ… 42.7 0.7204 211.26
ํ˜•์‹ ์ƒํƒœ ๋””์Šคํฌ ํฌ๊ธฐ(MB) mAP50-95(B) ์ถ”๋ก  ์‹œ๊ฐ„(ms/im)
PyTorch โœ… 6.2 0.6381 1068.42
TorchScript โœ… 12.4 0.6092 1248.01
ONNX โœ… 12.2 0.6092 560.04
OpenVINO โœ… 12.3 0.6092 534.93
TF SavedModel โœ… 30.6 0.6092 816.50
TF GraphDef โœ… 12.3 0.6092 1007.57
TF Lite โœ… 12.3 0.6092 950.29
PaddlePaddle โœ… 24.4 0.6092 1507.75
NCNN โœ… 12.2 0.6092 414.73
ํ˜•์‹ ์ƒํƒœ ๋””์Šคํฌ ํฌ๊ธฐ(MB) mAP50-95(B) ์ถ”๋ก  ์‹œ๊ฐ„(ms/im)
PyTorch โœ… 21.5 0.6967 2589.58
TorchScript โœ… 43.0 0.7136 2901.33
ONNX โœ… 42.8 0.7136 1436.33
OpenVINO โœ… 42.9 0.7136 1225.19
TF SavedModel โœ… 107.0 0.7136 1770.95
TF GraphDef โœ… 42.8 0.7136 2146.66
TF Lite โœ… 42.8 0.7136 2945.03
PaddlePaddle โœ… 85.5 0.7136 3962.62
NCNN โœ… 42.7 0.7136 1042.39

๊ฒฐ๊ณผ ์žฌํ˜„

๋ชจ๋“  ๋‚ด๋ณด๋‚ด๊ธฐ ํ˜•์‹์—์„œ ์œ„์˜ Ultralytics ๋ฒค์น˜๋งˆํฌ๋ฅผ ์žฌํ˜„ํ•˜๋ ค๋ฉด ๋‹ค์Œ ์ฝ”๋“œ๋ฅผ ์‹คํ–‰ํ•˜์„ธ์š”:

์˜ˆ

from ultralytics import YOLO

# Load a YOLOv8n PyTorch model
model = YOLO("yolov8n.pt")

# Benchmark YOLOv8n speed and accuracy on the COCO8 dataset for all all export formats
results = model.benchmarks(data="coco8.yaml", imgsz=640)
# Benchmark YOLOv8n speed and accuracy on the COCO8 dataset for all all export formats
yolo benchmark model=yolov8n.pt data=coco8.yaml imgsz=640

๋ฒค์น˜๋งˆํ‚น ๊ฒฐ๊ณผ๋Š” ์‹œ์Šคํ…œ์˜ ์ •ํ™•ํ•œ ํ•˜๋“œ์›จ์–ด ๋ฐ ์†Œํ”„ํŠธ์›จ์–ด ๊ตฌ์„ฑ๊ณผ ๋ฒค์น˜๋งˆํฌ๋ฅผ ์‹คํ–‰ํ•  ๋‹น์‹œ ์‹œ์Šคํ…œ์˜ ํ˜„์žฌ ์ž‘์—…๋Ÿ‰์— ๋”ฐ๋ผ ๋‹ฌ๋ผ์งˆ ์ˆ˜ ์žˆ๋‹ค๋Š” ์ ์— ์œ ์˜ํ•˜์„ธ์š”. ๊ฐ€์žฅ ์‹ ๋ขฐํ•  ์ˆ˜ ์žˆ๋Š” ๊ฒฐ๊ณผ๋ฅผ ์–ป์œผ๋ ค๋ฉด ๋งŽ์€ ์ˆ˜์˜ ์ด๋ฏธ์ง€๊ฐ€ ํฌํ•จ๋œ ๋ฐ์ดํ„ฐ ์„ธํŠธ๋ฅผ ์‚ฌ์šฉํ•˜์„ธ์š”. data='coco8.yaml' (4 val images), ordata='coco.yaml'` (5000๊ฐœ val ์ด๋ฏธ์ง€).

๋ผ์ฆˆ๋ฒ ๋ฆฌ ํŒŒ์ด ์นด๋ฉ”๋ผ ์‚ฌ์šฉ

์ปดํ“จํ„ฐ ๋น„์ „ ํ”„๋กœ์ ํŠธ์— ๋ผ์ฆˆ๋ฒ ๋ฆฌ ํŒŒ์ด๋ฅผ ์‚ฌ์šฉํ•  ๋•Œ๋Š” ๊ธฐ๋ณธ์ ์œผ๋กœ ์ถ”๋ก ์„ ์ˆ˜ํ–‰ํ•˜๊ธฐ ์œ„ํ•ด ์‹ค์‹œ๊ฐ„ ๋น„๋””์˜ค ํ”ผ๋“œ๋ฅผ ๊ฐ€์ ธ์™€์•ผ ํ•ฉ๋‹ˆ๋‹ค. ๋ผ์ฆˆ๋ฒ ๋ฆฌํŒŒ์ด์˜ ์˜จ๋ณด๋“œ MIPI CSI ์ปค๋„ฅํ„ฐ๋ฅผ ์‚ฌ์šฉํ•˜๋ฉด ๊ณต์‹ ๋ผ์ฆˆ๋ฒ ๋ฆฌํŒŒ์ด ์นด๋ฉ”๋ผ ๋ชจ๋“ˆ์„ ์—ฐ๊ฒฐํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์ด ๊ฐ€์ด๋“œ์—์„œ๋Š” ๋ผ์ฆˆ๋ฒ ๋ฆฌ ํŒŒ์ด ์นด๋ฉ”๋ผ ๋ชจ๋“ˆ 3์„ ์‚ฌ์šฉํ•ด ๋น„๋””์˜ค ํ”ผ๋“œ๋ฅผ ์ˆ˜์ง‘ํ•˜๊ณ  YOLOv8 ๋ชจ๋ธ์„ ์‚ฌ์šฉํ•ด ์ถ”๋ก ์„ ์ˆ˜ํ–‰ํ–ˆ์Šต๋‹ˆ๋‹ค.

์ฐธ๊ณ 

๋ผ์ฆˆ๋ฒ ๋ฆฌํŒŒ์ด 5๋Š” ๋ผ์ฆˆ๋ฒ ๋ฆฌํŒŒ์ด 4๋ณด๋‹ค ๋” ์ž‘์€ CSI ์ปค๋„ฅํ„ฐ๋ฅผ ์‚ฌ์šฉํ•˜๋ฏ€๋กœ(15ํ•€ ๋Œ€ 22ํ•€), ๋ผ์ฆˆ๋ฒ ๋ฆฌํŒŒ์ด ์นด๋ฉ”๋ผ์— ์—ฐ๊ฒฐํ•˜๋ ค๋ฉด 15ํ•€ ๋Œ€ 22ํ•€ ์–ด๋Œ‘ํ„ฐ ์ผ€์ด๋ธ”์ด ํ•„์š”ํ•ฉ๋‹ˆ๋‹ค.

์นด๋ฉ”๋ผ ํ…Œ์ŠคํŠธ

์นด๋ฉ”๋ผ๋ฅผ ๋ผ์ฆˆ๋ฒ ๋ฆฌํŒŒ์ด์— ์—ฐ๊ฒฐํ•œ ํ›„ ๋‹ค์Œ ๋ช…๋ น์„ ์‹คํ–‰ํ•ฉ๋‹ˆ๋‹ค. ์•ฝ 5์ดˆ ๋™์•ˆ ์นด๋ฉ”๋ผ์˜ ์‹ค์‹œ๊ฐ„ ๋น„๋””์˜ค ํ”ผ๋“œ๊ฐ€ ํ‘œ์‹œ๋ฉ๋‹ˆ๋‹ค.

rpicam-hello

์นด๋ฉ”๋ผ๋กœ ์ถ”๋ก ํ•˜๊ธฐ

๋ผ์ฆˆ๋ฒ ๋ฆฌ ํŒŒ์ด ์นด๋ฉ”๋ผ๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ YOLOv8 ๋ชจ๋ธ์„ ์ถ”๋ก ํ•˜๋Š” ๋ฐฉ๋ฒ•์—๋Š” ๋‘ ๊ฐ€์ง€๊ฐ€ ์žˆ์Šต๋‹ˆ๋‹ค.

์‚ฌ์šฉ๋ฒ•

๋‹ค์Œ์„ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. picamera2์นด๋ฉ”๋ผ ๋ฐ ์ถ”๋ก  YOLOv8 ๋ชจ๋ธ์— ์•ก์„ธ์Šคํ•˜๊ธฐ ์œ„ํ•ด ๋ผ์ฆˆ๋ฒ ๋ฆฌ ํŒŒ์ด OS๊ฐ€ ์‚ฌ์ „ ์„ค์น˜๋˜์–ด ์ œ๊ณต๋ฉ๋‹ˆ๋‹ค.

์˜ˆ

import cv2
from picamera2 import Picamera2

from ultralytics import YOLO

# Initialize the Picamera2
picam2 = Picamera2()
picam2.preview_configuration.main.size = (1280, 720)
picam2.preview_configuration.main.format = "RGB888"
picam2.preview_configuration.align()
picam2.configure("preview")
picam2.start()

# Load the YOLOv8 model
model = YOLO("yolov8n.pt")

while True:
    # Capture frame-by-frame
    frame = picam2.capture_array()

    # Run YOLOv8 inference on the frame
    results = model(frame)

    # Visualize the results on the frame
    annotated_frame = results[0].plot()

    # Display the resulting frame
    cv2.imshow("Camera", annotated_frame)

    # Break the loop if 'q' is pressed
    if cv2.waitKey(1) == ord("q"):
        break

# Release resources and close windows
cv2.destroyAllWindows()

๋‹ค์Œ์„ ์‚ฌ์šฉํ•˜์—ฌ TCP ์ŠคํŠธ๋ฆผ์„ ์‹œ์ž‘ํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. rpicam-vid ๋ฅผ ์—ฐ๊ฒฐํ•˜์—ฌ ๋‚˜์ค‘์— ์ถ”๋ก ํ•  ๋•Œ ์ด ์ŠคํŠธ๋ฆผ URL์„ ์ž…๋ ฅ์œผ๋กœ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋„๋ก ํ•ฉ๋‹ˆ๋‹ค. ๋‹ค์Œ ๋ช…๋ น์„ ์‹คํ–‰ํ•˜์—ฌ TCP ์ŠคํŠธ๋ฆผ์„ ์‹œ์ž‘ํ•ฉ๋‹ˆ๋‹ค.

rpicam-vid -n -t 0 --inline --listen -o tcp://127.0.0.1:8888

์ž์„ธํžˆ ์•Œ์•„๋ณด๊ธฐ rpicam-vid ๊ณต์‹ ๋ผ์ฆˆ๋ฒ ๋ฆฌ ํŒŒ์ด ๋ฌธ์„œ์—์„œ ์‚ฌ์šฉ ๋ฐฉ๋ฒ•

์˜ˆ

from ultralytics import YOLO

# Load a YOLOv8n PyTorch model
model = YOLO("yolov8n.pt")

# Run inference
results = model("tcp://127.0.0.1:8888")
yolo predict model=yolov8n.pt source="tcp://127.0.0.1:8888"

ํŒ

์ด๋ฏธ์ง€/๋น„๋””์˜ค ์ž…๋ ฅ ์œ ํ˜•์„ ๋ณ€๊ฒฝํ•˜๋ ค๋ฉด ์ถ”๋ก  ์†Œ์Šค์— ๋Œ€ํ•œ ๋ฌธ์„œ๋ฅผ ํ™•์ธํ•˜์„ธ์š”.

๋ผ์ฆˆ๋ฒ ๋ฆฌ ํŒŒ์ด ์‚ฌ์šฉ ์‹œ ๋ชจ๋ฒ” ์‚ฌ๋ก€

YOLOv8 ์„ ์‹คํ–‰ํ•˜๋Š” ๋ผ์ฆˆ๋ฒ ๋ฆฌ ํŒŒ์ด์—์„œ ์„ฑ๋Šฅ์„ ๊ทน๋Œ€ํ™”ํ•˜๊ธฐ ์œ„ํ•ด ๋”ฐ๋ผ์•ผ ํ•  ๋ช‡ ๊ฐ€์ง€ ๋ชจ๋ฒ” ์‚ฌ๋ก€๊ฐ€ ์žˆ์Šต๋‹ˆ๋‹ค.

  1. SSD ์‚ฌ์šฉ

    ๋ผ์ฆˆ๋ฒ ๋ฆฌํŒŒ์ด๋ฅผ 24์‹œ๊ฐ„ ๋‚ด๋‚ด ๊ณ„์† ์‚ฌ์šฉํ•˜๋Š” ๊ฒฝ์šฐ, SD ์นด๋“œ๋Š” ์ง€์†์ ์ธ ์“ฐ๊ธฐ๋ฅผ ๊ฒฌ๋””์ง€ ๋ชปํ•˜๊ณ  ํŒŒ์†๋  ์ˆ˜ ์žˆ์œผ๋ฏ€๋กœ ์‹œ์Šคํ…œ์šฉ์œผ๋กœ SSD๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ๊ฒƒ์ด ์ข‹์Šต๋‹ˆ๋‹ค. ๋ผ์ฆˆ๋ฒ ๋ฆฌํŒŒ์ด 5์˜ ์˜จ๋ณด๋“œ PCIe ์ปค๋„ฅํ„ฐ๋ฅผ ํ†ตํ•ด ์ด์ œ ๋ผ์ฆˆ๋ฒ ๋ฆฌํŒŒ์ด 5์šฉ NVMe ๋ฒ ์ด์Šค์™€ ๊ฐ™์€ ์–ด๋Œ‘ํ„ฐ๋ฅผ ์‚ฌ์šฉํ•ด SSD๋ฅผ ์—ฐ๊ฒฐํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

  2. GUI ์—†๋Š” ํ”Œ๋ž˜์‹œ

    ๋ผ์ฆˆ๋ฒ ๋ฆฌ ํŒŒ์ด OS๋ฅผ ํ”Œ๋ž˜์‹œํ•  ๋•Œ ๋ฐ์Šคํฌํ†ฑ ํ™˜๊ฒฝ(๋ผ์ฆˆ๋ฒ ๋ฆฌ ํŒŒ์ด OS ๋ผ์ดํŠธ)์„ ์„ค์น˜ํ•˜์ง€ ์•Š๋„๋ก ์„ ํƒํ•  ์ˆ˜ ์žˆ์œผ๋ฉฐ, ์ด๋ ‡๊ฒŒ ํ•˜๋ฉด ์žฅ์น˜์˜ RAM์„ ์•ฝ๊ฐ„ ์ ˆ์•ฝํ•˜์—ฌ ์ปดํ“จํ„ฐ ๋น„์ „ ์ฒ˜๋ฆฌ๋ฅผ ์œ„ํ•œ ๊ณต๊ฐ„์„ ๋” ๋งŽ์ด ํ™•๋ณดํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

๋‹ค์Œ ๋‹จ๊ณ„

๋ผ์ฆˆ๋ฒ ๋ฆฌํŒŒ์ด์— YOLO ๋ฅผ ์„ฑ๊ณต์ ์œผ๋กœ ์„ค์น˜ํ•˜์‹  ๊ฒƒ์„ ์ถ•ํ•˜๋“œ๋ฆฝ๋‹ˆ๋‹ค! ์ถ”๊ฐ€ ํ•™์Šต ๋ฐ ์ง€์›์€ Ultralytics YOLOv8 ๋ฌธ์„œ ๋ฐ ์นด์Šˆ๋ฏธ๋ฅด ์›”๋“œ ์žฌ๋‹จ์„ ์ฐธ์กฐํ•˜์„ธ์š”.

๊ฐ์‚ฌ ๋ฐ ์ธ์šฉ

์ด ๊ฐ€์ด๋“œ๋Š” ๋ฉธ์ข… ์œ„๊ธฐ ์ข… ๋ณด์กด์„ ์œ„ํ•ด YOLO ์„ ์‚ฌ์šฉํ•˜๋Š” ๋‹จ์ฒด์ธ ์นด์Šˆ๋ฏธ๋ฅด ์›”๋“œ ์žฌ๋‹จ์„ ์œ„ํ•ด ๋‹ค์•ˆ ์—˜ํŒ…ํฌ๊ฐ€ ์ฒ˜์Œ์— ๋งŒ๋“ค์—ˆ์Šต๋‹ˆ๋‹ค. ๋ฌผ์ฒด ๊ฐ์ง€ ๊ธฐ์ˆ  ๋ถ„์•ผ์—์„œ ์„ ๊ตฌ์ ์ธ ์ž‘์—…๊ณผ ๊ต์œก์— ์ค‘์ ์„ ๋‘” ์ด ๋‹จ์ฒด์˜ ๊ณต๋กœ๋ฅผ ์ธ์ •ํ•ฉ๋‹ˆ๋‹ค.

์นด์Šˆ๋ฏธ๋ฅด ์›”๋“œ ์žฌ๋‹จ์˜ ํ™œ๋™์— ๋Œ€ํ•œ ์ž์„ธํ•œ ๋‚ด์šฉ์€ ์›น์‚ฌ์ดํŠธ์—์„œ ํ™•์ธํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.



Created 2023-11-12, Updated 2024-06-10
Authors: glenn-jocher (7), IvorZhu331 (1), lakshanthad (2)

๋Œ“๊ธ€