Home 4336 9200 0186 8054
Post
Cancel

4336 9200 0186 8054

정리:

Non-maximum Suppression (NMS)

설명:

  • 목적: 객체 검출(Object Detection)에서 여러 겹쳐진 경계 상자(Bounding Boxes) 중 최적의 상자를 선택하기 위함.
  • 방법:
    • 각 경계 상자에 대해 감지 확률을 평가.
    • 가장 높은 점수를 가진 상자를 선택하고, 다른 상자들과의 중첩(Overlap)을 계산.
    • 특정 임계값(IoU: Intersection over Union)보다 높은 중첩을 가진 상자는 제거.
  • 결과: 각 객체에 대해 단일, 최적의 경계 상자를 얻음.

설명:

  • 목적: R-CNN에서 사용, 이미지 내 잠재적인 관심 영역(Regions of Interest, RoIs)을 식별하기 위함.
  • 방법:
    • 세분화(Segmentation) 기법을 사용하여 이미지를 여러 영역으로 나눔.
    • 유사한 특징(색상, 질감 등)을 가진 인접 영역을 병합.
    • 다양한 크기와 모양의 후보 영역 생성.
  • 결과: 후보 영역들이 객체 검출 알고리즘의 입력으로 사용됨.

R-CNN, Fast R-CNN, Faster R-CNN

R-CNN (Regions with CNN features)

  • 구조:
    • Selective Search로 후보 영역 추출
    • 각 영역을 CNN에 입력하여 특징 추출
    • 추출된 특징을 SVM(Classifier)에 입력하여 객체 분류
  • 단점: 계산 비효율성 (각 영역마다 CNN 통과)

Fast R-CNN

  • 개선점:
    • 전체 이미지를 한 번에 CNN에 통과시키고, RoI Pooling Layer를 사용하여 특징 맵에서 후보 영역의 특징 추출
    • 속도와 효율성 향상
  • 구조: 전체 이미지 -> CNN -> RoI Pooling -> 분류 및 경계 상자 회귀

Faster R-CNN

  • 개선점:
    • Selective Search 대신 Region Proposal Network(RPN) 사용하여 후보 영역 생성.
    • 더 빠르고 정확한 객체 검출 가능.
  • 구조: RPN -> RoI Pooling -> 분류 및 경계 상자 회귀.

Anchor Boxes

기본 개념

  • 객체 검출(Object Detection) 알고리즘에서 사용되는, 미리 정의된 여러 크기와 비율의 가상의 경계 상자
  • 특정 영역에서 다양한 형태와 크기를 가진 객체들을 동시에 감지하는 데 도움을 줌

동작 방식

  1. 정의: 알고리즘은 다양한 크기와 비율의 Anchor Boxes를 미리 정의
    • 작은 크기, 중간 크기, 큰 크기 및 각기 다른 비율(정사각형, 세로로 긴 직사각형, 가로로 긴 직사각형 등)의 상자들을 정의하는데 주로 9개로 함
  2. 배치: 이미지의 각 위치에 이 Anchor Boxes를 배치
    • 일반적으로 특징 맵(Feature Map) 위에 수행
    • 특징 맵의 각 위치에서 모든 Anchor Boxes는 객체의 잠재적 위치로 간주
  3. 예측: 각 Anchor Box에 대해 두 가지 주요 예측을 수행
    • 클래스 예측: 이 Box에 객체가 있는지 없는지(배경 포함), 그리고 객체가 있다면 어떤 클래스에 속하는지
    • 경계 상자 조정: Box의 크기와 위치를 조정하여 실제 객체에 더 잘 맞도록

중요성

  • 다양한 형태 처리: 한 위치에서 여러 형태의 객체를 감지할 수 있게 해주므로, 객체의 형태와 크기가 다양한 경우에 유용
  • 중복 감지 방지: 동일한 객체에 대해 여러 Anchor Boxes가 반응할 수 있으므로, 이를 관리하기 위해 Non-Maximum Suppression(NMS)과 같은 기술 사용

예시

  • 이미지에 개와 고양이가 있을 때, 작은 Anchor Box는 멀리 있는 고양이를, 큰 Anchor Box는 가까이 있는 개를 감지
  • 비율이 다른 Box는 세로로 긴 개체(예: 서 있는 사람) 또는 가로로 긴 개체(예: 누워있는 사람)를 감지하는 데 유용

응용

  • Faster R-CNNYOLO와 같은 고급 객체 검출 알고리즘에서는 Anchor Boxes가 핵심 구성 요소로 사용
  • 이를 통해 이러한 알고리즘은 이미지 내의 다양한 객체를 효율적으로 식별하고 분류

Region Proposal Network (RPN) 상세 설명

기본 개념

  • Region Proposal Network (RPN)는 Faster R-CNN 알고리즘의 핵심 구성 요소입니다.
  • RPN의 주요 역할은 객체가 있을 가능성이 높은 영역, 즉 “Region Proposals”을 빠르고 효율적으로 식별하는 것입니다.

동작 방식

  1. 특징 맵 생성: RPN은 먼저 기본 CNN 네트워크를 통해 입력 이미지에서 특징 맵(Feature Map)을 생성합니다.
  2. 슬라이딩 윈도우: 이 특징 맵 위에서 RPN은 슬라이딩 윈도우 방식을 사용합니다. 각 윈도우 위치에서, RPN은 여러 Anchor Boxes에 대한 객체 존재 여부와 위치 조정을 예측합니다.
  3. Anchor Boxes: RPN은 다양한 크기와 비율의 Anchor Boxes를 사용하여 각 위치에서 여러 영역을 동시에 고려합니다.
  4. 예측: 각 Anchor Box에 대해 RPN은 두 가지를 예측합니다:
    • 객체 점수(Objectness Score): Anchor Box 내에 객체가 있는지 여부를 나타냅니다.
    • 경계 상자 조정: Anchor Box의 위치와 크기를 조정하여 실제 객체에 더 잘 맞도록 합니다.

핵심 요소

  • 속도와 정확도: RPN은 Selective Search 방법보다 훨씬 빠르면서도 정확하게 영역 제안을 생성합니다.
  • 통합 구조: RPN은 Faster R-CNN의 나머지 부분과 긴밀하게 통합되어 있으며, 객체 검출 파이프라인의 효율성과 정확도를 향상시킵니다.
  • 학습 가능: RPN은 역전파를 통해 학습될 수 있으며, 이미지에 대한 객체의 위치와 크기에 대해 더 정확한 예측을 하도록 최적화됩니다.

응용

  • Faster R-CNN: RPN은 Faster R-CNN에서 객체의 위치를 신속하게 제안하고, 이후의 네트워크가 이 영역들을 자세히 분석하여 객체를 분류하고 정확한 경계 상자를 생성합니다.

RPN의 도입은 객체 검출 분야에서 중요한 혁신으로, 이전 방법들에 비해 더 빠르고 정확한 영역 제안을 가능하게 합니다. 이는 객체 검출 알고리즘의 전체 성능을 향상시키는 중요한 요소입니다.

수업:

Positive Anchor Box, Negative Anchor Box

Ground Truth Bounding Box 겹치는 IOU 값에 따라 Anchor Box를 분류

  • IOU가 가장 높은 Positive Anchor Box
  • IOU가 0.7 이상이면 Positive Anchor Box
  • IOU가 0.3보다 낮으면 Negative Anchor Box
  • Classification에 비유하자면, 개&고양이 구별하는 모델이 있을 때, 개일 확률이 높은것만 가르키는것이 아니라, 고양이가 아닐 확률 또한 가르키는 방법.

Anchor Box 기반 BB regression

예측 bounding box와 positive anchor box와의 좌표 차이는 ground truth와 positive anchor box와의 좌표 차이와 최대한 동일하게 되게 regression 학습

Anchor Box 기반 RPN Output

  • k: Anchor Box 수

RPN Loss 함수

앞의 L 과 뒤의 L 이 다름

Ground Truth를 찾는 방법을 훈련시키다기 보다 Anchor Box를 찾는 훈련을 한다

실습

OpenCV DNN 패키지를 이용하여 Faster R-CNN 기반의 Object Detection 수행

  • Tensorflow 에서 Pretrained 된 모델 파일을 OpenCV에서 로드하여 이미지와 영상에 대한 Object Detection 수행.

입력 이미지로 사용될 이미지 다운로드/보기

1
2
!mkdir /content/data
!wget -O ./data/beatles01.jpg https://raw.githubusercontent.com/chulminkw/DLCV/master/data/image/beatles01.jpg
1
2
3
4
5
6
7
8
9
10
11
mkdir: cannot create directory ‘/content/data’: File exists
--2023-11-22 06:21:14--  https://raw.githubusercontent.com/chulminkw/DLCV/master/data/image/beatles01.jpg
Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 185.199.109.133, 185.199.110.133, 185.199.108.133, ...
Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|185.199.109.133|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 383118 (374K) [image/jpeg]
Saving to: ‘./data/beatles01.jpg’

./data/beatles01.jp 100%[===================>] 374.14K  --.-KB/s    in 0.05s   

