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

YOLOv5 ๋น ๋ฅธ ์‹œ์ž‘ ๐Ÿš€

YOLOv5 ์œผ๋กœ ์‹ค์‹œ๊ฐ„ ๊ฐ์ฒด ๊ฐ์ง€์˜ ์—ญ๋™์ ์ธ ์˜์—ญ์œผ๋กœ ์—ฌํ–‰์„ ๋– ๋‚˜๋ณด์„ธ์š”! ์ด ๊ฐ€์ด๋“œ๋Š” YOLOv5 ์„ ๋งˆ์Šคํ„ฐํ•˜๊ณ ์ž ํ•˜๋Š” AI ์• ํ˜ธ๊ฐ€์™€ ์ „๋ฌธ๊ฐ€๋ฅผ ์œ„ํ•œ ์ข…ํ•ฉ์ ์ธ ์ถœ๋ฐœ์ ์ด ๋  ์ˆ˜ ์žˆ๋„๋ก ์ œ์ž‘๋˜์—ˆ์Šต๋‹ˆ๋‹ค. ์ดˆ๊ธฐ ์„ค์ •๋ถ€ํ„ฐ ๊ณ ๊ธ‰ ํ›ˆ๋ จ ๊ธฐ๋ฒ•๊นŒ์ง€ ๋ชจ๋“  ๊ฒƒ์„ ๋‹ค๋ฃน๋‹ˆ๋‹ค. ์ด ๊ฐ€์ด๋“œ๊ฐ€ ๋๋‚˜๋ฉด ํ”„๋กœ์ ํŠธ์— YOLOv5 ์„ ์ž์‹  ์žˆ๊ฒŒ ๊ตฌํ˜„ํ•  ์ˆ˜ ์žˆ๋Š” ์ง€์‹์„ ๊ฐ–์ถ”๊ฒŒ ๋  ๊ฒƒ์ž…๋‹ˆ๋‹ค. ์ด์ œ ์—”์ง„์— ๋ถˆ์„ ๋ถ™์ด๊ณ  YOLOv5 ๋กœ ๋‚ ์•„์˜ค๋ฅด์„ธ์š”!

์„ค์น˜

๋ฆฌํฌ์ง€ํ† ๋ฆฌ๋ฅผ ๋ณต์ œํ•˜๊ณ  ํ™˜๊ฒฝ์„ ์„ค์ •ํ•˜์—ฌ ์ถœ์‹œ๋ฅผ ์ค€๋น„ํ•ฉ๋‹ˆ๋‹ค. ์ด๋ ‡๊ฒŒ ํ•˜๋ฉด ํ•„์š”ํ•œ ๋ชจ๋“  ์š”๊ตฌ ์‚ฌํ•ญ์ด ์„ค์น˜๋ฉ๋‹ˆ๋‹ค. ๋‹ค์Œ ์‚ฌํ•ญ์„ ํ™•์ธํ•˜์„ธ์š”. Python>=3.8.0 ๋ฐ PyTorch>=1.8 ์ด ์ค€๋น„๋˜์—ˆ๋Š”์ง€ ํ™•์ธํ•ฉ๋‹ˆ๋‹ค.

git clone https://github.com/ultralytics/yolov5  # clone repository
cd yolov5
pip install -r requirements.txt  # install dependencies

๋ฅผ ์‚ฌ์šฉํ•œ ์ถ”๋ก  PyTorch Hub

์ถ”๋ก ์˜ ๋‹จ์ˆœํ•จ์„ ๊ฒฝํ—˜ํ•˜์„ธ์š”. YOLOv5 PyTorch Hub ์ถ”๋ก ์˜ ๋‹จ์ˆœํ•จ์„ ๊ฒฝํ—˜ํ•˜์„ธ์š”. YOLOv5 ๋ฆด๋ฆฌ์Šค์—์„œ ๋ชจ๋ธ์„ ์›ํ™œํ•˜๊ฒŒ ๋‹ค์šด๋กœ๋“œํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

import torch

# Model loading
model = torch.hub.load("ultralytics/yolov5", "yolov5s")  # Can be 'yolov5n' - 'yolov5x6', or 'custom'

# Inference on images
img = "https://ultralytics.com/images/zidane.jpg"  # Can be a file, Path, PIL, OpenCV, numpy, or list of images

# Run inference
results = model(img)

# Display results
results.print()  # Other options: .show(), .save(), .crop(), .pandas(), etc.

detect.py๋ฅผ ์‚ฌ์šฉํ•œ ์ถ”๋ก 

ํ•˜๋„ค์Šค detect.py ๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ๋‹ค์–‘ํ•œ ์†Œ์Šค์— ๋Œ€ํ•œ ๋‹ค์–‘ํ•œ ์ถ”๋ก ์„ ์ˆ˜ํ–‰ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์ž๋™์œผ๋กœ ๋‹ค์Œ์„ ๊ฐ€์ ธ์˜ต๋‹ˆ๋‹ค. ๋ชจ๋ธ ์—์„œ ์ตœ์‹  YOLOv5 ๋ฆด๋ฆฌ์Šค ๋ฅผ ํด๋ฆญํ•˜๊ณ  ๊ฒฐ๊ณผ๋ฅผ ์‰ฝ๊ฒŒ ์ €์žฅํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

