반응형
- 데이터는 roboflow 사용
- 최종결과 확인 및 정리
- 사용할 데이터셋 세포 데이터셋
Yolo v3 가져오기
!git clone https://github.com/ultralytics/yolov3 # clone
%cd yolov3
%pip install -qr requirements.txt # install
import torch
from yolov3 import utils
display = utils.notebook_init() # checks
>> YOLOv3 🚀 v9.6.0-21-g92c3bd7 torch 1.12.0+cu113 CUDA:0 (Tesla P100-PCIE-16GB, 16281MiB) Setup complete ✅
- yolo v3 종속성 패키지 설치
%pip install -qr requirements.txt
데이터셋 다운
- roboflow 데이터셋 format yolov5 와 같은걸로 설정
import os
os.mkdir('new_data')
os.chdir('new_data')
!curl -L "https://public.roboflow.com/ds/LiqNCw2nxu?key=JGcsrO8gpA" > roboflow.zip; unzip roboflow.zip; rm roboflow.zip
yaml 파일 확인
os.getcwd()
>> '/content/yolov3/new_data'
import yaml
with open('data.yaml') as f:
yaml_data = yaml.load(f, Loader=yaml.FullLoader)
yaml_data['train'] = './new_data/train/images'
yaml_data['val'] = './new_data/valid/images'
with open('data.yaml', 'w') as f:
yaml.dump(yaml_data, f)
os.chdir('..')
모델 훈련
- 모델은 선택해서 깊은걸 사용 할 수도 있음
!python train.py --img 640 --batch 16 --epochs 30 --data ./new_data/data.yaml --weights yolov3-tiny.pt --cache
TEST 수행
- 저장된 가중치 경로, test 이미지셋 경로
os.getcwd()
>> '/content/yolov3'
!python ./detect.py --weights ./runs/train/exp/weights/best.pt --img 640 --conf 0.25 --line-thickness 1 --source ./new_data/test/images
Yolo v3 모델 결과 확인
from glob import glob
import cv2
from google.colab.patches import cv2_imshow
data_list = glob('./runs/detect/exp/*.jpg')
for i in data_list[:10]:
src = cv2.imread(i)
cv2_imshow(src)
반응형
'DeepLearning > Yolo' 카테고리의 다른 글
YOLOV3 - Ship detection 실습 (2) | 2024.07.23 |
---|---|
YOLOV3 - Cardetection 실습 (2) | 2024.07.23 |