2023-11-22 06:21:14 (7.31 MB/s) - ‘./data/beatles01.jpg’ saved [383118/383118]
1
2
3
4
5
6
7
8
9
10
import cv2
import matplotlib.pyplot as plt
%matplotlib inline

img = cv2.imread('./data/beatles01.jpg')
img_rgb = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)

print('image shape:', img.shape)
plt.figure(figsize=(12, 12))
plt.imshow(img_rgb)
1
2
3
4
5
6
7
image shape: (633, 806, 3)





<matplotlib.image.AxesImage at 0x7ec0aaf2e680>

Tensorflow에서 Pretrained 된 Inference모델(Frozen graph)와 환경파일을 다운로드 받은 후 이를 이용해 OpenCV에서 Inference 모델 생성

  • https://github.com/opencv/opencv/wiki/TensorFlow-Object-Detection-API 에 다운로드 URL 있음.
  • pretrained 모델은 http://download.tensorflow.org/models/object_detection/faster_rcnn_resnet50_coco_2018_01_28.tar.gz 에서 다운로드 후 압축 해제
  • pretrained 모델을 위한 환경 파일은 https://github.com/opencv/opencv_extra/blob/master/testdata/dnn/faster_rcnn_resnet50_coco_2018_01_28.pbtxt 에서 다운로드
  • download된 모델 파일과 config 파일을 인자로 하여 inference 모델을 DNN에서 로딩함.
1
2
3
!mkdir ./pretrained
!wget -O ./pretrained/faster_rcnn_resnet50_coco_2018_01_28.tar.gz http://download.tensorflow.org/models/object_detection/faster_rcnn_resnet50_coco_2018_01_28.tar.gz
!wget -O ./pretrained/config_graph.pbtxt https://raw.githubusercontent.com/opencv/opencv_extra/master/testdata/dnn/faster_rcnn_resnet50_coco_2018_01_28.pbtxt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
--2023-11-22 06:21:15--  http://download.tensorflow.org/models/object_detection/faster_rcnn_resnet50_coco_2018_01_28.tar.gz
Resolving download.tensorflow.org (download.tensorflow.org)... 173.194.215.207, 173.194.216.207, 173.194.218.207, ...
Connecting to download.tensorflow.org (download.tensorflow.org)|173.194.215.207|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 381355771 (364M) [application/x-tar]
Saving to: ‘./pretrained/faster_rcnn_resnet50_coco_2018_01_28.tar.gz’

./pretrained/faster 100%[===================>] 363.69M  47.4MB/s    in 3.8s    

2023-11-22 06:21:19 (95.0 MB/s) - ‘./pretrained/faster_rcnn_resnet50_coco_2018_01_28.tar.gz’ saved [381355771/381355771]

--2023-11-22 06:21:19--  https://raw.githubusercontent.com/opencv/opencv_extra/master/testdata/dnn/faster_rcnn_resnet50_coco_2018_01_28.pbtxt
Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 185.199.110.133, 185.199.111.133, 185.199.108.133, ...
Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|185.199.110.133|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 90893 (89K) [text/plain]
Saving to: ‘./pretrained/config_graph.pbtxt’

./pretrained/config 100%[===================>]  88.76K  --.-KB/s    in 0.03s   

2023-11-22 06:21:19 (3.22 MB/s) - ‘./pretrained/config_graph.pbtxt’ saved [90893/90893]
1
!tar -xvf ./pretrained/faster*.tar.gz -C ./pretrained
1
2
3
4
5
6
7
8
9
10
faster_rcnn_resnet50_coco_2018_01_28/
faster_rcnn_resnet50_coco_2018_01_28/model.ckpt.index
faster_rcnn_resnet50_coco_2018_01_28/checkpoint
faster_rcnn_resnet50_coco_2018_01_28/pipeline.config
faster_rcnn_resnet50_coco_2018_01_28/model.ckpt.data-00000-of-00001
faster_rcnn_resnet50_coco_2018_01_28/model.ckpt.meta
faster_rcnn_resnet50_coco_2018_01_28/saved_model/
faster_rcnn_resnet50_coco_2018_01_28/saved_model/saved_model.pb
faster_rcnn_resnet50_coco_2018_01_28/saved_model/variables/
faster_rcnn_resnet50_coco_2018_01_28/frozen_inference_graph.pb
1
2
!pwd
!ls -lia ./pretrained/faster_rcnn_resnet50_coco_2018_01_28
1
2
3
4
5
6
7
8
9
10
11
/content
total 296076
4980851 drwxr-xr-x 3 345018 5000      4096 Feb  1  2018 .
4980848 drwxr-xr-x 3 root   root      4096 Nov 22 06:21 ..
4980853 -rw-r--r-- 1 345018 5000        77 Feb  1  2018 checkpoint
4980860 -rw-r--r-- 1 345018 5000 120549957 Feb  1  2018 frozen_inference_graph.pb
4980855 -rw-r--r-- 1 345018 5000 176914228 Feb  1  2018 model.ckpt.data-00000-of-00001
4980852 -rw-r--r-- 1 345018 5000     14460 Feb  1  2018 model.ckpt.index
4980856 -rw-r--r-- 1 345018 5000   5675175 Feb  1  2018 model.ckpt.meta
4980854 -rw-r--r-- 1 345018 5000      3240 Feb  1  2018 pipeline.config
4980857 drwxr-xr-x 3 345018 5000      4096 Feb  1  2018 saved_model

dnn에서 readNetFromTensorflow()로 tensorflow inference 모델을 로딩

1
2
cv_net = cv2.dnn.readNetFromTensorflow('./pretrained/faster_rcnn_resnet50_coco_2018_01_28/frozen_inference_graph.pb',
                                     './pretrained/config_graph.pbtxt')

coco 데이터 세트의 클래스id별 클래스명 지정.

1
2
3
4
5
6
7
8
9
# OpenCV Yolo용
labels_to_names_seq = {0:'person',1:'bicycle',2:'car',3:'motorbike',4:'aeroplane',5:'bus',6:'train',7:'truck',8:'boat',9:'traffic light',10:'fire hydrant',
                        11:'stop sign',12:'parking meter',13:'bench',14:'bird',15:'cat',16:'dog',17:'horse',18:'sheep',19:'cow',20:'elephant',
                        21:'bear',22:'zebra',23:'giraffe',24:'backpack',25:'umbrella',26:'handbag',27:'tie',28:'suitcase',29:'frisbee',30:'skis',
                        31:'snowboard',32:'sports ball',33:'kite',34:'baseball bat',35:'baseball glove',36:'skateboard',37:'surfboard',38:'tennis racket',39:'bottle',40:'wine glass',
                        41:'cup',42:'fork',43:'knife',44:'spoon',45:'bowl',46:'banana',47:'apple',48:'sandwich',49:'orange',50:'broccoli',
                        51:'carrot',52:'hot dog',53:'pizza',54:'donut',55:'cake',56:'chair',57:'sofa',58:'pottedplant',59:'bed',60:'diningtable',
                        61:'toilet',62:'tvmonitor',63:'laptop',64:'mouse',65:'remote',66:'keyboard',67:'cell phone',68:'microwave',69:'oven',70:'toaster',
                        71:'sink',72:'refrigerator',73:'book',74:'clock',75:'vase',76:'scissors',77:'teddy bear',78:'hair drier',79:'toothbrush' }
1
2
3
4
5
6
7
8
9
10
11
# OpenCV Tensorflow Faster-RCNN용
labels_to_names_0 = {0:'person',1:'bicycle',2:'car',3:'motorcycle',4:'airplane',5:'bus',6:'train',7:'truck',8:'boat',9:'traffic light',
                    10:'fire hydrant',11:'street sign',12:'stop sign',13:'parking meter',14:'bench',15:'bird',16:'cat',17:'dog',18:'horse',19:'sheep',
                    20:'cow',21:'elephant',22:'bear',23:'zebra',24:'giraffe',25:'hat',26:'backpack',27:'umbrella',28:'shoe',29:'eye glasses',
                    30:'handbag',31:'tie',32:'suitcase',33:'frisbee',34:'skis',35:'snowboard',36:'sports ball',37:'kite',38:'baseball bat',39:'baseball glove',
                    40:'skateboard',41:'surfboard',42:'tennis racket',43:'bottle',44:'plate',45:'wine glass',46:'cup',47:'fork',48:'knife',49:'spoon',
                    50:'bowl',51:'banana',52:'apple',53:'sandwich',54:'orange',55:'broccoli',56:'carrot',57:'hot dog',58:'pizza',59:'donut',
                    60:'cake',61:'chair',62:'couch',63:'potted plant',64:'bed',65:'mirror',66:'dining table',67:'window',68:'desk',69:'toilet',
                    70:'door',71:'tv',72:'laptop',73:'mouse',74:'remote',75:'keyboard',76:'cell phone',77:'microwave',78:'oven',79:'toaster',
                    80:'sink',81:'refrigerator',82:'blender',83:'book',84:'clock',85:'vase',86:'scissors',87:'teddy bear',88:'hair drier',89:'toothbrush',
                    90:'hair brush'}
