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

Docker์—์„œ YOLOv5 ๐Ÿš€๋กœ ์‹œ์ž‘ํ•˜๊ธฐ

์ด ํŠœํ† ๋ฆฌ์–ผ์—์„œ๋Š” Docker ์ปจํ…Œ์ด๋„ˆ์—์„œ YOLOv5 ์„ ์„ค์ •ํ•˜๊ณ  ์‹คํ–‰ํ•˜๋Š” ๊ณผ์ •์„ ์•ˆ๋‚ดํ•ฉ๋‹ˆ๋‹ค.

๋‹ค์Œ๊ณผ ๊ฐ™์€ YOLOv5 ์— ๋Œ€ํ•œ ๋‹ค๋ฅธ ๋น ๋ฅธ ์‹œ์ž‘ ์˜ต์…˜์„ ์‚ดํŽด๋ณผ ์ˆ˜๋„ ์žˆ์Šต๋‹ˆ๋‹ค. ๋žฉ ๋…ธํŠธ๋ถ ๊ณต๋™ ์ž‘์—…์‹ค์—์„œ ์—ด๊ธฐ ์บ๊ธ€์—์„œ ์—ด๊ธฐ, GCP ๋”ฅ ๋Ÿฌ๋‹ VM๋ฐ Amazon AWS.

์ „์ œ ์กฐ๊ฑด

  1. Nvidia ๋“œ๋ผ์ด๋ฒ„: ๋ฒ„์ „ 455.23 ์ด์ƒ. Nvidia ์›น์‚ฌ์ดํŠธ์—์„œ ๋‹ค์šด๋กœ๋“œํ•ฉ๋‹ˆ๋‹ค.
  2. ์—”๋น„๋””์•„-๋„์ปค: Docker๊ฐ€ ๋กœ์ปฌ GPU์™€ ์ƒํ˜ธ ์ž‘์šฉํ•  ์ˆ˜ ์žˆ๋„๋ก ํ•ฉ๋‹ˆ๋‹ค. ์„ค์น˜ ์ง€์นจ์€ Nvidia-Docker GitHub ๋ฆฌํฌ์ง€ํ† ๋ฆฌ์—์„œ ํ™•์ธํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
  3. ๋„์ปค ์—”์ง„ - CE: ๋ฒ„์ „ 19.03 ์ด์ƒ. ๋‹ค์šด๋กœ๋“œ ๋ฐ ์„ค์น˜ ์ง€์นจ์€ Docker ์›น์‚ฌ์ดํŠธ์—์„œ ํ™•์ธํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

1๋‹จ๊ณ„: YOLOv5 ๋„์ปค ์ด๋ฏธ์ง€ ๊ฐ€์ ธ์˜ค๊ธฐ

Ultralytics YOLOv5 ๋„์ปคํ—ˆ๋ธŒ ๋ฆฌํฌ์ง€ํ† ๋ฆฌ๋Š” ๋‹ค์Œ ์ฃผ์†Œ์—์„œ ํ™•์ธํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. https://hub.docker.com/r/ultralytics/yolov5. ๋„์ปค ์ž๋™ ๋นŒ๋“œ๋ฅผ ์‚ฌ์šฉํ•˜๋ฉด ultralytics/yolov5:latest ์ด๋ฏธ์ง€๋Š” ํ•ญ์ƒ ๊ฐ€์žฅ ์ตœ๊ทผ์˜ ๋ฆฌํฌ์ง€ํ† ๋ฆฌ ์ปค๋ฐ‹๊ณผ ๋™๊ธฐํ™”๋ฉ๋‹ˆ๋‹ค. ์ตœ์‹  ์ด๋ฏธ์ง€๋ฅผ ๊ฐ€์ ธ์˜ค๋ ค๋ฉด ๋‹ค์Œ ๋ช…๋ น์„ ์‹คํ–‰ํ•ฉ๋‹ˆ๋‹ค:

sudo docker pull ultralytics/yolov5:latest

2๋‹จ๊ณ„: Docker ์ปจํ…Œ์ด๋„ˆ ์‹คํ–‰ํ•˜๊ธฐ

๊ธฐ๋ณธ ์ปจํ…Œ์ด๋„ˆ:

๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ YOLOv5 ๋„์ปค ์ด๋ฏธ์ง€("์ปจํ…Œ์ด๋„ˆ"๋ผ๊ณ  ํ•จ)์˜ ๋Œ€ํ™”ํ˜• ์ธ์Šคํ„ด์Šค๋ฅผ ์‹คํ–‰ํ•ฉ๋‹ˆ๋‹ค. -it ํ”Œ๋ž˜๊ทธ:

sudo docker run --ipc=host -it ultralytics/yolov5:latest

๋กœ์ปฌ ํŒŒ์ผ ์•ก์„ธ์Šค ๊ถŒํ•œ์ด ์žˆ๋Š” ์ปจํ…Œ์ด๋„ˆ์ž…๋‹ˆ๋‹ค:

๋กœ์ปฌ ํŒŒ์ผ์— ์•ก์„ธ์Šคํ•  ์ˆ˜ ์žˆ๋Š” ์ปจํ…Œ์ด๋„ˆ๋ฅผ ์‹คํ–‰ํ•˜๋ ค๋ฉด(์˜ˆ๋ฅผ ๋“ค์–ด /datasets)๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ -v ํ”Œ๋ž˜๊ทธ:

sudo docker run --ipc=host -it -v "$(pwd)"/datasets:/usr/src/datasets ultralytics/yolov5:latest

GPU ์•ก์„ธ์Šค ๊ถŒํ•œ์ด ์žˆ๋Š” ์ปจํ…Œ์ด๋„ˆ์ž…๋‹ˆ๋‹ค:

GPU ์•ก์„ธ์Šค ๊ถŒํ•œ์œผ๋กœ ์ปจํ…Œ์ด๋„ˆ๋ฅผ ์‹คํ–‰ํ•˜๋ ค๋ฉด --gpus all ํ”Œ๋ž˜๊ทธ:

sudo docker run --ipc=host -it --gpus all ultralytics/yolov5:latest

3๋‹จ๊ณ„: Docker ์ปจํ…Œ์ด๋„ˆ ๋‚ด์—์„œ YOLOv5 ๐Ÿš€ ์‚ฌ์šฉ

์ด์ œ ์‹คํ–‰ ์ค‘์ธ Docker ์ปจํ…Œ์ด๋„ˆ ๋‚ด์—์„œ YOLOv5 ๋ชจ๋ธ์„ ํ•™์Šต, ํ…Œ์ŠคํŠธ, ๊ฐ์ง€ ๋ฐ ๋‚ด๋ณด๋‚ผ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค:

# Train a model on your data
python train.py

# Validate the trained model for Precision, Recall, and mAP
python val.py --weights yolov5s.pt

# Run inference using the trained model on your images or videos
python detect.py --weights yolov5s.pt --source path/to/images

# Export the trained model to other formats for deployment
python export.py --weights yolov5s.pt --include onnx coreml tflite

Docker๋ฅผ ์‹คํ–‰ํ•˜๋Š” GCP



์ƒ์„ฑ๋จ 2023-11-12, ์—…๋ฐ์ดํŠธ๋จ 2023-12-03
์ž‘์„ฑ์ž: glenn-jocher (3)

๋Œ“๊ธ€