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

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 ๋ฆด๋ฆฌ์Šค์—์„œ ๋ชจ๋ธ์„ ์›ํ™œํ•˜๊ฒŒ ๋‹ค์šด๋กœ๋“œํ•  ์ˆ˜ ์žˆ๋Š” YOLOv5 PyTorch ํ—ˆ๋ธŒ ์ถ”๋ก ์˜ ๊ฐ„ํŽธํ•จ์„ ๊ฒฝํ—˜ํ•ด ๋ณด์„ธ์š”.

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
                                               image.jpg                       # image
                                               video.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 ์˜ ๊ฒฝ์ด๋กœ์›€์„ ์ฆ๊ฒจ๋ณด์„ธ์š”. ํ–‰๋ณตํ•œ ํƒํ—˜์ด ๋˜์„ธ์š”! ๐ŸŒ ๐Ÿ”

๐Ÿ“…1 ๋…„ ์ „ ์ƒ์„ฑ๋จ โœ๏ธ 2๊ฐœ์›” ์ „ ์—…๋ฐ์ดํŠธ๋จ

๋Œ“๊ธ€