1
2
3
4
5
6
7
8
9
10
11
labels_to_names = {1:'person',2:'bicycle',3:'car',4:'motorcycle',5:'airplane',6:'bus',7:'train',8:'truck',9:'boat',10:'traffic light',
                    11:'fire hydrant',12:'street sign',13:'stop sign',14:'parking meter',15:'bench',16:'bird',17:'cat',18:'dog',19:'horse',20:'sheep',
                    21:'cow',22:'elephant',23:'bear',24:'zebra',25:'giraffe',26:'hat',27:'backpack',28:'umbrella',29:'shoe',30:'eye glasses',
                    31:'handbag',32:'tie',33:'suitcase',34:'frisbee',35:'skis',36:'snowboard',37:'sports ball',38:'kite',39:'baseball bat',40:'baseball glove',
                    41:'skateboard',42:'surfboard',43:'tennis racket',44:'bottle',45:'plate',46:'wine glass',47:'cup',48:'fork',49:'knife',50:'spoon',
                    51:'bowl',52:'banana',53:'apple',54:'sandwich',55:'orange',56:'broccoli',57:'carrot',58:'hot dog',59:'pizza',60:'donut',
                    61:'cake',62:'chair',63:'couch',64:'potted plant',65:'bed',66:'mirror',67:'dining table',68:'window',69:'desk',70:'toilet',
                    71:'door',72:'tv',73:'laptop',74:'mouse',75:'remote',76:'keyboard',77:'cell phone',78:'microwave',79:'oven',80:'toaster',
                    81:'sink',82:'refrigerator',83:'blender',84:'book',85:'clock',86:'vase',87:'scissors',88:'teddy bear',89:'hair drier',90:'toothbrush',
                    91:'hair brush'}

이미지를 preprocessing 수행하여 Network에 입력하고 Object Detection 수행 후 결과를 이미지에 시각화