python detect.py --weights yolov5s.pt --source 0                               # webcam
                                               img.jpg                         # image
                                               vid.mp4                         # video
                                               screen                          # screenshot
                                               path/                           # directory
                                               list.txt                        # list of images
                                               list.streams                    # list of streams
                                               'path/*.jpg'                    # glob
                                               'https://youtu.be/LNwODJXcvt4'  # YouTube
                                               'rtsp://example.com/media.mp4'  # RTSP, RTMP, HTTP stream

๊ต์œก

๋ณต์ œ YOLOv5 COCO ๋ฒค์น˜๋งˆํฌ์— ๋Œ€ํ•œ ์ž์„ธํ•œ ๋‚ด์šฉ์€ ์•„๋ž˜ ์ง€์นจ์„ ์ฐธ์กฐํ•˜์„ธ์š”. ํ•„์š”ํ•œ ๋ชจ๋ธ ๋ฐ ๋ฐ์ดํ„ฐ ์„ธํŠธ ๋Š” ์ตœ์‹  YOLOv5 ๋ฆด๋ฆฌ์Šค. V100 GPU์—์„œ YOLOv5n/s/m/l/x๋ฅผ ํŠธ๋ ˆ์ด๋‹ํ•˜๋Š” ๋ฐ๋Š” ์ผ๋ฐ˜์ ์œผ๋กœ ๊ฐ๊ฐ 1/2/4/6/8์ผ์ด ์†Œ์š”๋ฉ๋‹ˆ๋‹ค. ๋ฉ€ํ‹ฐ GPU ์„ค์ •์ด ๋” ๋น ๋ฅด๊ฒŒ ์ž‘๋™ํ•ฉ๋‹ˆ๋‹ค). ๊ฐ€๋Šฅํ•œ ์ตœ๊ณ  ์ˆ˜์ค€์˜ --batch-size ๋˜๋Š” --batch-size -1 ์— ๋Œ€ํ•œ YOLOv5 ์ž๋™ ๋ฐฐ์น˜ ๊ธฐ๋Šฅ์„ ์‚ฌ์šฉํ•˜์„ธ์š”. ๋‹ค์Œ ๋ฐฐ์น˜ ํฌ๊ธฐ๋Š” V100-16GB GPU์— ์ด์ƒ์ ์ž…๋‹ˆ๋‹ค.

python train.py --data coco.yaml --epochs 300 --weights '' --cfg yolov5n.yaml  --batch-size 128
                                                                 yolov5s                    64
                                                                 yolov5m                    40
                                                                 yolov5l                    24
                                                                 yolov5x                    16

YOLO ํŠธ๋ ˆ์ด๋‹ ๊ณก์„ 

๊ฒฐ๋ก ์ ์œผ๋กœ, YOLOv5 ์€ ๋ฌผ์ฒด ๊ฐ์ง€๋ฅผ ์œ„ํ•œ ์ตœ์ฒจ๋‹จ ๋„๊ตฌ์ผ ๋ฟ๋งŒ ์•„๋‹ˆ๋ผ ์‹œ๊ฐ์  ์ดํ•ด๋ฅผ ํ†ตํ•ด ์„ธ์ƒ๊ณผ ์ƒํ˜ธ์ž‘์šฉํ•˜๋Š” ๋ฐฉ์‹์„ ๋ณ€ํ™”์‹œํ‚ค๋Š” ๋จธ์‹ ๋Ÿฌ๋‹์˜ ํž˜์„ ๋ณด์—ฌ์ฃผ๋Š” ์ฆ๊ฑฐ์ด๊ธฐ๋„ ํ•ฉ๋‹ˆ๋‹ค. ์ด ๊ฐ€์ด๋“œ๋ฅผ ์ง„ํ–‰ํ•˜๋ฉด์„œ ํ”„๋กœ์ ํŠธ์— YOLOv5 ์„ ์ ์šฉํ•˜๊ธฐ ์‹œ์ž‘ํ•  ๋•Œ, ์—ฌ๋Ÿฌ๋ถ„์€ ๋†€๋ผ์šด ์—…์ ์„ ๋‹ฌ์„ฑํ•  ์ˆ˜ ์žˆ๋Š” ๊ธฐ์ˆ  ํ˜๋ช…์˜ ์ตœ์ „์„ ์— ์„œ ์žˆ๋‹ค๋Š” ์‚ฌ์‹ค์„ ๊ธฐ์–ตํ•˜์„ธ์š”. ๋” ๋งŽ์€ ์ธ์‚ฌ์ดํŠธ๋‚˜ ๋™๋ฃŒ ์„ ๊ตฌ์ž๋“ค์˜ ์ง€์›์ด ํ•„์š”ํ•˜๋‹ค๋ฉด, ๋ฒˆ์ฐฝํ•˜๋Š” ๊ฐœ๋ฐœ์ž ๋ฐ ์—ฐ๊ตฌ์ž ์ปค๋ฎค๋‹ˆํ‹ฐ๊ฐ€ ์žˆ๋Š” GitHub ๋ฆฌํฌ์ง€ํ† ๋ฆฌ์— ์ดˆ๋Œ€ํ•ฉ๋‹ˆ๋‹ค. ๊ณ„์† ํƒ์ƒ‰ํ•˜๊ณ , ๊ณ„์† ํ˜์‹ ํ•˜๊ณ , YOLOv5 ์˜ ๊ฒฝ์ด๋กœ์›€์„ ์ฆ๊ธฐ์„ธ์š”. ์ฆ๊ฑฐ์šด ํƒ์‚ฌ ๋˜์„ธ์š”! ๐ŸŒ ๐Ÿ”



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

๋Œ“๊ธ€