참조 : https://learnopencv.com/train-yolov8-on-custom-dataset/

 

Train YOLOv8 on Custom Dataset – A Complete Tutorial

Train YOLOv8 on a custom pothole detection dataset. Training YOLOv8 Nano, Small, & Medium models and running inference for pothole detection on unseen videos.

learnopencv.com

 

파이참을 실행하고 터미널을 열고  학습 데이터를 다운받음 (25G 정도되니 시간이 많이 걸립니다.)

wget https://www.dropbox.com/s/qvglw8pqo16769f/pothole_dataset_v8.zip?dl=1 -O pothole_dataset_v8.zip

 

다운이 완료되면  ultralytics-main\datasets  폴더안에 이동후 해당 파일 이름으로 압축을 해제

 

train \images  

 

프로젝트에서 마우스 오른쪽 버튼을 누르고, New  -> File 

 

아래 이름으로 생성 

pothole_v8.yaml

 

 

 

 

 

아래 내용을 복사후 저장 

path: pothole_dataset_v8/
train: 'train/images'
val: 'valid/images'

# class names
names:
0: 'pothole'

 

훈련을 시킵니다. 

yolo task=detect mode=train model=yolov8n.pt imgsz=1280 data=pothole_v8.yaml epochs=50 batch=8 name=yolov8n_v8_50e

 

시간이.....

 

 

 

 

 

완료가 되면 runs\detect 폴더에 pt 파일이 생성됩니다. . 

 

 

 

 

프로젝트에 복사해주고 모델을 명을 변경해줍니다. 

from ultralytics import YOLO



model = YOLO("best.pt")
results = model.predict(source="0", show=True )

print(results)

 

스마트폰으로 포트홀 사진을 뛰운후 검출이 잘 됩니다. 

 

+ Recent posts