๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ

AIFEEL

YOLOv5 ๋ฌด์ž‘์ • ๋Œ๋ฆฌ๊ธฐ

https://github.com/ultralytics/yolov5

 

GitHub - ultralytics/yolov5: YOLOv5 ๐Ÿš€ in PyTorch > ONNX > CoreML > TFLite

YOLOv5 ๐Ÿš€ in PyTorch > ONNX > CoreML > TFLite. Contribute to ultralytics/yolov5 development by creating an account on GitHub.

github.com

 

 

GitHub - ultralytics/yolov5: YOLOv5 ๐Ÿš€ in PyTorch > ONNX > CoreML > TFLite

YOLOv5 ๐Ÿš€ in PyTorch > ONNX > CoreML > TFLite. Contribute to ultralytics/yolov5 development by creating an account on GitHub.

github.com

 

์•„๋ž˜๋Š” ๋ชจ๋ธ์„ ํ•™์Šต์‹œํ‚ค๊ธฐ ์œ„ํ•ด ์ง์ ‘ ๋Œ๋ฆฐ ์ฝ”๋“œ์ด๋‹ค

 

- (๋ชจ๋ธ ํ•™์Šต์„ ์œ„ํ•œ ์ค€๋น„) ๋ฐ์ดํ„ฐ์…‹ ๊ฒฝ๋กœ ์„ค์ •

cd aiffel
mkdir yolov5
cd yolov5

 

- ํด๋ผ์šฐ๋“œ ์„œ๋ฒ„์˜ yolov5 ํด๋”์— ๋‹ค์šด๋ฐ›์€ zip ํŒŒ์ผ์„ ์˜ฌ๋ฆฐ๋‹ค. (์ฃผํ”ผํ„ฐ ๋…ธํŠธ๋ถ)

unzip yolov5-master.zip
mkdir datasets

- git clone์„ ํ•œ๋‹ค. (๊ตฌ๊ธ€ ์ฝ”๋žฉ)

!git clone https://github.com/ultralytics/yolov5

 

- ํ•„์š”ํ•œ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ ํŒจํ‚ค์ง€๋ฅผ ์„ค์น˜ํ•œ๋‹ค.

!cd yolov5;pip install -qr requirements.txt

- ๋ชจ๋ธ์„ ๋Œ๋ ค๋ณด์ž!

!cd /content/yolov5; python train.py --img 640 --batch 16 --epochs 70 --data /content/drive/MyDrive/aiffel_hackathon/trainNvalid/book_spine.yaml --weights yolov5m.pt \
                                     --project=/content/drive/MyDrive/aiffel_hackathon/model --name epoch70_batch16 --exist-ok

 

-- data : yaml ํŒŒ์ผ ๊ฒฝ๋กœ

-- project : ํŒŒ์ผ ์ €์žฅํ•  ๊ฒฝ๋กœ

-- weights : ๊ฐ€์ค‘์น˜ ๊ฒฝ๋กœ์ด๋‚˜, yolo์—์„œ ๊ธฐ๋ณธ์ ์œผ๋กœ ์ œ๊ณตํ•˜๋Š” ๊ฐ€์ค‘์น˜ ์‚ฌ์šฉ๊ฐ€๋Šฅ

-- projects : ๊ฒฐ๊ณผ๋ฅผ ์ €์žฅํ•  ํ”„๋กœ์ ํŠธ ๊ฒฝ๋กœ์ด๋‹ค.

-- name : ์ €์žฅํ•  ํ”„๋กœ์ ํŠธ ์ด๋ฆ„

 

