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

๋ชจ๋ธ ์•™์ƒ๋ธ”

์ด ๊ฐ€์ด๋“œ์—์„œ๋Š” ํ…Œ์ŠคํŠธ ๋ฐ ์ถ”๋ก  ์ค‘ YOLOv5 ๐Ÿš€ ๋ชจ๋ธ ์กฐํ•ฉ์„ ์‚ฌ์šฉํ•˜์—ฌ mAP ๋ฐ ๋ฆฌ์ฝœ์„ ๊ฐœ์„ ํ•˜๋Š” ๋ฐฉ๋ฒ•์„ ์„ค๋ช…ํ•ฉ๋‹ˆ๋‹ค.

์ถœ์ฒ˜: https: //en.wikipedia.org/wiki/Ensemble_learning:

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

์‹œ์ž‘ํ•˜๊ธฐ ์ „์—

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

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

์ •์ƒ์ ์œผ๋กœ ํ…Œ์ŠคํŠธ

์–ด์…ˆ๋ธ”ํ•˜๊ธฐ ์ „์— ๋‹จ์ผ ๋ชจ๋ธ์˜ ๊ธฐ์ค€ ์„ฑ๋Šฅ์„ ์„ค์ •ํ•˜๊ณ  ์‹ถ์Šต๋‹ˆ๋‹ค. ์ด ๋ช…๋ น์€ ์ด๋ฏธ์ง€ ํฌ๊ธฐ 640ํ”ฝ์…€์˜ COCO val2017์—์„œ YOLOv5x๋ฅผ ํ…Œ์ŠคํŠธํ•ฉ๋‹ˆ๋‹ค. yolov5x.pt ์€ ๊ฐ€์žฅ ํฌ๊ณ  ์ •ํ™•ํ•œ ๋ชจ๋ธ์ž…๋‹ˆ๋‹ค. ๋‹ค๋ฅธ ์˜ต์…˜์€ ๋‹ค์Œ๊ณผ ๊ฐ™์Šต๋‹ˆ๋‹ค. yolov5s.pt, yolov5m.pt ๊ทธ๋ฆฌ๊ณ  yolov5l.pt๋˜๋Š” ์‚ฌ์šฉ์ž ์ง€์ • ๋ฐ์ดํ„ฐ ์„ธํŠธ ํ•™์Šต์—์„œ ์–ป์€ ์ž์ฒด ์ฒดํฌํฌ์ธํŠธ ./weights/best.pt. ์‚ฌ์šฉ ๊ฐ€๋Šฅํ•œ ๋ชจ๋“  ๋ชจ๋ธ์— ๋Œ€ํ•œ ์ž์„ธํ•œ ๋‚ด์šฉ์€ README๋ฅผ ์ฐธ์กฐํ•˜์„ธ์š”. ํ…Œ์ด๋ธ”.

python val.py --weights yolov5x.pt --data coco.yaml --img 640 --half

์ถœ๋ ฅ:

val: data=./data/coco.yaml, weights=['yolov5x.pt'], batch_size=32, imgsz=640, conf_thres=0.001, iou_thres=0.65, task=val, device=, single_cls=False, augment=False, verbose=False, save_txt=False, save_hybrid=False, save_conf=False, save_json=True, project=runs/val, name=exp, exist_ok=False, half=True
YOLOv5 ๐Ÿš€ v5.0-267-g6a3ee7c torch 1.9.0+cu102 CUDA:0 (Tesla P100-PCIE-16GB, 16280.875MB)

Fusing layers...
Model Summary: 476 layers, 87730285 parameters, 0 gradients

val: Scanning '../datasets/coco/val2017' images and labels...4952 found, 48 missing, 0 empty, 0 corrupted: 100% 5000/5000 [00:01<00:00, 2846.03it/s]
val: New cache created: ../datasets/coco/val2017.cache
               Class     Images     Labels          P          R     mAP@.5 mAP@.5:.95: 100% 157/157 [02:30<00:00,  1.05it/s]
                 all       5000      36335      0.746      0.626       0.68       0.49
Speed: 0.1ms pre-process, 22.4ms inference, 1.4ms NMS per image at shape (32, 3, 640, 640)  # <--- baseline speed

