์ ์ ์ด ์์ด์ ์ด์ด์ ์ฐ๋๊ฑธ ๊น๋จน์๋ค์.. ์ด์ฌํ ์จ๋ณด๊ฒ ์ต๋๋ค ใ
Keras YOLO Open source Package ํน์ง
๋ ์ฌ์ด ํ๊ฒฝ ์ค์
- Keras ๊ธฐ๋ฐ์ YOLO ํจํค์ง๋ Darknet YOLO ํ๋ ์์ํฌ์ ๋นํด ํ๊ฒฝ ์ค์ ์ด ๋ ๊ฐ๋จํฉ๋๋ค. Keras๋ Python์ ๊ธฐ๋ฐ์ผ๋ก ํ ๋ฅ๋ฌ๋ ์ํฌํ๋ก์ฐ์ ์ ํตํฉ๋๋ฉฐ, ๋ ์ฌ์ฉ์ ์นํ์ ์ธ ์ธํฐํ์ด์ค๋ฅผ ์ ๊ณตํ์ฌ ๋ค์ํ ์ฌ์ฉ์๊ฐ ์ ๊ทผํ๊ธฐ ์ฝ์ต๋๋ค.
Keras์ Callbacks, TensorBoard, Preprocessing ๊ธฐ๋ฅ ํ์ฉ
- Keras๋ Callbacks ๊ธฐ๋ฅ์ ์ ๊ณตํ์ฌ ํ์ต ๊ณผ์ ์ค์ ๋์ ์ผ๋ก ๋ชจ๋ํฐ๋งํ๊ณ ์กฐ์ ํ ์ ์์ต๋๋ค. ์๋ฅผ ๋ค์ด, ์กฐ๊ธฐ ์ข ๋ฃ(early stopping)๋ ํ์ต ์๋ ์ค์ผ์ค๋ง(learning rate scheduling) ๋ฑ์ ์ค์ ํ ์ ์์ต๋๋ค.
- ๋ํ TensorBoard์์ ํตํฉ์ ํตํด ํ์ต ์ค์ธ ๋ชจ๋ธ์ ์ฑ๋ฅ์ ์ค์๊ฐ์ผ๋ก ์๊ฐํํ ์ ์์ต๋๋ค.
- Keras๋ ๊ฐ๋ ฅํ ๋ด์ฅ Preprocessing ๋๊ตฌ๋ฅผ ์ ๊ณตํ์ฌ YOLO ๋ชจ๋ธ์ ์ํ ๋ฐ์ดํฐ ์ค๋น ๊ณผ์ ์ ๋์ฑ ์ฝ๊ฒ ๋ง๋ค์ด ์ค๋๋ค.
๋ ์ฝ๊ธฐ ์ฌ์ด ์์ค์ฝ๋์ ์์ฌ์ด ์ปค์คํฐ๋ง์ด์ง
- Keras YOLO ํจํค์ง๋ ์ฝ๋๊ฐ ๋ ์ฝ๊ธฐ ์ฝ๊ณ ๋ชจ๋ํ๋์ด ์์ด, ์ฌ์ฉ์๊ฐ ์ดํดํ๊ณ ์์ ํ๊ธฐ ์ฝ์ต๋๋ค. ์ด๋ฅผ ํตํด ํน์ ์์ฉ ํ๋ก๊ทธ๋จ์ ๋ง๊ฒ ๋ชจ๋ธ์ ์กฐ์ ํ๊ฑฐ๋ ์๋ก์ด ๊ธฐ๋ฅ์ ์คํํ๋ ค๋ ๊ฐ๋ฐ์์๊ฒ ์ ๋ฆฌํฉ๋๋ค.
Darknet YOLO (C/C++ ๊ตฌํ) ๋๋น ์ฒ๋ฆฌ ์๋ ๋๋ฆผ
- Keras๋ YOLO๋ฅผ ๋ ์ ๊ทผํ๊ธฐ ์ฝ๊ณ ์ฌ์ฉํ๊ธฐ ํธ๋ฆฌํ๊ฒ ๋ง๋ค์ง๋ง, ์ฒ๋ฆฌ ์๋๋ ์ผ๋ฐ์ ์ผ๋ก ์๋์ C/C++๋ก ๊ตฌํ๋ Darknet YOLO์ ๋นํด ๋๋ฆฝ๋๋ค. ์ด๋ Keras๊ฐ ์ ๊ณตํ๋ ๋์ ์์ค์ ์ถ์ํ๋ก ์ธํ ์ฑ๋ฅ ์ ํ ๋๋ฌธ์ ๋๋ค.
Keras YOLO Open Source Package ์๊ฐ
qqwweee keras-yolo3
GitHub - qqwweee/keras-yolo3: A Keras implementation of YOLOv3 (Tensorflow backend)
A Keras implementation of YOLOv3 (Tensorflow backend) - qqwweee/keras-yolo3
github.com
- ํ์ต ๋ฐ ์ถ๋ก (Inference)์ ๊ฐ๋ฅํ์ง๋ง ํ๊ฐ(Evaluation)๋ฅผ ์ง์ํ์ง ์์.
- VOC, COCO ๊ฐ์ ๋ฐ์ดํฐ์ ์ CSV ํ์์ผ๋ก ๋ณํํ์ฌ ์ ๋ ฅํ ์ ์๋ ๊ธฐ๋ฅ์ ์ง์ํ๋ฉฐ, CSV ํ์์ ๋ฐ์ดํฐ ์ ๋ ฅ์ ๋ฐ์ต๋๋ค.
Experiencor keras-yolo3
GitHub - experiencor/keras-yolo3: Training and Detecting Objects with YOLO3
Training and Detecting Objects with YOLO3. Contribute to experiencor/keras-yolo3 development by creating an account on GitHub.
github.com
- ํ์ต, ์ถ๋ก ๋ฟ๋ง ์๋๋ผ ํ๊ฐ(Evaluation)๋ ๊ฐ๋ฅ.
- ์ ๋ ฅ ๋ฐ์ดํฐ๋ XML ํ์๋ง ์ง์ํ๋ฉฐ, CSV๋ JSON ๋ฐ์ดํฐ๋ฅผ ์ ๋ ฅํ๋ ค๋ฉด XML ํฌ๋งท์ผ๋ก ๋ณํํด์ผ ํฉ๋๋ค.
- ๋ ๊ตฌํ์ฒด์ ์ฃผ์ ์ฐจ์ด์ ์ ํ๊ฐ ๊ธฐ๋ฅ ์ง์ ์ฌ๋ถ์ ๋ฐ์ดํฐ ์ ๋ ฅ ํ์์ ๋๋ค. Experiencor๋ ํ๊ฐ ๊ธฐ๋ฅ์ ์ง์ํ๋ฉฐ XML ํ์์ ์ฌ์ฉํด์ผ ํ๋ ๋ฐ๋ฉด, qqwweee๋ ํ๊ฐ ๊ธฐ๋ฅ์ด ์๊ณ CSV ํ์์ ๊ธฐ๋ณธ์ผ๋ก ์ง์ํฉ๋๋ค.
qqwweee/kears-yolo3 ํจํค์ง ๊ตฌ์ฑ
model_data ํด๋
- YOLO ๋ชจ๋ธ์ ํด๋์ค์ anchor box ์์น ์ค์ ํ์ผ๋ค์ ํฌํจํ๊ณ ์์ต๋๋ค.
- ์๋ฅผ ๋ค์ด, coco_classes.txt, tiny_yolo_anchors.txt, voc_classes.txt, yolo_anchors.txt ํ์ผ๋ค์ด ์กด์ฌํ๋ฉฐ, ๊ฐ๊ฐ COCO์ VOC ๋ฐ์ดํฐ์ ์ ํด๋์ค ๋ฐ YOLO ์ต์ปค ๋ฐ์ค ๊ด๋ จ ์ค์ ๋ค์ ํฌํจํ๊ณ ์์ต๋๋ค.
yolo3 ํด๋
- ์ฃผ์ Backend API๋ค์ด ์๋ ํด๋์ ๋๋ค.
- ์ด ํด๋์๋ __init__.py, model.py, utils.py ํ์ผ์ด ํฌํจ๋์ด ์์ผ๋ฉฐ, YOLO ๋ชจ๋ธ์ ์ฃผ์ ๋ฐฑ์๋ ๋ก์ง๊ณผ ์ ํธ๋ฆฌํฐ ํจ์๋ค์ด ์ ์๋์ด ์์ต๋๋ค.
train.py: YOLO ๋ชจ๋ธ์ ํ์ต์ํค๊ธฐ ์ํ ์ฃผ์ API๋ฅผ ํฌํจํ๊ณ ์์ต๋๋ค. ์ด ์คํฌ๋ฆฝํธ๋ฅผ ํตํด ๋ชจ๋ธ ํ์ต์ ์งํํ ์ ์์ต๋๋ค.
yolo.py: YOLO ๋ชจ๋ธ์ ๋ก๋ฉํ๊ณ ๊ฐ์ฒด ํ์ง(Detection)๋ฅผ ์ํํ๋ ํด๋์ค์ ๊ด๋ จ๋ ํ์ผ์ ๋๋ค.
keras-yolo3 ํจํค์ง๋ฅผ ์ด์ฉํ์ฌ Yolo & tiny Yolo ๊ธฐ๋ฐ์ผ๋ก ์ด๋ฏธ์ง์ ์์ Object Detection
- ๋คํฌ๋ท์์ Pretrained๋ yolo/tiny-yolo weights ๋ชจ๋ธ์ ๋ค์ด๋ก๋ํฉ๋๋ค.
- ๋ค์ด๋ก๋ํ ๋คํฌ๋ท weight ํ์ผ์ ๊ธฐ๋ฐ์ผ๋ก keras-yolo3์์ ์ฌ์ฉํ ์ ์๋ weight ํ์ผ๋ก ๋ณํ ํ ์ด๋ฅผ ์ด์ฉํ์ฌ Object Detection์ ์ํํด ๋ณด๊ฒ ์ต๋๋ค.
- ๋จ, ์๋ ๋ฒ์ ์ด์ฌ์ ์คํฐ๋ํ ๋ด์ฉ๋ง ์ ๋ฆฌํด์ ์ฌ๋ฆฌ๋๊ฑฐ๊ธฐ ๋๋ฌธ์ ํ์ฌ ์คํ์ด ์๋ ์๋ ์์ต๋๋ค. ๋จ์ํ ์ฐธ๊ณ ์ฉ์ผ๋ก๋ง ๋ด์ฃผ์ธ์!
๋ณธ์ฝ๋๋ GPU๋ฅผ ํ์ฉํ๋ฏ๋ก Colab ์๋จ ๋ฉ๋ด์์ ๋ฐํ์ ์ ํ ๋ณ๊ฒฝ์์ GPU๋ฅผ ์ ํํด์ผ ํฉ๋๋ค.
# ํ์ฌ ๋๋ ํ ๋ฆฌ๋ /content์ด๋ฉฐ ์ด ๋๋ ํ ๋ฆฌ๋ฅผ ๊ธฐ์ค์ผ๋ก ์ค์ต์ฝ๋์ ๋ฐ์ดํฐ๋ฅผ ๋ค์ด๋ก๋ ํฉ๋๋ค.
!pwd
!rm -rf DLCV
!git clone https://github.com/chulminkw/DLCV.git
# DLCV ๋๋ ํ ๋ฆฌ๊ฐ Download๋๊ณ DLCV ๋ฐ์ Detection๊ณผ Segmentation ๋๋ ํ ๋ฆฌ๊ฐ ์๋ ๊ฒ์ ํ์ธ
!ls -lia
!ls -lia DLCV
# tensorflow 1.15์ ์ค์นํฉ๋๋ค. ์๋์ผ๋ก tensorflow 2.2๊ฐ 1.15๋ก downgrade ๋ฉ๋๋ค.
!pip install tensorflow-gpu==1.15.2
# keras 2.3๋ฅผ ์ค์นํฉ๋๋ค.
!pip install keras==2.3.0
# GPU๊ฐ ์ธํ
๋์ด ์์ง ์์ผ๋ฉด ์๋จ ๋ฉ๋ด์์ ๋ฐํ์->๋ฐํ์ ์ ํ ๋ณ๊ฒฝ์์ GPU๋ฅผ ์ ํํ ํ ๋ฐํ์ ๋ค์ ์์์ ์ ํํ๊ณ ์ฒ์ ๋ถํฐ์ธ tensorflow, keras ์ค์น ๋ถํฐ ๋ค์ ์์.
import tensorflow as tf
import keras
print(tf.__version__)
print(keras.__version__)
# gpu๊ฐ ์ธํ
๋์ด ์๋์ง ํ์ธ.
tf.test.gpu_device_name()
import os
import sys
import random
import math
import time
import numpy as np
import tensorflow as tf
import matplotlib
import matplotlib.pyplot as plt
%cd /content/DLCV/Detection/yolo
!git clone https://github.com/qqwweee/keras-yolo3.git
!ls -lia /content/DLCV/Detection/yolo/keras-yolo3
Local Directory ์์์ yolo package๋ฅผ import.
- keras-yolo3๋ setup์ ์ ๊ณตํ์ง ์์ผ๋ฏ๋ก local directory์์์ ๋ฐ๋ก package๋ฅผ importํฉ๋๋ค.
- ์ด๋ฅผ ์ํด keras-yolo3๋ฅผ system path์ ์ถ๊ฐํฉ๋๋ค.
- keras-yolo3 ๋๋ ํ ๋ฆฌ์ ์๋ yolo.py์์ YOLO class๋ฅผ importํ์ฌ ์ฌ์ฉํฉ๋๋ค.
from keras.layers import LeakyReLU, BatchNormalization
default_dir = '/content/DLCV'
default_yolo_dir = os.path.join(default_dir, 'Detection/yolo')
LOCAL_PACKAGE_DIR = os.path.abspath(os.path.join(default_yolo_dir,'keras-yolo3'))
print(LOCAL_PACKAGE_DIR)
sys.path.append(LOCAL_PACKAGE_DIR)
from yolo import YOLO
# YOLO ํด๋์ค๋ model_path, achors_path, classes_path๋ฅผ model_data ๋ฐ์ ํ์ผ๋ก ๊ฐ์ง. ๋ณ๊ฒฝ์ ์ํด์๋ yolo.py ํ์ผ์์ YOLO ํด๋์ค์ฝ๋๋ฅผ ์ง์ ๋ณ๊ฒฝ ํ์.
print(LOCAL_PACKAGE_DIR)
!ls /home/chulmin.kwon45/DLCV/Detection/yolo/keras-yolo3
!cat /home/chulmin.kwon45/DLCV/Detection/yolo/keras-yolo3/yolo.py
YOLO ๊ฐ์ฒด๋ฅผ ์ฌ์ฉํ๊ธฐ ์ํ ๋ชจ๋ธ ํ์ผ ์ค์ ๋ฐ ์์ค ์ฝ๋ ๋ณ๊ฒฝ
- ๋คํฌ๋ท์์ Yolo V3 Weight ๋ชจ๋ธ ํ์ผ์ ๋ค์ด๋ก๋ ๋ฐ์ ๋ค ์ด๋ฅผ keras-yolo3์ฉ์ผ๋ก ๋ชจ๋ธ ํ์ผ์ผ๋ก ๋ณ๊ฒฝํฉ๋๋ค.
- model_data ๋๋ ํ ๋ฆฌ ๋ฐ์ yolo_anchors.txt, coco_classes.txt ๊ฐ ์๋์ง ํ์ธํด์ผํฉ๋๋ค.
!ls /content/DLCV/Detection/yolo/keras-yolo3
# ์ฝ๋ฉ ๋ฒ์ ์ ์๋๋ฅผ ์ด์ฉํ์ฌ yolov3.weights ํ์ผ์ download ๋ฐ๊ณ , convert.py ๋ฅผ ์ํํ์ฌ model_data ๋ฐ์ yolo.h5 ํ์ผ ์์ฑ ์ํ.
%cd /content/DLCV/Detection/yolo/keras-yolo3
!wget https://github.com/chulminkw/DLCV/releases/download/1.0/yolov3.weights
# yolov3.weights๋ฅผ keras-yolo3์์ ์ฌ์ฉํ ์ ์๋๋ก yolo.h5 ๋ก ๋ณํ
!python convert.py yolov3.cfg yolov3.weights model_data/yolo.h5
# model_data ๋ฐ์ yolo.h5 ํ์ผ์ด ์์ฑ๋์๋์ง ํ์ธ.
!ls /content/DLCV/Detection/yolo/keras-yolo3/model_data
import sys
import argparse
from yolo import YOLO, detect_video
#keras-yolo์์ image์ฒ๋ฆฌ๋ฅผ ์ฃผ์ PIL๋ก ์ํ.
from PIL import Image
# YOLO ๊ฐ์ฒด ์์ฑ. config๋ default๋ก keras-yolo3 ๋๋ ํ ๋ฆฌ์ ์๋ yolov3.cfg๋ฅผ ์ ์ฉ.
# ์ฝ๋ฉ ๋ฒ์ ์ ์ ๋ ๊ฒฝ๋ก๋ก ๊ฐ ์์ฑ ์ธ์๊ฐ ์
๋ ฅ
default_yolo_dir = '/content/DLCV/Detection/yolo'
config_dict = {}
yolo = YOLO(model_path=os.path.join(default_yolo_dir, 'keras-yolo3/model_data/yolo.h5'),
anchors_path=os.path.join(default_yolo_dir, 'keras-yolo3/model_data/yolo_anchors.txt'),
classes_path=os.path.join(default_yolo_dir, 'keras-yolo3/model_data/coco_classes.txt'))
๋จ์ผ Image Object Detection
# ์๋ณธ ์ด๋ฏธ์ง ๋ณด๊ธฐ
default_dir = '/content/DLCV'
img = Image.open(os.path.join(default_dir, 'data/image/beatles01.jpg'))
plt.figure(figsize=(12, 12))
plt.imshow(img)
# yolo.detect_image() ๋ฉ์๋๋ PIL package๋ฅผ ์ด์ฉํ์ฌ image ์์
์ํ. keras-yolo3/font ๋๋ ํ ๋ฆฌ๋ฅผ ์์ ๋๋ ํ ๋ฆฌ๋ก ๋ณต์ฌ ํด์ผํจ.
%cd /content/DLCV/Detection/yolo
!cp -rf keras-yolo3/font ./font
img = Image.open(os.path.join(default_dir, 'data/image/beatles01.jpg'))
detected_img = yolo.detect_image(img)
plt.figure(figsize=(12, 12))
plt.imshow(detected_img)
Video Object Detection ์ํ
YOLO V3 Model ์ด ์๋ github์์ detect_video.py์ฉ code๋ฅผ ์ ๊ณตํฉ๋๋ค.
GitHub - qqwweee/keras-yolo3: A Keras implementation of YOLOv3 (Tensorflow backend)
A Keras implementation of YOLOv3 (Tensorflow backend) - qqwweee/keras-yolo3
github.com
import cv2
import time
def detect_video_yolo(model, input_path, output_path=""):
start = time.time()
cap = cv2.VideoCapture(input_path)
#codec = cv2.VideoWriter_fourcc(*'DIVX')
codec = cv2.VideoWriter_fourcc(*'XVID')
vid_fps = cap.get(cv2.CAP_PROP_FPS)
vid_size = (int(cap.get(cv2.CAP_PROP_FRAME_WIDTH)),int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT)))
vid_writer = cv2.VideoWriter(output_path, codec, vid_fps, vid_size)
frame_cnt = int(cap.get(cv2.CAP_PROP_FRAME_COUNT))
print('์ด Frame ๊ฐฏ์:', frame_cnt, '์๋ณธ ์์ FPS:',vid_fps)
index = 0
while True:
hasFrame, image_frame = cap.read()
if not hasFrame:
print('ํ๋ ์์ด ์๊ฑฐ๋ ์ข
๋ฃ ๋์์ต๋๋ค.')
break
start = time.time()
# PIL Package๋ฅผ ๋ด๋ถ์์ ์ฌ์ฉํ๋ฏ๋ก cv2์์ ์ฝ์ image_frame array๋ฅผ ๋ค์ PIL์ Imageํํ๋ก ๋ณํํด์ผ ํจ.
image = Image.fromarray(image_frame)
# ์๋๋ ์ธ์๋ก ์
๋ ฅ๋ yolo๊ฐ์ฒด์ detect_image()๋ก ๋ณํํ๋ค.
detected_image = model.detect_image(image)
# cv2์ video writer๋ก ์ถ๋ ฅํ๊ธฐ ์ํด ๋ค์ PIL์ Imageํํ๋ฅผ arrayํํ๋ก ๋ณํ
result = np.asarray(detected_image)
index +=1
print('#### frame:{0} ์ด๋ฏธ์ง ์ฒ๋ฆฌ์๊ฐ:{1}'.format(index, round(time.time()-start,3)))
vid_writer.write(result)
vid_writer.release()
cap.release()
print('### Video Detect ์ด ์ํ์๊ฐ:', round(time.time()-start, 5))
default_dir = '/content/DLCV'
detect_video_yolo(yolo, os.path.join(default_dir, 'data/video/Night_Day_Chase.mp4'),
os.path.join(default_dir, 'data/output/Night_Day_Chase_yolo_01.avi'))
## colab ๋ฒ์ ์ Object Detection ์ ์ฉ๋ ์์ ํ์ผ์ google drive์์ download ํด์ผ ํฉ๋๋ค. ์ด๋ฅผ ์ํด google drive๋ฅผ colab์ mount ์ํ.
import os, sys
from google.colab import drive
drive.mount('/content/gdrive')
## colab ๋ฒ์ ์ Object Detection ์ ์ฉ๋ ์์ ํ์ผ์ google drive์์ download ํด์ผ ํฉ๋๋ค.
## My Drive ๋๋ ํ ๋ฆฌ ์ด๋ฆ์ ๊ณต๋์ด ์์ผ๋ฏ๋ก ' '๋ก ๋ฌถ์ต๋๋ค.
!cp /content/DLCV/data/output/Night_Day_Chase_yolo_01.avi '/content/gdrive/My Drive/Night_Day_Chase_yolo_01.avi'
- ๊ฒฐ๊ณผ ํ๋ฉด (ํ๋ฉด ์บก์ฒ)
- SSD ๋ณด๋จ ์ ํ๋๊ฐ ์ฌ๋ผ๊ฐ๋๊ฑธ ๋ณผ ์ ์์ต๋๋ค.
Tiny YOLO๋ฅผ ์ด์ฉํ์ฌ Image & Video Object Detection
- tiny yolo weightsํ์ผ์ https://pjreddie.com/media/files/yolov3-tiny.weights ์์ ๋ค์ด๋ก๋ ๋ฐ์ ์ ์์ต๋๋ค.
- ๋ค์ด๋ก๋ ๋ฐ์ tiny-yolo weightํ์ผ์ keras-yolo3์์ ์ฌ์ฉํ ์ ์๊ฒ Convert ์ํ ํ YOLO๊ฐ์ฒด์์ ๋ก๋ฉํ์ฌ ์ฌ์ฉํฉ๋๋ค.
# wget https://pjreddie.com/media/files/yolov3-tiny.weights
#!python convert.py yolov3-tiny.cfg ./model_data/yolov3-tiny.weights model_data/yolo-tiny.h5
# yolov3-tiny.weights ํ์ผ์ download ๋ฐ๊ณ , convert.py ๋ฅผ ์ํํ์ฌ model_data ๋ฐ์ yolo-tiny.h5 ํ์ผ ์์ฑ.
%cd /content/DLCV/Detection/yolo/keras-yolo3
!wget https://pjreddie.com/media/files/yolov3-tiny.weights
!python convert.py yolov3-tiny.cfg yolov3-tiny.weights model_data/yolo-tiny.h5
# model_data ๋ฐ์ yolo-tiny.h5 ํ์ผ์ด ์์ฑ๋์๋์ง ํ์ธ.
!ls /content/DLCV/Detection/yolo/keras-yolo3/model_data
tiny yolo weight ํ์ผ๊ณผ anchor ํ์ผ, coco ํด๋์ค ํ์ผ์ YOLO ๊ฐ์ฒด ์์ฑ ์ ์ธ์๋ก ์ ๋ ฅ
default_yolo_dir = '/content/DLCV/Detection/yolo'
config_dict = {}
tiny_yolo = YOLO(model_path=os.path.join(default_yolo_dir,'keras-yolo3/model_data/yolo-tiny.h5'),
anchors_path=os.path.join(default_yolo_dir,'keras-yolo3/model_data/tiny_yolo_anchors.txt'),
classes_path=os.path.join(default_yolo_dir,'keras-yolo3/model_data/coco_classes.txt'))
Single Image Object Detection
default_dir = '/content/DLCV'
img = Image.open(os.path.join(default_dir, 'data/image/beatles01.jpg'))
detected_img = tiny_yolo.detect_image(img)
plt.figure(figsize=(12, 12))
plt.imshow(detected_img)
Video Object Detection
default_dir = '/content/DLCV'
detect_video_yolo(tiny_yolo, os.path.join(default_dir, 'data/video/Night_Day_Chase.mp4'), os.path.join(default_dir, 'data/output/Night_Day_Chase_tiny_yolo01.avi'))
## colab ๋ฒ์ ์ Object Detection ์ ์ฉ๋ ์์ ํ์ผ์ google drive์์ download ํด์ผํจ. ์ด๋ฅผ ์ํด google drive๋ฅผ colab์ mount ์ํ.
import os, sys
from google.colab import drive
drive.mount('/content/gdrive')
## colab ๋ฒ์ ์ Object Detection ์ ์ฉ๋ ์์ ํ์ผ์ google drive์์ download ํด์ผ ํฉ๋๋ค.
## My Drive ๋๋ ํ ๋ฆฌ ์ด๋ฆ์ ๊ณต๋์ด ์์ผ๋ฏ๋ก ' '๋ก ๋ฌถ์ต๋๋ค.
!cp /content/DLCV/data/output/Night_Day_Chase_tiny_yolo01.avi '/content/gdrive/My Drive/Night_Day_Chase_tiny_yolo01.avi'
'๐ Computer Vision' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[CV] Keras YOLO๋ก Raccoon Dataset์ ์ด์ฉํ Object Detection (0) | 2024.10.10 |
---|---|
[CV] Object Detection Model Training์ ์ ์์ฌํญ (0) | 2024.10.08 |
[CV] OpenCV์์ YOLO๋ฅผ ์ด์ฉํ Object Detection Part.2 (0) | 2024.10.06 |
[CV] OpenCV์์ YOLO๋ฅผ ์ด์ฉํ Object Detection Part.1 (0) | 2024.07.15 |
[CV] YOLO (You Only Look Once) (0) | 2024.07.14 |