def parse_opt():
    parser = argparse.ArgumentParser()
    parser.add_argument('--weights', nargs='+', type=str, default=ROOT / 'yolov5s.pt', help='model path(s)')
    parser.add_argument('--source', type=str, default=ROOT / 'data/images', help='file/dir/URL/glob, 0 for webcam')
    parser.add_argument('--data', type=str, default=ROOT / 'data/coco128.yaml', help='(optional) dataset.yaml path')
    parser.add_argument('--imgsz', '--img', '--img-size', nargs='+', type=int, default=[640], help='inference size h,w')
    parser.add_argument('--conf-thres', type=float, default=0.25, help='confidence threshold')
    parser.add_argument('--iou-thres', type=float, default=0.45, help='NMS IoU threshold')
    parser.add_argument('--max-det', type=int, default=1000, help='maximum detections per image')
    parser.add_argument('--device', default='', help='cuda device, i.e. 0 or 0,1,2,3 or cpu')
    parser.add_argument('--view-img', action='store_true', help='show results')
    parser.add_argument('--save-txt', action='store_true', help='save results to *.txt')
    parser.add_argument('--save-conf', action='store_true', help='save confidences in --save-txt labels')
    parser.add_argument('--save-crop', action='store_true', help='save cropped prediction boxes')
    parser.add_argument('--nosave', action='store_true', help='do not save images/videos')
    parser.add_argument('--classes', nargs='+', type=int, help='filter by class: --classes 0, or --classes 0 2 3')
    parser.add_argument('--agnostic-nms', action='store_true', help='class-agnostic NMS')
    parser.add_argument('--augment', action='store_true', help='augmented inference')
    parser.add_argument('--visualize', action='store_true', help='visualize features')
    parser.add_argument('--update', action='store_true', help='update all models')
    parser.add_argument('--project', default=ROOT / 'runs/detect', help='save results to project/name')
    parser.add_argument('--name', default='exp', help='save results to project/name')
    parser.add_argument('--exist-ok', action='store_true', help='existing project/name ok, do not increment')
    parser.add_argument('--line-thickness', default=3, type=int, help='bounding box thickness (pixels)')
    parser.add_argument('--hide-labels', default=False, action='store_true', help='hide labels')
    parser.add_argument('--hide-conf', default=False, action='store_true', help='hide confidences')
    parser.add_argument('--half', action='store_true', help='use FP16 half-precision inference')
    parser.add_argument('--dnn', action='store_true', help='use OpenCV DNN for ONNX inference')
    opt = parser.parse_args()
    opt.imgsz *= 2 if len(opt.imgsz) == 1 else 1  # expand
    print_args(FILE.stem, opt)
    return opt

 

์œ„์™€ ๊ฐ™์€ ๋‹ค์–‘ํ•œ ์˜ต์…˜์„ ์ ์šฉํ•˜๋ฉด ์›๋ณธ ์ฝ”๋“œ ์ˆ˜์ • ์—†์ด ํ™œ์šฉ ๊ฐ€๋Šฅํ•˜๋‹ค.

 

 


Object Detection์˜ ๋‹ค์–‘ํ•œ ํ‰๊ฐ€์ง€ํ‘œ : 

https://fuxxy.tistory.com/22

 

Object Detection์˜ ํ‰๊ฐ€์ง€ํ‘œ

Object Detection์„ ํ™œ์šฉํ•œ ํ”„๋กœ์ ํŠธ๋ฅผ ์ง„ํ–‰ํ•˜์˜€์Šต๋‹ˆ๋‹ค.  ์ด ๊ณผ์ •์—์„œ ๋‹ค์–‘ํ•œ ํ‰๊ฐ€์ง€ํ‘œ๋“ค์„ ์ฐพ์•„๋ณด์•˜์Šต๋‹ˆ๋‹ค. 1. IoU(Intersection over Union) ๋ชจ๋ธ์ด ์˜ˆ์ธกํ•œ bbox์™€ ์‹ค์ œ bbox๊ฐ€ ์–ผ๋งˆ๋‚˜ ๊ฒน์น˜๋Š”์ง€ ๋‚˜ํƒ€๋‚ด๋Š” ์ง€

fuxxy.tistory.com