質問編集履歴
2
実行結果を載せていなかったので掲載いたしました。
title
CHANGED
File without changes
|
body
CHANGED
@@ -50,6 +50,40 @@
|
|
50
50
|
|
51
51
|
localize_objects("./resources/bicycle_original.jpeg")
|
52
52
|
```
|
53
|
+
実行結果
|
54
|
+
```
|
55
|
+
Number of objects found: 4
|
56
|
+
|
57
|
+
Bicycle wheel (confidence: 0.9344853758811951)
|
58
|
+
Normalized bounding polygon vertices:
|
59
|
+
- (0.31457117199897766, 0.7848830223083496)
|
60
|
+
- (0.44048216938972473, 0.7848830223083496)
|
61
|
+
- (0.44048216938972473, 0.9704981446266174)
|
62
|
+
- (0.31457117199897766, 0.9704981446266174)
|
63
|
+
|
64
|
+
Bicycle wheel (confidence: 0.9330147504806519)
|
65
|
+
Normalized bounding polygon vertices:
|
66
|
+
- (0.5049288272857666, 0.7552310824394226)
|
67
|
+
- (0.627302348613739, 0.7552310824394226)
|
68
|
+
- (0.627302348613739, 0.944308340549469)
|
69
|
+
- (0.5049288272857666, 0.944308340549469)
|
70
|
+
|
71
|
+
Bicycle (confidence: 0.9041756391525269)
|
72
|
+
Normalized bounding polygon vertices:
|
73
|
+
- (0.31727585196495056, 0.6597068905830383)
|
74
|
+
- (0.6291733980178833, 0.6597068905830383)
|
75
|
+
- (0.6291733980178833, 0.9677099585533142)
|
76
|
+
- (0.31727585196495056, 0.9677099585533142)
|
77
|
+
|
78
|
+
Picture frame (confidence: 0.6569825410842896)
|
79
|
+
Normalized bounding polygon vertices:
|
80
|
+
- (0.786456823348999, 0.16705626249313354)
|
81
|
+
- (0.9639955163002014, 0.16705626249313354)
|
82
|
+
- (0.9639955163002014, 0.3188837766647339)
|
83
|
+
- (0.786456823348999, 0.3188837766647339)
|
84
|
+
総実行時間:25.37931489944458
|
85
|
+
annotationsにかかる時間:25.37454390525818
|
86
|
+
```
|
53
87
|
見ていただいてわかる通り、下記の記述部分でかなり時間がかかっているようです。
|
54
88
|
|
55
89
|
```
|
1
サンプルと同じ画像を使用し、時間測定のためのコードを追加しました。
title
CHANGED
File without changes
|
body
CHANGED
@@ -11,9 +11,14 @@
|
|
11
11
|
https://cloud.google.com/vision/docs/object-localizer
|
12
12
|
|
13
13
|
### 該当のソースコード
|
14
|
+
サンプルコードと同じ画像を使用しています。
|
15
|
+
時間測定のためのコードを追加していますが、それ以外は変えていません。
|
14
16
|
|
15
17
|
```main.py
|
18
|
+
import time
|
19
|
+
|
16
20
|
def localize_objects(path):
|
21
|
+
start = time.time() #時間計測
|
17
22
|
"""Localize objects in the local image.
|
18
23
|
|
19
24
|
Args:
|
@@ -24,10 +29,13 @@
|
|
24
29
|
|
25
30
|
with open(path, 'rb') as image_file:
|
26
31
|
content = image_file.read()
|
32
|
+
|
27
33
|
image = vision.Image(content=content)
|
34
|
+
|
28
|
-
|
35
|
+
start2 = time.time() #時間計測
|
29
36
|
objects = client.object_localization(
|
30
37
|
image=image).localized_object_annotations
|
38
|
+
end2 = time.time() #時間計測
|
31
39
|
|
32
40
|
print('Number of objects found: {}'.format(len(objects)))
|
33
41
|
for object_ in objects:
|
@@ -35,5 +43,16 @@
|
|
35
43
|
print('Normalized bounding polygon vertices: ')
|
36
44
|
for vertex in object_.bounding_poly.normalized_vertices:
|
37
45
|
print(' - ({}, {})'.format(vertex.x, vertex.y))
|
46
|
+
|
47
|
+
end = time.time() #時間計測
|
48
|
+
print("総実行時間:{}".format(end - start))
|
49
|
+
print("annotationsにかかる時間:{}".format(end2 - start2))
|
50
|
+
|
51
|
+
localize_objects("./resources/bicycle_original.jpeg")
|
38
52
|
```
|
53
|
+
見ていただいてわかる通り、下記の記述部分でかなり時間がかかっているようです。
|
39
54
|
|
55
|
+
```
|
56
|
+
objects = client.object_localization(
|
57
|
+
image=image).localized_object_annotations
|
58
|
+
```
|