1
img.shape
1
(633, 806, 3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# 원본 이미지가 Faster RCNN기반 네트웍으로 입력 시 resize됨.
# scaling된 이미지 기반으로 bounding box 위치가 예측 되므로 이를 다시 원복하기 위해 원본 이미지 shape정보 필요
rows = img.shape[0]
cols = img.shape[1]
# cv2의 rectangle()은 인자로 들어온 이미지 배열에 직접 사각형을 업데이트 하므로 그림 표현을 위한 별도의 이미지 배열 생성.
draw_img = img.copy()

# 원본 이미지 배열 BGR을 RGB로 변환하여 배열 입력. Tensorflow Faster RCNN은 마지막 classification layer가 Dense가 아니여서 size를 고정할 필요는 없음.
cv_net.setInput(cv2.dnn.blobFromImage(img, swapRB=True, crop=False))

# Object Detection 수행하여 결과를 cvOut으로 반환
cv_out = cv_net.forward()
print(cv_out.shape)

# bounding box의 테두리와 caption 글자색 지정
green_color=(0, 255, 0)
red_color=(0, 0, 255)

# detected 된 object들을 iteration 하면서 정보 추출
for detection in cv_out[0,0,:,:]:
    score = float(detection[2])
    class_id = int(detection[1])
    # detected된 object들의 score가 0.5 이상만 추출
    if score > 0.5:
        # detected된 object들은 scale된 기준으로 예측되었으므로 다시 원본 이미지 비율로 계산
        left = detection[3] * cols
        top = detection[4] * rows
        right = detection[5] * cols
        bottom = detection[6] * rows
        # labels_to_names_seq 딕셔너리로 class_id값을 클래스명으로 변경.
        caption = "{}: {:.4f}".format(labels_to_names_0[class_id], score)
        print(caption)
        #cv2.rectangle()은 인자로 들어온 draw_img에 사각형을 그림. 위치 인자는 반드시 정수형.
        cv2.rectangle(draw_img, (int(left), int(top)), (int(right), int(bottom)), color=green_color, thickness=2)
        cv2.putText(draw_img, caption, (int(left), int(top - 5)), cv2.FONT_HERSHEY_SIMPLEX, 0.4, red_color, 1)

img_rgb = cv2.cvtColor(draw_img, cv2.COLOR_BGR2RGB)

plt.figure(figsize=(12, 12))
plt.imshow(img_rgb)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
(1, 1, 100, 7)
person: 0.9998
person: 0.9996
person: 0.9993
person: 0.9970
person: 0.8995
car: 0.8922
car: 0.7602
car: 0.7415
car: 0.6929
car: 0.6918
car: 0.6896
car: 0.6717
car: 0.6521
car: 0.5730
car: 0.5679
car: 0.5261
car: 0.5012





<matplotlib.image.AxesImage at 0x7ec0aae1f130>

1
cv_out
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
array([[[[0.00000000e+00, 0.00000000e+00, 9.99780715e-01,
          2.80248195e-01, 4.11070466e-01, 4.66062039e-01,
          8.59829783e-01],
         [0.00000000e+00, 0.00000000e+00, 9.99588192e-01,
          5.82913086e-02, 4.13466066e-01, 2.61212587e-01,
          8.93701553e-01],
         [0.00000000e+00, 0.00000000e+00, 9.99259293e-01,
          6.89431906e-01, 4.10281926e-01, 8.99752855e-01,
          9.24375534e-01],
         [0.00000000e+00, 0.00000000e+00, 9.96988714e-01,
          4.78255481e-01, 4.39303011e-01, 6.92748427e-01,
          8.84738088e-01],
         [0.00000000e+00, 0.00000000e+00, 8.99450958e-01,
          7.59500206e-01, 3.65392357e-01, 7.86593020e-01,
          4.65826124e-01],
         [0.00000000e+00, 2.00000000e+00, 8.92164528e-01,
          5.86493194e-01, 3.73032689e-01, 6.27667129e-01,
          4.18615639e-01],
         [0.00000000e+00, 2.00000000e+00, 7.60227084e-01,
          5.41625261e-01, 3.59284222e-01, 5.69990754e-01,
          3.85314763e-01],
         [0.00000000e+00, 2.00000000e+00, 7.41497338e-01,
          4.75410581e-01, 3.59473735e-01, 4.97386515e-01,
          3.79805237e-01],
         [0.00000000e+00, 2.00000000e+00, 6.92948997e-01,
          3.92828494e-01, 3.70877385e-01, 4.34664756e-01,
          4.21965003e-01],
         [0.00000000e+00, 2.00000000e+00, 6.91804171e-01,
          1.81006208e-01, 3.93057227e-01, 3.14580262e-01,
          5.48215151e-01],
         [0.00000000e+00, 2.00000000e+00, 6.89624131e-01,
          4.74969536e-01, 3.63849461e-01, 4.93522853e-01,
          3.84744525e-01],
         [0.00000000e+00, 2.00000000e+00, 6.71736002e-01,
          5.55497468e-01, 3.60749632e-01, 5.80439866e-01,
          3.90315205e-01],
         [0.00000000e+00, 2.00000000e+00, 6.52131736e-01,
          5.39770365e-01, 3.56873840e-01, 5.62574983e-01,
          3.80937070e-01],
         [0.00000000e+00, 2.00000000e+00, 5.73045015e-01,
          4.90699500e-01, 3.37454706e-01, 5.16624153e-01,
          3.59009713e-01],
         [0.00000000e+00, 2.00000000e+00, 5.67916274e-01,
          5.51230371e-01, 3.58385175e-01, 5.75492680e-01,
          3.83766681e-01],
         [0.00000000e+00, 2.00000000e+00, 5.26121140e-01,
          6.24870598e-01, 3.65172297e-01, 7.20076859e-01,
          4.69361275e-01],
         [0.00000000e+00, 2.00000000e+00, 5.01187444e-01,
          5.67409754e-01, 3.63825679e-01, 5.90894938e-01,
          3.97718430e-01],
         [0.00000000e+00, 7.00000000e+00, 4.64711666e-01,
          6.20865345e-01, 3.64188731e-01, 7.15440154e-01,
          4.71168458e-01],
         [0.00000000e+00, 7.00000000e+00, 3.03259879e-01,
          1.80326447e-01, 3.91769946e-01, 3.13728631e-01,
          5.46020031e-01],
         [0.00000000e+00, 2.00000000e+00, 3.01223546e-01,
          5.74293852e-01, 3.68572682e-01, 5.96763015e-01,
          4.02530283e-01],
         [0.00000000e+00, 0.00000000e+00, 2.80752093e-01,
          7.87774682e-01, 3.81029934e-01, 8.25374126e-01,
          4.47248787e-01],
         [0.00000000e+00, 2.00000000e+00, 2.48058274e-01,
          5.23602128e-01, 3.49777788e-01, 5.40038109e-01,
          3.71462077e-01],
         [0.00000000e+00, 7.00000000e+00, 1.84282407e-01,
          3.95181656e-01, 3.71212065e-01, 4.35151696e-01,
          4.23574567e-01],
         [0.00000000e+00, 0.00000000e+00, 1.82083458e-01,
          3.73441994e-01, 3.48522216e-01, 3.83972704e-01,
          4.01509136e-01],
         [0.00000000e+00, 2.00000000e+00, 1.80037409e-01,
          4.53898787e-01, 3.45813066e-01, 4.72737730e-01,
          3.63361746e-01],
         [0.00000000e+00, 2.00000000e+00, 1.65681034e-01,
          5.17707169e-01, 3.53159130e-01, 5.33488214e-01,
          3.72920692e-01],
         [0.00000000e+00, 2.00000000e+00, 1.55796289e-01,
          4.67642099e-01, 3.54734778e-01, 4.83820230e-01,
          3.73075724e-01],
         [0.00000000e+00, 2.00000000e+00, 1.46018192e-01,
          4.92013007e-01, 3.45370203e-01, 5.14485359e-01,
          3.66457492e-01],
         [0.00000000e+00, 2.00000000e+00, 1.44557431e-01,
          4.82330412e-01, 3.55178297e-01, 5.03692985e-01,
          3.75229180e-01],
         [0.00000000e+00, 2.00000000e+00, 1.24358237e-01,
          5.11652708e-01, 3.43919307e-01, 5.30575037e-01,
          3.62588555e-01],
         [0.00000000e+00, 0.00000000e+00, 6.44718856e-02,
          2.47735411e-01, 3.34493279e-01, 1.00000000e+00,
          9.24582124e-01],
         [0.00000000e+00, 4.00000000e+01, 6.41610473e-02,
          6.07192278e-01, 7.12545931e-01, 7.36410856e-01,
          8.81260693e-01],
         [0.00000000e+00, 7.00000000e+00, 3.89110185e-02,
          4.89900410e-01, 3.35432768e-01, 5.16415656e-01,
          3.60289812e-01],
         [0.00000000e+00, 1.40000000e+01, 3.50213349e-02,
          0.00000000e+00, 5.80373943e-01, 3.05343717e-01,
          8.83919060e-01],
         [0.00000000e+00, 7.00000000e+00, 3.11381314e-02,
          5.85294187e-01, 3.69822443e-01, 6.28036797e-01,
          4.18421745e-01],
         [0.00000000e+00, 4.80000000e+01, 2.76309699e-02,
          6.02841854e-01, 7.18697369e-01, 7.30017900e-01,
          8.81516278e-01],
         [0.00000000e+00, 0.00000000e+00, 2.57278625e-02,
          9.77824926e-02, 2.72160709e-01, 9.93152618e-01,
          7.56028116e-01],
         [0.00000000e+00, 7.00000000e+00, 2.48284657e-02,
          4.75376308e-01, 3.62739325e-01, 4.93569553e-01,
          3.86044025e-01],
         [0.00000000e+00, 7.00000000e+00, 2.37590931e-02,
          4.75977302e-01, 3.58107388e-01, 4.97631490e-01,
          3.81023586e-01],
         [0.00000000e+00, 1.40000000e+01, 1.49268005e-02,
          2.09231555e-01, 5.68155050e-01, 9.33958709e-01,
          9.58911061e-01],
         [0.00000000e+00, 0.00000000e+00, 1.20805567e-02,
          3.57881904e-01, 3.67384046e-01, 8.09000254e-01,
          9.63311553e-01],
         [0.00000000e+00, 3.00000000e+00, 1.13860313e-02,
          6.24577522e-01, 3.66592944e-01, 7.21163750e-01,
          4.70143795e-01],
         [0.00000000e+00, 1.40000000e+01, 9.86425858e-03,
          5.93366086e-01, 7.20776379e-01, 7.48598635e-01,
          8.94425571e-01],
         [0.00000000e+00, 1.80000000e+01, 9.80106834e-03,
          3.69374067e-01, 3.53263438e-01, 3.88122767e-01,
          4.04582381e-01],
         [0.00000000e+00, 5.00000000e+00, 9.73206013e-03,
          4.90943849e-01, 3.34368289e-01, 5.16584456e-01,
          3.60147476e-01],
         [0.00000000e+00, 7.00000000e+00, 9.51428246e-03,
          5.40800154e-01, 3.57831746e-01, 5.69447815e-01,
          3.86951298e-01],
         [0.00000000e+00, 0.00000000e+00, 8.63239355e-03,
          7.75167346e-02, 3.32534641e-01, 6.63682640e-01,
          9.61531758e-01],
         [0.00000000e+00, 7.00000000e+00, 8.15805607e-03,
          5.66278696e-01, 3.61254185e-01, 5.91310978e-01,
          3.98629099e-01],
         [0.00000000e+00, 6.10000000e+01, 8.03491566e-03,
          9.48411226e-03, 5.67005754e-01, 2.74469912e-01,
          8.97271037e-01],
         [0.00000000e+00, 7.00000000e+00, 7.91707728e-03,
          4.91519749e-01, 3.43558937e-01, 5.14246404e-01,
          3.67203623e-01],
         [0.00000000e+00, 7.00000000e+00, 7.35445367e-03,
          4.82455522e-01, 3.53581250e-01, 5.03509045e-01,
          3.76238227e-01],
         [0.00000000e+00, 6.10000000e+01, 6.94494182e-03,
          3.68493557e-01, 3.56619209e-01, 3.87626052e-01,
          4.06094521e-01],
         [0.00000000e+00, 1.40000000e+01, 6.54783100e-03,
          6.10418618e-03, 5.79146147e-01, 4.80332553e-01,
          9.49126244e-01],
         [0.00000000e+00, 7.00000000e+00, 6.27746154e-03,
          5.36520481e-01, 3.53603184e-01, 5.59339166e-01,
          3.80841434e-01],
         [0.00000000e+00, 8.00000000e+00, 6.27476955e-03,
          3.92465830e-01, 3.68267179e-01, 4.35713470e-01,
          4.20405626e-01],
         [0.00000000e+00, 7.00000000e+00, 6.10081526e-03,
          5.73487639e-01, 3.66590977e-01, 5.97670555e-01,
          4.02794719e-01],
         [0.00000000e+00, 7.00000000e+00, 6.02893112e-03,
          5.50545931e-01, 3.56772482e-01, 5.75379252e-01,
          3.84796441e-01],
         [0.00000000e+00, 5.00000000e+00, 6.00703713e-03,
          3.94118249e-01, 3.67898315e-01, 4.36152458e-01,
          4.22300309e-01],
         [0.00000000e+00, 3.40000000e+01, 5.94002195e-03,
          5.98778367e-01, 7.17872977e-01, 7.40862012e-01,
          8.79907966e-01],
         [0.00000000e+00, 7.00000000e+00, 5.79615124e-03,
          5.54574192e-01, 3.59007031e-01, 5.80113471e-01,
          3.91549677e-01],
         [0.00000000e+00, 7.00000000e+00, 4.96817240e-03,
          4.53043997e-01, 3.44320834e-01, 4.72617805e-01,
          3.63990903e-01],
         [0.00000000e+00, 6.60000000e+01, 4.74483147e-03,
          2.07151055e-01, 5.94048738e-01, 9.01062369e-01,
          9.79222536e-01],
         [0.00000000e+00, 7.00000000e+00, 4.69966512e-03,
          5.23367345e-01, 3.47458959e-01, 5.39889514e-01,
          3.72587383e-01],
         [0.00000000e+00, 8.00000000e+00, 4.12739906e-03,
          2.42405355e-01, 4.13437188e-01, 1.00000000e+00,
          9.96230662e-01],
         [0.00000000e+00, 0.00000000e+00, 3.82863800e-03,
          5.75615525e-01, 3.65983993e-01, 5.93157053e-01,
          4.05264348e-01],
         [0.00000000e+00, 1.80000000e+01, 3.60784982e-03,
          7.86790192e-01, 3.83652985e-01, 8.28235924e-01,
          4.46530521e-01],
         [0.00000000e+00, 6.10000000e+01, 3.60408914e-03,
          6.02209210e-01, 7.07144618e-01, 7.39261031e-01,
          8.89606953e-01],
         [0.00000000e+00, 6.60000000e+01, 3.53453867e-03,
          0.00000000e+00, 5.97515285e-01, 3.01365823e-01,
          9.19872701e-01],
         [0.00000000e+00, 3.00000000e+00, 3.25129787e-03,
          4.75844175e-01, 3.64978939e-01, 4.93122607e-01,
          3.87378484e-01],
         [0.00000000e+00, 3.00000000e+01, 3.12937191e-03,
          5.98151803e-01, 7.17014194e-01, 7.34741688e-01,
          8.88292432e-01],
         [0.00000000e+00, 6.60000000e+01, 3.06002260e-03,
          4.56096232e-03, 6.12245083e-01, 4.85649884e-01,
          9.69758630e-01],
         [0.00000000e+00, 7.00000000e+00, 2.90708686e-03,
          5.11513233e-01, 3.41565341e-01, 5.30220985e-01,
          3.63441139e-01],
         [0.00000000e+00, 6.10000000e+01, 2.83700530e-03,
          7.70215616e-02, 4.76723969e-01, 2.50199080e-01,
          8.57185423e-01],
         [0.00000000e+00, 1.40000000e+01, 2.74842582e-03,
          5.61820269e-02, 5.39402723e-01, 7.73234487e-01,
          9.54025507e-01],
         [0.00000000e+00, 6.00000000e+00, 2.64789513e-03,
          3.92966747e-01, 3.65466624e-01, 4.37269211e-01,
          4.24340516e-01],
         [0.00000000e+00, 7.00000000e+00, 2.45322683e-03,
          4.67577040e-01, 3.53129745e-01, 4.83946383e-01,
          3.74349356e-01],
         [0.00000000e+00, 7.00000000e+00, 2.38776905e-03,
          5.18215060e-01, 3.50189179e-01, 5.32959819e-01,
          3.73705477e-01],
         [0.00000000e+00, 2.00000000e+01, 2.28653685e-03,
          3.68863255e-01, 3.54681790e-01, 3.88738900e-01,
          4.05850708e-01],
         [0.00000000e+00, 3.50000000e+01, 2.26170523e-03,
          5.90554714e-01, 7.20685124e-01, 7.43540645e-01,
          8.82087827e-01],
         [0.00000000e+00, 2.00000000e+00, 2.25718343e-03,
          1.07380599e-01, 2.82831281e-01, 9.75862503e-01,
          7.10785866e-01],
         [0.00000000e+00, 5.00000000e+00, 2.10479973e-03,
          6.23704851e-01, 3.60841870e-01, 7.15491116e-01,
          4.64615941e-01],
         [0.00000000e+00, 3.00000000e+01, 2.07235990e-03,
          7.61325955e-01, 4.97121066e-01, 8.57526898e-01,
          7.35164285e-01],
         [0.00000000e+00, 0.00000000e+00, 1.92974054e-03,
          5.69738805e-01, 3.60520869e-01, 5.87458193e-01,
          4.02149826e-01],
         [0.00000000e+00, 6.00000000e+00, 1.89443154e-03,
          6.19646788e-01, 3.58304083e-01, 7.22060442e-01,
          4.69268739e-01],
         [0.00000000e+00, 7.00000000e+00, 1.81595772e-03,
          2.94367850e-01, 3.67994905e-01, 9.78064239e-01,
          9.30691838e-01],
         [0.00000000e+00, 2.00000000e+00, 1.69707532e-03,
          3.67421329e-01, 3.52760375e-01, 3.88726890e-01,
          4.00401950e-01],
         [0.00000000e+00, 5.00000000e+00, 1.67935912e-03,
          1.83898658e-01, 3.96509379e-01, 3.14183682e-01,
          5.44656634e-01],
         [0.00000000e+00, 3.00000000e+01, 1.63409393e-03,
          7.44515300e-01, 5.09966493e-01, 8.59870315e-01,
          8.15174937e-01],
         [0.00000000e+00, 1.00000000e+00, 1.61926937e-03,
          1.97852850e-02, 6.16704047e-01, 2.86476463e-01,
          9.02087033e-01],
         [0.00000000e+00, 2.60000000e+01, 1.54944754e-03,
          7.88556397e-01, 3.88741016e-01, 8.25305283e-01,
          4.40299392e-01],
         [0.00000000e+00, 8.60000000e+01, 1.52406318e-03,
          6.01132929e-01, 7.01487243e-01, 7.45222032e-01,
          8.93119633e-01],
         [0.00000000e+00, 4.10000000e+01, 1.51528139e-03,
          1.27276778e-03, 5.96581340e-01, 2.87025869e-01,
          8.85573030e-01],
         [0.00000000e+00, 3.40000000e+01, 1.39231631e-03,
          1.54019147e-02, 5.85525215e-01, 2.69098401e-01,
          8.94322455e-01],
         [0.00000000e+00, 6.10000000e+01, 1.37677998e-03,
          7.26888597e-01, 4.86116469e-01, 8.74394596e-01,
          8.61851394e-01],
         [0.00000000e+00, 6.00000000e+00, 1.32521265e-03,
          2.50652373e-01, 3.20080727e-01, 9.70555842e-01,
          9.49614763e-01],
         [0.00000000e+00, 3.10000000e+01, 1.31424330e-03,
          5.97983420e-01, 7.21269786e-01, 7.30159581e-01,
          8.85436714e-01],
         [0.00000000e+00, 2.00000000e+01, 1.28290569e-03,
          7.85527527e-01, 3.84867609e-01, 8.27534974e-01,
          4.46104646e-01],
         [0.00000000e+00, 4.10000000e+01, 1.23773608e-03,
          5.96185803e-01, 7.16784298e-01, 7.41377950e-01,
          8.89733970e-01],
         [0.00000000e+00, 0.00000000e+00, 1.18559075e-03,
          1.10947818e-01, 4.59801197e-01, 8.95728469e-01,
          9.50373650e-01],
         [0.00000000e+00, 3.00000000e+00, 1.17662584e-03,
          4.76408273e-01, 3.60545278e-01, 4.97020155e-01,
          3.82405043e-01]]]], dtype=float32)

단일 이미지의 object detection을 함수로 생성

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import time

def get_detected_img(cv_net, img_array, score_threshold, use_copied_array=True, is_print=True):

    rows = img_array.shape[0]
    cols = img_array.shape[1]

    draw_img = None
    if use_copied_array:
        draw_img = img_array.copy()
    else:
        draw_img = img_array

    cv_net.setInput(cv2.dnn.blobFromImage(img_array, swapRB=True, crop=False))

    start = time.time()
    cv_out = cv_net.forward()

    green_color=(0, 255, 0)
    red_color=(0, 0, 255)

    # detected 된 object들을 iteration 하면서 정보 추출
    for detection in cv_out[0,0,:,:]:
        score = float(detection[2])
        class_id = int(detection[1])
        # detected된 object들의 score가 함수 인자로 들어온 score_threshold 이상만 추출
        if score > score_threshold:
            # detected된 object들은 scale된 기준으로 예측되었으므로 다시 원본 이미지 비율로 계산
            left = detection[3] * cols
            top = detection[4] * rows
            right = detection[5] * cols
            bottom = detection[6] * rows
            # labels_to_names 딕셔너리로 class_id값을 클래스명으로 변경. opencv에서는 class_id + 1로 매핑해야함.
            caption = "{}: {:.4f}".format(labels_to_names_0[class_id], score)
            print(caption)
            #cv2.rectangle()은 인자로 들어온 draw_img에 사각형을 그림. 위치 인자는 반드시 정수형.
            cv2.rectangle(draw_img, (int(left), int(top)), (int(right), int(bottom)), color=green_color, thickness=2)
            cv2.putText(draw_img, caption, (int(left), int(top - 5)), cv2.FONT_HERSHEY_SIMPLEX, 0.4, red_color, 1)
    if is_print:
        print('Detection 수행시간:',round(time.time() - start, 2),"")

    return draw_img
1
2
3
4
5
6
7
8
9
10
11
12
13
14
# image 로드
img = cv2.imread('./data/beatles01.jpg')
print('image shape:', img.shape)

# tensorflow inference 모델 로딩
cv_net = cv2.dnn.readNetFromTensorflow('./pretrained/faster_rcnn_resnet50_coco_2018_01_28/frozen_inference_graph.pb',
                                     './pretrained/config_graph.pbtxt')
# Object Detetion 수행 후 시각화
draw_img = get_detected_img(cv_net, img, score_threshold=0.5, use_copied_array=True, is_print=True)

img_rgb = cv2.cvtColor(draw_img, cv2.COLOR_BGR2RGB)

plt.figure(figsize=(12, 12))
plt.imshow(img_rgb)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
image shape: (633, 806, 3)
person: 0.9998
person: 0.9996
person: 0.9993
person: 0.9970
person: 0.8995
car: 0.8922
car: 0.7602
car: 0.7415
car: 0.6929
car: 0.6918
car: 0.6896
car: 0.6717
car: 0.6521
car: 0.5730
car: 0.5679
car: 0.5261
car: 0.5012
Detection 수행시간: 4.93 초





<matplotlib.image.AxesImage at 0x7ec0aae95000>

1
2
# 다른 image 테스트
!wget -O ./data/baseball01.jpg https://raw.githubusercontent.com/chulminkw/DLCV/master/data/image/baseball01.jpg
1
2
3
4
5
6
7
8
9
10
--2023-11-22 06:21:38--  https://raw.githubusercontent.com/chulminkw/DLCV/master/data/image/baseball01.jpg
Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 185.199.110.133, 185.199.111.133, 185.199.108.133, ...
Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|185.199.110.133|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 76279 (74K) [image/jpeg]
Saving to: ‘./data/baseball01.jpg’

./data/baseball01.j 100%[===================>]  74.49K  --.-KB/s    in 0.02s   

2023-11-22 06:21:39 (2.98 MB/s) - ‘./data/baseball01.jpg’ saved [76279/76279]
1
2
3
4
5
6
7
8
9
10
11
12
13
img = cv2.imread('./data/baseball01.jpg')
print('image shape:', img.shape)

# tensorflow inference 모델 로딩
cv_net = cv2.dnn.readNetFromTensorflow('./pretrained/faster_rcnn_resnet50_coco_2018_01_28/frozen_inference_graph.pb',
                                     './pretrained/config_graph.pbtxt')
# Object Detetion 수행 후 시각화
draw_img = get_detected_img(cv_net, img, score_threshold=0.5, use_copied_array=True, is_print=True)

img_rgb = cv2.cvtColor(draw_img, cv2.COLOR_BGR2RGB)

plt.figure(figsize=(12, 12))
plt.imshow(img_rgb)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
image shape: (476, 735, 3)
person: 0.9998
person: 0.9997
person: 0.9977
baseball glove: 0.9815
sports ball: 0.8867
baseball bat: 0.8420
Detection 수행시간: 4.8 초





<matplotlib.image.AxesImage at 0x7ec0aad40c10>

Video Object Detection 수행

원본 영상 보기

1
!wget -O ./data/Jonh_Wick_small.mp4 https://github.com/chulminkw/DLCV/blob/master/data/video/John_Wick_small.mp4?raw=true
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
--2023-11-22 06:21:45--  https://github.com/chulminkw/DLCV/blob/master/data/video/John_Wick_small.mp4?raw=true
Resolving github.com (github.com)... 140.82.114.4
Connecting to github.com (github.com)|140.82.114.4|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://github.com/chulminkw/DLCV/raw/master/data/video/John_Wick_small.mp4 [following]
--2023-11-22 06:21:45--  https://github.com/chulminkw/DLCV/raw/master/data/video/John_Wick_small.mp4
Reusing existing connection to github.com:443.
HTTP request sent, awaiting response... 302 Found
Location: https://raw.githubusercontent.com/chulminkw/DLCV/master/data/video/John_Wick_small.mp4 [following]
--2023-11-22 06:21:45--  https://raw.githubusercontent.com/chulminkw/DLCV/master/data/video/John_Wick_small.mp4
Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 185.199.110.133, 185.199.111.133, 185.199.108.133, ...
Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|185.199.110.133|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1794863 (1.7M) [application/octet-stream]
Saving to: ‘./data/Jonh_Wick_small.mp4’

./data/Jonh_Wick_sm 100%[===================>]   1.71M  --.-KB/s    in 0.08s   

2023-11-22 06:21:46 (22.3 MB/s) - ‘./data/Jonh_Wick_small.mp4’ saved [1794863/1794863]

VideoCapture와 VideoWriter 설정하기

  • VideoCapture를 이용하여 Video를 frame별로 capture 할 수 있도록 설정
  • VideoCapture의 속성을 이용하여 Video Frame의 크기 및 FPS 설정.
  • VideoWriter를 위한 인코딩 코덱 설정 및 영상 write를 위한 설정
1
2
3
4
5
video_input_path = '/content/data/Jonh_Wick_small.mp4'

cap = cv2.VideoCapture(video_input_path)
frame_cnt = int(cap.get(cv2.CAP_PROP_FRAME_COUNT))
print('총 Frame 갯수:', frame_cnt)
1
총 Frame 갯수: 58
1
2
3
4
5
6
7
8
9
10
11
12
13
14
video_input_path = '/content/data/Jonh_Wick_small.mp4'
video_output_path = './data/John_Wick_small_cv01.mp4'

cap = cv2.VideoCapture(video_input_path)

codec = cv2.VideoWriter_fourcc(*'XVID')

vid_size = (round(cap.get(cv2.CAP_PROP_FRAME_WIDTH)),round(cap.get(cv2.CAP_PROP_FRAME_HEIGHT)))
vid_fps = cap.get(cv2.CAP_PROP_FPS )

vid_writer = cv2.VideoWriter(video_output_path, codec, vid_fps, vid_size)

frame_cnt = int(cap.get(cv2.CAP_PROP_FRAME_COUNT))
print('총 Frame 갯수:', frame_cnt)
1
총 Frame 갯수: 58
총 Frame 별로 iteration 하면서 Object Detection 수행. 개별 frame별로 단일 이미지 Object Detection과 유사
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# bounding box의 테두리와 caption 글자색 지정
green_color=(0, 255, 0)
red_color=(0, 0, 255)

while True:

    hasFrame, img_frame = cap.read()
    if not hasFrame:
        print('더 이상 처리할 frame이 없습니다.')
        break

    rows = img_frame.shape[0]
    cols = img_frame.shape[1]
    # 원본 이미지 배열 BGR을 RGB로 변환하여 배열 입력
    cv_net.setInput(cv2.dnn.blobFromImage(img_frame,  swapRB=True, crop=False))

    start= time.time()
    # Object Detection 수행하여 결과를 cv_out으로 반환
    cv_out = cv_net.forward()
    frame_index = 0
    # detected 된 object들을 iteration 하면서 정보 추출
    for detection in cv_out[0,0,:,:]:
        score = float(detection[2])
        class_id = int(detection[1])
        # detected된 object들의 score가 0.5 이상만 추출
        if score > 0.5:
            # detected된 object들은 scale된 기준으로 예측되었으므로 다시 원본 이미지 비율로 계산
            left = detection[3] * cols
            top = detection[4] * rows
            right = detection[5] * cols
            bottom = detection[6] * rows
            # labels_to_names_0딕셔너리로 class_id값을 클래스명으로 변경.
            caption = "{}: {:.4f}".format(labels_to_names_0[class_id], score)
            #print(class_id, caption)
            #cv2.rectangle()은 인자로 들어온 draw_img에 사각형을 그림. 위치 인자는 반드시 정수형.
            cv2.rectangle(img_frame, (int(left), int(top)), (int(right), int(bottom)), color=green_color, thickness=2)
            cv2.putText(img_frame, caption, (int(left), int(top - 5)), cv2.FONT_HERSHEY_SIMPLEX, 0.5, red_color, 1)
    print('Detection 수행 시간:', round(time.time()-start, 2),'')
    vid_writer.write(img_frame)
# end of while loop

vid_writer.release()
cap.release()
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
Detection 수행 시간: 5.02 초
Detection 수행 시간: 4.59 초
Detection 수행 시간: 5.85 초
Detection 수행 시간: 4.67 초
Detection 수행 시간: 4.53 초
Detection 수행 시간: 6.21 초
Detection 수행 시간: 5.82 초
Detection 수행 시간: 4.55 초
Detection 수행 시간: 5.97 초
Detection 수행 시간: 4.52 초
Detection 수행 시간: 4.46 초
Detection 수행 시간: 6.01 초
Detection 수행 시간: 4.43 초
Detection 수행 시간: 4.48 초
Detection 수행 시간: 5.88 초
Detection 수행 시간: 4.47 초
Detection 수행 시간: 4.45 초
Detection 수행 시간: 5.91 초
Detection 수행 시간: 4.51 초
Detection 수행 시간: 4.54 초
Detection 수행 시간: 5.83 초
Detection 수행 시간: 4.48 초
Detection 수행 시간: 4.83 초
Detection 수행 시간: 5.64 초
Detection 수행 시간: 4.56 초
Detection 수행 시간: 5.01 초
Detection 수행 시간: 5.41 초
Detection 수행 시간: 4.49 초
Detection 수행 시간: 5.31 초
Detection 수행 시간: 5.32 초
Detection 수행 시간: 4.62 초
Detection 수행 시간: 5.49 초
Detection 수행 시간: 5.12 초
Detection 수행 시간: 4.43 초
Detection 수행 시간: 5.4 초
Detection 수행 시간: 4.99 초
Detection 수행 시간: 4.49 초
Detection 수행 시간: 5.63 초
Detection 수행 시간: 4.77 초
Detection 수행 시간: 4.45 초
Detection 수행 시간: 5.71 초
Detection 수행 시간: 4.65 초
Detection 수행 시간: 4.5 초
Detection 수행 시간: 5.89 초
Detection 수행 시간: 4.58 초
Detection 수행 시간: 4.5 초
Detection 수행 시간: 6.01 초
Detection 수행 시간: 4.56 초
Detection 수행 시간: 4.48 초
Detection 수행 시간: 5.97 초
Detection 수행 시간: 4.46 초
Detection 수행 시간: 4.5 초
Detection 수행 시간: 5.86 초
Detection 수행 시간: 4.47 초
Detection 수행 시간: 4.48 초
Detection 수행 시간: 5.93 초
Detection 수행 시간: 4.45 초
Detection 수행 시간: 4.56 초
더 이상 처리할 frame이 없습니다.

video detection 전용 함수 생성.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
def do_detected_video(cv_net, input_path, output_path, score_threshold, is_print):

    cap = cv2.VideoCapture(input_path)

    codec = cv2.VideoWriter_fourcc(*'XVID')

    vid_size = (round(cap.get(cv2.CAP_PROP_FRAME_WIDTH)),round(cap.get(cv2.CAP_PROP_FRAME_HEIGHT)))
    vid_fps = cap.get(cv2.CAP_PROP_FPS)

    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)

    green_color=(0, 255, 0)
    red_color=(0, 0, 255)
    while True:
        hasFrame, img_frame = cap.read()
        if not hasFrame:
            print('더 이상 처리할 frame이 없습니다.')
            break

        img_frame = get_detected_img(cv_net, img_frame, score_threshold=score_threshold, use_copied_array=False, is_print=is_print)

        vid_writer.write(img_frame)
    # end of while loop

    vid_writer.release()
    cap.release()