Evaluating pycocotools mAP... saving runs/val/exp/yolov5x_predictions.json...
...
 Average Precision  (AP) @[ IoU=0.50:0.95 | area=   all | maxDets=100 ] = 0.504  # <--- baseline mAP
 Average Precision  (AP) @[ IoU=0.50      | area=   all | maxDets=100 ] = 0.688
 Average Precision  (AP) @[ IoU=0.75      | area=   all | maxDets=100 ] = 0.546
 Average Precision  (AP) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.351
 Average Precision  (AP) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.551
 Average Precision  (AP) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.644
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=   all | maxDets=  1 ] = 0.382
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=   all | maxDets= 10 ] = 0.628
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=   all | maxDets=100 ] = 0.681  # <--- baseline mAR
 Average Recall     (AR) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.524
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.735
 Average Recall     (AR) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.826

์•™์ƒ๋ธ” ํ…Œ์ŠคํŠธ

์‚ฌ์ „ ํ•™์Šต๋œ ์—ฌ๋Ÿฌ ๋ชจ๋ธ์„ ํ…Œ์ŠคํŠธ ๋ฐ ์ถ”๋ก  ์‹œ์ ์— ์ถ”๊ฐ€ ๋ชจ๋ธ์„ ์ถ”๊ฐ€ํ•˜์—ฌ ํ•จ๊ป˜ ์กฐํ•ฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. --weights ์ธ์ˆ˜๋ฅผ ์ถ”๊ฐ€ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์ด ์˜ˆ์—์„œ๋Š” ๋‘ ๋ชจ๋ธ์˜ ์•™์ƒ๋ธ”์„ ํ•จ๊ป˜ ํ…Œ์ŠคํŠธํ•ฉ๋‹ˆ๋‹ค:

  • YOLOv5x
  • YOLOv5l6
python val.py --weights yolov5x.pt yolov5l6.pt --data coco.yaml --img 640 --half

์ถœ๋ ฅ:

val: data=./data/coco.yaml, weights=['yolov5x.pt', 'yolov5l6.pt'], batch_size=32, imgsz=640, conf_thres=0.001, iou_thres=0.6, task=val, device=, single_cls=False, augment=False, verbose=False, save_txt=False, save_hybrid=False, save_conf=False, save_json=True, project=runs/val, name=exp, exist_ok=False, half=True
YOLOv5 ๐Ÿš€ v5.0-267-g6a3ee7c torch 1.9.0+cu102 CUDA:0 (Tesla P100-PCIE-16GB, 16280.875MB)

Fusing layers...
Model Summary: 476 layers, 87730285 parameters, 0 gradients  # Model 1
Fusing layers...
Model Summary: 501 layers, 77218620 parameters, 0 gradients  # Model 2
Ensemble created with ['yolov5x.pt', 'yolov5l6.pt']  # Ensemble notice

val: Scanning '../datasets/coco/val2017.cache' images and labels... 4952 found, 48 missing, 0 empty, 0 corrupted: 100% 5000/5000 [00:00<00:00, 49695545.02it/s]
               Class     Images     Labels          P          R     mAP@.5 mAP@.5:.95: 100% 157/157 [03:58<00:00,  1.52s/it]
                 all       5000      36335      0.747      0.637      0.692      0.502
Speed: 0.1ms pre-process, 39.5ms inference, 2.0ms NMS per image at shape (32, 3, 640, 640)  # <--- ensemble speed

Evaluating pycocotools mAP... saving runs/val/exp3/yolov5x_predictions.json...
...
 Average Precision  (AP) @[ IoU=0.50:0.95 | area=   all | maxDets=100 ] = 0.515  # <--- ensemble mAP
 Average Precision  (AP) @[ IoU=0.50      | area=   all | maxDets=100 ] = 0.699
 Average Precision  (AP) @[ IoU=0.75      | area=   all | maxDets=100 ] = 0.557
 Average Precision  (AP) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.356
 Average Precision  (AP) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.563
 Average Precision  (AP) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.668
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=   all | maxDets=  1 ] = 0.387
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=   all | maxDets= 10 ] = 0.638
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=   all | maxDets=100 ] = 0.689  # <--- ensemble mAR
 Average Recall     (AR) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.526
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.743
 Average Recall     (AR) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.844

์•™์ƒ๋ธ” ์ถ”๋ก 

