質問編集履歴
3
modified title
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
CentOSの仮想環境でmatplotlibが表示されないguest: host: windows10
|
1
|
+
CentOSの仮想環境でmatplotlibが表示されないguest: centos7 host: windows10
|
test
CHANGED
File without changes
|
2
見づらかったのでコメントを削除しました
test
CHANGED
File without changes
|
test
CHANGED
@@ -112,7 +112,7 @@
|
|
112
112
|
|
113
113
|
|
114
114
|
|
115
|
-
|
115
|
+
|
116
116
|
|
117
117
|
image = common.read_imgfile(args.image, None, None)
|
118
118
|
|
@@ -164,8 +164,6 @@
|
|
164
164
|
|
165
165
|
|
166
166
|
|
167
|
-
# show network output
|
168
|
-
|
169
167
|
a = fig.add_subplot(2, 2, 2)
|
170
168
|
|
171
169
|
plt.imshow(bgimg, alpha=0.5)
|
@@ -190,7 +188,7 @@
|
|
190
188
|
|
191
189
|
a.set_title('Vectormap-x')
|
192
190
|
|
193
|
-
|
191
|
+
|
194
192
|
|
195
193
|
plt.imshow(tmp2_odd, cmap=plt.cm.gray, alpha=0.5)
|
196
194
|
|
@@ -202,7 +200,7 @@
|
|
202
200
|
|
203
201
|
a.set_title('Vectormap-y')
|
204
202
|
|
205
|
-
|
203
|
+
|
206
204
|
|
207
205
|
plt.imshow(tmp2_even, cmap=plt.cm.gray, alpha=0.5)
|
208
206
|
|
1
run.py のコードを入れなおしました。宜しくお願いします。
test
CHANGED
File without changes
|
test
CHANGED
@@ -28,78 +28,196 @@
|
|
28
28
|
|
29
29
|
|
30
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
|
-
TfPoseEstimator
|
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
|
-
|
31
|
+
----------------------------------
|
32
|
+
|
33
|
+
|
34
|
+
|
35
|
+
import argparse
|
36
|
+
|
37
|
+
import logging
|
38
|
+
|
39
|
+
import sys
|
40
|
+
|
41
|
+
import time
|
42
|
+
|
43
|
+
|
44
|
+
|
45
|
+
from tf_pose import common
|
46
|
+
|
47
|
+
import cv2
|
48
|
+
|
49
|
+
import numpy as np
|
50
|
+
|
51
|
+
from tf_pose.estimator import TfPoseEstimator
|
52
|
+
|
53
|
+
from tf_pose.networks import get_graph_path, model_wh
|
54
|
+
|
55
|
+
|
56
|
+
|
57
|
+
logger = logging.getLogger('TfPoseEstimatorRun')
|
58
|
+
|
59
|
+
logger.handlers.clear()
|
60
|
+
|
61
|
+
logger.setLevel(logging.DEBUG)
|
62
|
+
|
63
|
+
ch = logging.StreamHandler()
|
64
|
+
|
65
|
+
ch.setLevel(logging.DEBUG)
|
66
|
+
|
67
|
+
formatter = logging.Formatter('[%(asctime)s] [%(name)s] [%(levelname)s] %(message)s')
|
68
|
+
|
69
|
+
ch.setFormatter(formatter)
|
70
|
+
|
71
|
+
logger.addHandler(ch)
|
72
|
+
|
73
|
+
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
if __name__ == '__main__':
|
78
|
+
|
79
|
+
parser = argparse.ArgumentParser(description='tf-pose-estimation run')
|
80
|
+
|
81
|
+
parser.add_argument('--image', type=str, default='./images/p1.jpg')
|
82
|
+
|
83
|
+
parser.add_argument('--model', type=str, default='cmu',
|
84
|
+
|
85
|
+
help='cmu / mobilenet_thin / mobilenet_v2_large / mobilenet_v2_small')
|
86
|
+
|
87
|
+
parser.add_argument('--resize', type=str, default='0x0',
|
88
|
+
|
89
|
+
help='if provided, resize images before they are processed. '
|
90
|
+
|
91
|
+
'default=0x0, Recommends : 432x368 or 656x368 or 1312x736 ')
|
92
|
+
|
93
|
+
parser.add_argument('--resize-out-ratio', type=float, default=4.0,
|
94
|
+
|
95
|
+
help='if provided, resize heatmaps before they are post-processed. default=1.0')
|
96
|
+
|
97
|
+
|
98
|
+
|
99
|
+
args = parser.parse_args()
|
100
|
+
|
101
|
+
|
102
|
+
|
103
|
+
w, h = model_wh(args.resize)
|
104
|
+
|
105
|
+
if w == 0 or h == 0:
|
106
|
+
|
107
|
+
e = TfPoseEstimator(get_graph_path(args.model), target_size=(432, 368))
|
108
|
+
|
109
|
+
else:
|
110
|
+
|
111
|
+
e = TfPoseEstimator(get_graph_path(args.model), target_size=(w, h))
|
112
|
+
|
113
|
+
|
114
|
+
|
115
|
+
# estimate human poses from a single image !
|
116
|
+
|
117
|
+
image = common.read_imgfile(args.image, None, None)
|
118
|
+
|
119
|
+
if image is None:
|
120
|
+
|
121
|
+
logger.error('Image can not be read, path=%s' % args.image)
|
122
|
+
|
123
|
+
sys.exit(-1)
|
124
|
+
|
125
|
+
|
126
|
+
|
127
|
+
t = time.time()
|
128
|
+
|
129
|
+
humans = e.inference(image, resize_to_default=(w > 0 and h > 0), upsample_size=args.resize_out_ratio)
|
130
|
+
|
131
|
+
elapsed = time.time() - t
|
132
|
+
|
133
|
+
|
134
|
+
|
135
|
+
logger.info('inference image: %s in %.4f seconds.' % (args.image, elapsed))
|
136
|
+
|
137
|
+
|
138
|
+
|
139
|
+
image = TfPoseEstimator.draw_humans(image, humans, imgcopy=False)
|
140
|
+
|
141
|
+
|
142
|
+
|
143
|
+
try:
|
144
|
+
|
145
|
+
import matplotlib
|
146
|
+
|
147
|
+
import matplotlib.pyplot as plt
|
148
|
+
|
149
|
+
|
150
|
+
|
151
|
+
fig = plt.figure()
|
152
|
+
|
153
|
+
a = fig.add_subplot(2, 2, 1)
|
154
|
+
|
155
|
+
a.set_title('Result')
|
156
|
+
|
157
|
+
plt.imshow(cv2.cvtColor(image, cv2.COLOR_BGR2RGB))
|
158
|
+
|
159
|
+
|
160
|
+
|
161
|
+
bgimg = cv2.cvtColor(image.astype(np.uint8), cv2.COLOR_BGR2RGB)
|
162
|
+
|
163
|
+
bgimg = cv2.resize(bgimg, (e.heatMat.shape[1], e.heatMat.shape[0]), interpolation=cv2.INTER_AREA)
|
164
|
+
|
165
|
+
|
166
|
+
|
167
|
+
# show network output
|
168
|
+
|
169
|
+
a = fig.add_subplot(2, 2, 2)
|
170
|
+
|
171
|
+
plt.imshow(bgimg, alpha=0.5)
|
172
|
+
|
173
|
+
tmp = np.amax(e.heatMat[:, :, :-1], axis=2)
|
174
|
+
|
175
|
+
plt.imshow(tmp, cmap=plt.cm.gray, alpha=0.5)
|
176
|
+
|
177
|
+
plt.colorbar()
|
178
|
+
|
179
|
+
|
180
|
+
|
181
|
+
tmp2 = e.pafMat.transpose((2, 0, 1))
|
182
|
+
|
183
|
+
tmp2_odd = np.amax(np.absolute(tmp2[::2, :, :]), axis=0)
|
184
|
+
|
185
|
+
tmp2_even = np.amax(np.absolute(tmp2[1::2, :, :]), axis=0)
|
186
|
+
|
187
|
+
|
188
|
+
|
189
|
+
a = fig.add_subplot(2, 2, 3)
|
190
|
+
|
191
|
+
a.set_title('Vectormap-x')
|
192
|
+
|
193
|
+
# plt.imshow(CocoPose.get_bgimg(inp, target_size=(vectmap.shape[1], vectmap.shape[0])), alpha=0.5)
|
194
|
+
|
195
|
+
plt.imshow(tmp2_odd, cmap=plt.cm.gray, alpha=0.5)
|
196
|
+
|
197
|
+
plt.colorbar()
|
198
|
+
|
199
|
+
|
200
|
+
|
201
|
+
a = fig.add_subplot(2, 2, 4)
|
202
|
+
|
203
|
+
a.set_title('Vectormap-y')
|
204
|
+
|
205
|
+
# plt.imshow(CocoPose.get_bgimg(inp, target_size=(vectmap.shape[1], vectmap.shape[0])), alpha=0.5)
|
206
|
+
|
207
|
+
plt.imshow(tmp2_even, cmap=plt.cm.gray, alpha=0.5)
|
208
|
+
|
209
|
+
plt.colorbar()
|
210
|
+
|
211
|
+
plt.show()
|
212
|
+
|
213
|
+
except Exception as e:
|
214
|
+
|
215
|
+
logger.warning('matplotlib error, %s' % e)
|
216
|
+
|
217
|
+
cv2.imshow('result', image)
|
218
|
+
|
219
|
+
cv2.waitKey()
|
220
|
+
|
221
|
+
|
222
|
+
|
223
|
+
-----------------------------------------------
|