1
do_detected_video(cv_net, '/content/data/Jonh_Wick_small.mp4', './data/John_Wick_small_02.mp4', 0.2, False)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
총 Frame 갯수: 58
car: 0.9882
car: 0.9622
person: 0.9495
car: 0.9266
car: 0.8772
motorcycle: 0.6607
car: 0.3988
car: 0.3763
bicycle: 0.3498
person: 0.2871
car: 0.2583
car: 0.2150
book: 0.2069
car: 0.9881
car: 0.9643
person: 0.9581
car: 0.9318
car: 0.8992
motorcycle: 0.5682
person: 0.4459
car: 0.4418
bicycle: 0.4216
car: 0.4189
person: 0.2940
car: 0.2545
car: 0.2318
car: 0.9903
car: 0.9833
motorcycle: 0.9532
car: 0.9115
car: 0.8625
person: 0.7814
person: 0.5169
car: 0.4893
car: 0.4251
person: 0.3087
airplane: 0.2046
car: 0.9919
car: 0.9909
car: 0.9870
motorcycle: 0.8655
person: 0.7585
person: 0.7484
person: 0.7375
car: 0.7361
person: 0.7200
car: 0.6120
umbrella: 0.4362
person: 0.3580
person: 0.2285
person: 0.2171
car: 0.9933
car: 0.9817
motorcycle: 0.9781
car: 0.9530
car: 0.7823
person: 0.5313
person: 0.4869
truck: 0.4717
person: 0.4709
car: 0.2064
car: 0.9799
car: 0.9678
car: 0.9496
person: 0.8299
car: 0.6521
motorcycle: 0.6003
person: 0.4792
car: 0.4465
car: 0.4120
person: 0.2719
truck: 0.2605
car: 0.2396
car: 0.2354
car: 0.2019
car: 0.9809
car: 0.9647
car: 0.9632
person: 0.8467
car: 0.7496
car: 0.6391
motorcycle: 0.5894
person: 0.5808
car: 0.4643
person: 0.2547
person: 0.2523
cup: 0.2440
car: 0.2424
truck: 0.2293
car: 0.9844
motorcycle: 0.9825
car: 0.9683
car: 0.9670
car: 0.5693
car: 0.4446
person: 0.4043
truck: 0.3849
person: 0.3756
person: 0.3400
car: 0.9877
car: 0.9737
car: 0.9403
car: 0.9125
motorcycle: 0.8699
person: 0.6535
car: 0.4144
bird: 0.2821
cup: 0.2633
person: 0.2619
person: 0.2481
person: 0.2201
car: 0.2150
car: 0.9902
car: 0.9878
car: 0.9599
motorcycle: 0.9435
car: 0.7138
person: 0.5800
cup: 0.5553
person: 0.4904
person: 0.3368
person: 0.2976
car: 0.2952
car: 0.2379
car: 0.9907
car: 0.9776
motorcycle: 0.9524
car: 0.8853
person: 0.8192
car: 0.6970
person: 0.6404
cup: 0.3994
bicycle: 0.3949
motorcycle: 0.3554
motorcycle: 0.3481
person: 0.2300
car: 0.9841
car: 0.9781
motorcycle: 0.9241
car: 0.7169
motorcycle: 0.5577
motorcycle: 0.4566
car: 0.4485
person: 0.4420
motorcycle: 0.4212
cup: 0.3727
car: 0.3612
truck: 0.2527
bicycle: 0.2126
bus: 0.2101
car: 0.2005
person: 0.9901
car: 0.9869
car: 0.9866
motorcycle: 0.9701
car: 0.8183
car: 0.7574
car: 0.6915
bicycle: 0.6210
motorcycle: 0.5741
bicycle: 0.5092
truck: 0.4533
motorcycle: 0.4033
person: 0.3662
car: 0.3278
car: 0.2578
person: 0.2368
car: 0.9957
car: 0.9825
person: 0.9698
motorcycle: 0.9445
car: 0.7977
person: 0.7839
car: 0.7749
car: 0.6895
person: 0.5858
car: 0.4500
person: 0.4353
bicycle: 0.4259
person: 0.4199
car: 0.3546
truck: 0.3052
motorcycle: 0.3046
motorcycle: 0.2502
car: 0.9949
motorcycle: 0.9842
person: 0.9788
car: 0.9764
car: 0.9244
car: 0.8736
person: 0.7939
car: 0.7762
person: 0.6404
car: 0.6390
bicycle: 0.4425
person: 0.4230
car: 0.3565
truck: 0.3405
person: 0.3094
motorcycle: 0.2526
motorcycle: 0.2243
car: 0.9647
car: 0.9598
car: 0.9365
person: 0.9282
motorcycle: 0.8955
car: 0.8722
car: 0.7995
person: 0.6669
person: 0.6577
person: 0.5404
bicycle: 0.3739
motorcycle: 0.3376
car: 0.2960
motorcycle: 0.2904
car: 0.9745
car: 0.9696
person: 0.9340
motorcycle: 0.9148
person: 0.9073
car: 0.8388
car: 0.8164
motorcycle: 0.6961
person: 0.6480
car: 0.3133
bicycle: 0.2909
motorcycle: 0.2772
motorcycle: 0.2301
car: 0.2115
car: 0.9891
person: 0.9882
motorcycle: 0.9654
car: 0.9549
person: 0.9152
person: 0.8825
car: 0.7725
car: 0.7310
motorcycle: 0.7143
person: 0.7120
car: 0.5168
bottle: 0.3688
bicycle: 0.2378
motorcycle: 0.2119
motorcycle: 0.2001
person: 0.9954
motorcycle: 0.9814
car: 0.9679
car: 0.9650
car: 0.9215
car: 0.8846
person: 0.7777
motorcycle: 0.7036
car: 0.7027
person: 0.6045
truck: 0.4509
car: 0.4450
car: 0.3449
motorcycle: 0.2720
person: 0.2447
person: 0.9929
motorcycle: 0.9765
car: 0.9655
car: 0.9567
car: 0.9439
car: 0.8923
person: 0.7470
motorcycle: 0.7363
person: 0.6892
car: 0.6779
car: 0.5399
truck: 0.4182
person: 0.3035
car: 0.2959
motorcycle: 0.2642
car: 0.2374
person: 0.9970
car: 0.9527
motorcycle: 0.9130
car: 0.8177
person: 0.7596
car: 0.7438
person: 0.7293
car: 0.5823
motorcycle: 0.5488
car: 0.4609
car: 0.3970
person: 0.3759
car: 0.3581
person: 0.9970
car: 0.9496
motorcycle: 0.9380
car: 0.9329
person: 0.8679
car: 0.8679
car: 0.8658
car: 0.8487
motorcycle: 0.5940
person: 0.4911
bicycle: 0.2710
car: 0.2265
person: 0.9918
car: 0.9297
car: 0.9136
car: 0.8933
car: 0.8894
person: 0.8712
car: 0.8535
motorcycle: 0.8233
motorcycle: 0.7279
car: 0.6941
bus: 0.4408
truck: 0.3496
car: 0.3402
chair: 0.2794
person: 0.2701
motorcycle: 0.2564
truck: 0.2343
person: 0.9937
person: 0.9902
person: 0.9007
person: 0.8891
car: 0.8629
person: 0.7491
motorcycle: 0.6533
car: 0.6490
motorcycle: 0.6412
bus: 0.6101
car: 0.5802
backpack: 0.3946
tie: 0.3124
book: 0.2827
horse: 0.2626
bus: 0.2520
person: 0.9946
person: 0.9943
car: 0.9678
person: 0.8935
person: 0.8771
car: 0.8286
bus: 0.7770
person: 0.7719
horse: 0.7242
car: 0.6825
person: 0.5186
backpack: 0.4447
tie: 0.4062
car: 0.3354
motorcycle: 0.3290
book: 0.3098
car: 0.2145
motorcycle: 0.2080
bus: 0.2029
person: 0.9940
person: 0.9909
motorcycle: 0.9492
person: 0.9134
car: 0.8806
horse: 0.8115
person: 0.7574
car: 0.5957
car: 0.5931
bottle: 0.4080
motorcycle: 0.4030
backpack: 0.3690
tie: 0.3613
car: 0.3185
car: 0.2986
person: 0.9950
person: 0.9756
horse: 0.9391
car: 0.9195
car: 0.8674
person: 0.8166
motorcycle: 0.7987
backpack: 0.4910
car: 0.4774
bus: 0.4362
car: 0.3393
tie: 0.3350
person: 0.2950
car: 0.2495
car: 0.9969
person: 0.9928
person: 0.9915
horse: 0.9488
motorcycle: 0.9010
car: 0.8352
person: 0.6850
person: 0.6366
car: 0.5806
tie: 0.3954
backpack: 0.3952
person: 0.9901
horse: 0.9859
person: 0.9792
car: 0.9536
motorcycle: 0.9383
car: 0.8917
tie: 0.7203
person: 0.6974
person: 0.4848
person: 0.4523
car: 0.2506
car: 0.2439
person: 0.9932
horse: 0.9855
person: 0.9852
car: 0.9675
car: 0.9271
motorcycle: 0.9235
tie: 0.7668
person: 0.6755
person: 0.4859
person: 0.4302
car: 0.4201
car: 0.2362
person: 0.2272
person: 0.9936
car: 0.9934
person: 0.9909
horse: 0.9586
car: 0.9119
motorcycle: 0.8364
person: 0.7698
tie: 0.3867
car: 0.2644
car: 0.2642
person: 0.9845
person: 0.9764
horse: 0.9675
car: 0.9639
motorcycle: 0.8961
person: 0.8735
car: 0.6855
person: 0.5583
tie: 0.4867
car: 0.4057
backpack: 0.2925
person: 0.2217
person: 0.9917
person: 0.9785
person: 0.9374
car: 0.9359
motorcycle: 0.9042
person: 0.8649
horse: 0.7944
tie: 0.5588
person: 0.5491
car: 0.3204
car: 0.9968
person: 0.9956
motorcycle: 0.9356
person: 0.9244
person: 0.8594
horse: 0.7290
car: 0.6477
person: 0.6388
tie: 0.4539
person: 0.3829
person: 0.3750
car: 0.3435
bus: 0.3412
car: 0.9971
person: 0.9945
motorcycle: 0.9419
person: 0.8980
person: 0.8587
horse: 0.7697
car: 0.6937
person: 0.6066
tie: 0.4593
person: 0.3755
car: 0.3697
bus: 0.2207
car: 0.9980
horse: 0.9905
person: 0.9779
person: 0.9763
person: 0.9174
car: 0.8977
car: 0.8216
person: 0.6501
person: 0.6422
motorcycle: 0.6399
car: 0.6033
person: 0.3897
tie: 0.3675
car: 0.3668
car: 0.3286
bicycle: 0.2602
backpack: 0.2587
car: 0.2369
person: 0.2210
car: 0.9988
person: 0.9967
horse: 0.9927
person: 0.9688
person: 0.8231
car: 0.6273
car: 0.6083
bicycle: 0.5841
person: 0.4549
person: 0.3365
tie: 0.3003
car: 0.2711
motorcycle: 0.2652
car: 0.9982
person: 0.9904
horse: 0.9824
person: 0.9789
person: 0.9186
person: 0.6977
tie: 0.4522
truck: 0.4071
bicycle: 0.4023
car: 0.3720
car: 0.3719
person: 0.3307
motorcycle: 0.3050
car: 0.2776
car: 0.2710
car: 0.2667
person: 0.9955
car: 0.9955
person: 0.9789
car: 0.9395
horse: 0.8212
person: 0.8055
person: 0.7017
person: 0.6686
tie: 0.6387
car: 0.6380
backpack: 0.3793
motorcycle: 0.3448
car: 0.3180
car: 0.2932
person: 0.2562
bicycle: 0.2172
person: 0.9973
car: 0.9955
person: 0.9930
car: 0.9488
horse: 0.8301
person: 0.7948
person: 0.7185
tie: 0.6364
car: 0.5763
motorcycle: 0.4957
bus: 0.3036
backpack: 0.3011
car: 0.2646
person: 0.2550
car: 0.2431
truck: 0.2317
person: 0.2168
car: 0.9970
person: 0.9925
person: 0.9837
car: 0.9669
horse: 0.9540
person: 0.8208
person: 0.6790
car: 0.6660
tie: 0.5785
dining table: 0.5703
car: 0.5010
backpack: 0.4517
bicycle: 0.4228
car: 0.4047
tie: 0.3814
car: 0.3004
car: 0.2022
car: 0.9955
person: 0.9784
car: 0.9749
horse: 0.9373
person: 0.9296
person: 0.8978
person: 0.7294
person: 0.6772
person: 0.6544
person: 0.5553
car: 0.4921
car: 0.4612
person: 0.3831
motorcycle: 0.3362
tie: 0.3263
person: 0.3160
motorcycle: 0.3093
person: 0.3000
bottle: 0.2946
backpack: 0.2656
car: 0.9924
person: 0.9762
car: 0.9702
person: 0.9644
horse: 0.9467
person: 0.7758
person: 0.7141
car: 0.5701
tie: 0.4508
car: 0.4143
person: 0.2801
car: 0.9956
person: 0.9880
person: 0.9632
car: 0.9593
horse: 0.9463
car: 0.7951
person: 0.7122
person: 0.6594
person: 0.6392
car: 0.4182
person: 0.3084
car: 0.2890
person: 0.2577
car: 0.2015
car: 0.9958
person: 0.9859
car: 0.9667
person: 0.9529
horse: 0.9386
car: 0.7554
person: 0.7041
person: 0.6600
car: 0.5186
car: 0.4647
person: 0.3403
person: 0.2593
car: 0.2129
car: 0.2093
person: 0.9935
car: 0.9926
person: 0.9550
car: 0.9331
horse: 0.8945
car: 0.6492
person: 0.5894
person: 0.5273
person: 0.4070
car: 0.3987
motorcycle: 0.3858
tie: 0.3529
car: 0.3068
person: 0.2932
person: 0.2888
person: 0.2804
car: 0.2436
car: 0.2163
car: 0.9887
person: 0.9568
car: 0.9032
person: 0.9026
car: 0.8810
person: 0.8793
horse: 0.4804
car: 0.4410
elephant: 0.4073
person: 0.3530
car: 0.3450
person: 0.3237
tie: 0.2947
person: 0.2725
person: 0.2691
person: 0.2532
person: 0.2348
car: 0.9849
person: 0.9607
car: 0.9552
person: 0.9462
car: 0.9236
horse: 0.8286
person: 0.5502
person: 0.5346
tie: 0.4882
car: 0.2624
car: 0.2494
car: 0.2335
car: 0.2301
cow: 0.2228
car: 0.9800
car: 0.9777
horse: 0.9668
person: 0.9541
car: 0.9503
person: 0.9359
motorcycle: 0.7502
car: 0.5679
person: 0.5251
person: 0.4887
person: 0.4060
tie: 0.4052
car: 0.3347
person: 0.3163
car: 0.2763
person: 0.2183
car: 0.2166
car: 0.9862
horse: 0.9747
car: 0.9629
person: 0.9467
car: 0.9432
person: 0.9395
motorcycle: 0.8648
car: 0.5876
person: 0.5597
person: 0.4821
tie: 0.3964
person: 0.3681
car: 0.3443
person: 0.3048
car: 0.2825
person: 0.2787
car: 0.2748
person: 0.2516
car: 0.9972
person: 0.9928
car: 0.9826
person: 0.9814
car: 0.9783
car: 0.9098
horse: 0.8984
car: 0.6470
person: 0.5902
motorcycle: 0.4925
toothbrush: 0.4216
tie: 0.4092
person: 0.3966
car: 0.3155
person: 0.2538
car: 0.9987
person: 0.9948
car: 0.9690
person: 0.9632
horse: 0.9015
car: 0.8703
car: 0.7212
person: 0.6859
person: 0.6433
suitcase: 0.3733
car: 0.3009
person: 0.2986
tie: 0.2826
person: 0.2655
person: 0.2293
motorcycle: 0.2256
car: 0.9974
person: 0.9900
person: 0.9703
car: 0.9473
car: 0.9213
horse: 0.9101
tie: 0.8922
person: 0.8296
car: 0.8060
car: 0.6353
person: 0.6110
suitcase: 0.5954
car: 0.3395
car: 0.2918
person: 0.2778
motorcycle: 0.2572
car: 0.9979
person: 0.9566
car: 0.9483
car: 0.9346
person: 0.9068
car: 0.8925
horse: 0.8732
tie: 0.7236
person: 0.7002
person: 0.6212
car: 0.5415
car: 0.3162
person: 0.2832
person: 0.2831
motorcycle: 0.2528
person: 0.2501
person: 0.2033
car: 0.9982
person: 0.9635
car: 0.9531
person: 0.9457
horse: 0.9248
car: 0.8991
car: 0.8901
person: 0.7725
person: 0.6168
tie: 0.4165
person: 0.3911
car: 0.3438
person: 0.3160
person: 0.2786
motorcycle: 0.2582
car: 0.2200
person: 0.2133
car: 0.9983
person: 0.9781
car: 0.9625
horse: 0.9336
person: 0.9185
tie: 0.8509
person: 0.7062
car: 0.5896
car: 0.5503
car: 0.5202
car: 0.4539
person: 0.3827
person: 0.3132
bicycle: 0.2274
car: 0.2052
car: 0.9954
car: 0.9928
person: 0.9834
person: 0.9706
tie: 0.7990
horse: 0.7551
car: 0.7481
person: 0.5980
car: 0.2928
person: 0.2792
person: 0.2757
car: 0.2199
backpack: 0.2020
car: 0.9960
car: 0.9896
person: 0.9528
person: 0.9082
horse: 0.8085
car: 0.7858
person: 0.7171
car: 0.7106
car: 0.5665
car: 0.4249
car: 0.4122
person: 0.3954
tie: 0.3411
person: 0.2653
더 이상 처리할 frame이 없습니다.
1
This post is licensed under CC BY 4.0 by the author.

Azure ML Classic

딥러닝 영상처리4