์ถ”๊ฐ€ ๋ชจ๋ธ์„ ์ถ”๊ฐ€ํ•ฉ๋‹ˆ๋‹ค. --weights ์ธ์ˆ˜๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์•™์ƒ๋ธ” ์ถ”๋ก ์„ ์‹คํ–‰ํ•ฉ๋‹ˆ๋‹ค:

python detect.py --weights yolov5x.pt yolov5l6.pt --img 640 --source data/images

์ถœ๋ ฅ:

YOLOv5 ๐Ÿš€ v5.0-267-g6a3ee7c torch 1.9.0+cu102 CUDA:0 (Tesla P100-PCIE-16GB, 16280.875MB)

Fusing layers...
Model Summary: 476 layers, 87730285 parameters, 0 gradients
Fusing layers...
Model Summary: 501 layers, 77218620 parameters, 0 gradients
Ensemble created with ['yolov5x.pt', 'yolov5l6.pt']

image 1/2 /content/yolov5/data/images/bus.jpg: 640x512 4 persons, 1 bus, 1 tie, Done. (0.063s)
image 2/2 /content/yolov5/data/images/zidane.jpg: 384x640 3 persons, 2 ties, Done. (0.056s)
Results saved to runs/detect/exp2
Done. (0.223s)

YOLO ์ถ”๋ก  ๊ฒฐ๊ณผ

์ง€์› ํ™˜๊ฒฝ

Ultralytics ๋Š” ๋ฐ”๋กœ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋Š” ๋‹ค์–‘ํ•œ ํ™˜๊ฒฝ์„ ์ œ๊ณตํ•˜๋ฉฐ, ๊ฐ ํ™˜๊ฒฝ์—๋Š” CUDA, CUDNN๊ณผ ๊ฐ™์€ ํ•„์ˆ˜ ์ข…์†์„ฑ์ด ์‚ฌ์ „ ์„ค์น˜๋˜์–ด ์žˆ์Šต๋‹ˆ๋‹ค, Python๋ฐ PyTorch์™€ ๊ฐ™์€ ํ•„์ˆ˜ ์ข…์† ์š”์†Œ๊ฐ€ ์‚ฌ์ „ ์„ค์น˜๋˜์–ด ์žˆ์–ด ํ”„๋กœ์ ํŠธ๋ฅผ ์‹œ์ž‘ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

ํ”„๋กœ์ ํŠธ ์ƒํƒœ

YOLOv5 CI

์ด ๋ฐฐ์ง€๋Š” ๋ชจ๋“  YOLOv5 GitHub Actions ์ง€์†์  ํ†ตํ•ฉ(CI) ํ…Œ์ŠคํŠธ๊ฐ€ ์„ฑ๊ณต์ ์œผ๋กœ ํ†ต๊ณผ๋˜์—ˆ์Œ์„ ๋‚˜ํƒ€๋ƒ…๋‹ˆ๋‹ค. ์ด๋Ÿฌํ•œ CI ํ…Œ์ŠคํŠธ๋Š” ๊ต์œก, ๊ฒ€์ฆ, ์ถ”๋ก , ๋‚ด๋ณด๋‚ด๊ธฐ ๋ฐ ๋ฒค์น˜๋งˆํฌ ๋“ฑ ๋‹ค์–‘ํ•œ ์ฃผ์š” ์ธก๋ฉด์—์„œ YOLOv5 ์˜ ๊ธฐ๋Šฅ๊ณผ ์„ฑ๋Šฅ์„ ์—„๊ฒฉํ•˜๊ฒŒ ํ™•์ธํ•ฉ๋‹ˆ๋‹ค. 24์‹œ๊ฐ„๋งˆ๋‹ค ๊ทธ๋ฆฌ๊ณ  ์ƒˆ๋กœ์šด ์ปค๋ฐ‹์ด ์žˆ์„ ๋•Œ๋งˆ๋‹ค ํ…Œ์ŠคํŠธ๋ฅผ ์ˆ˜ํ–‰ํ•˜์—ฌ macOS, Windows ๋ฐ Ubuntu์—์„œ ์ผ๊ด€๋˜๊ณ  ์•ˆ์ •์ ์ธ ์ž‘๋™์„ ๋ณด์žฅํ•ฉ๋‹ˆ๋‹ค.



Created 2023-11-12, Updated 2024-06-02
Authors: glenn-jocher (6)

๋Œ“๊ธ€