質問編集履歴

3

modified title

2019/09/12 01:40

投稿

ShumpeiSori
ShumpeiSori

スコア5

test CHANGED
@@ -1 +1 @@
1
- CentOSの仮想環境でmatplotlibが表示されないguest: host: windows10
1
+ CentOSの仮想環境でmatplotlibが表示されないguest: centos7 host: windows10
test CHANGED
File without changes

2

見づらかったのでコメントを削除しました

2019/09/12 01:40

投稿

ShumpeiSori
ShumpeiSori

スコア5

test CHANGED
File without changes
test CHANGED
@@ -112,7 +112,7 @@
112
112
 
113
113
 
114
114
 
115
- # estimate human poses from a single image !
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
- # plt.imshow(CocoPose.get_bgimg(inp, target_size=(vectmap.shape[1], vectmap.shape[0])), alpha=0.5)
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
- # plt.imshow(CocoPose.get_bgimg(inp, target_size=(vectmap.shape[1], vectmap.shape[0])), alpha=0.5)
203
+
206
204
 
207
205
  plt.imshow(tmp2_even, cmap=plt.cm.gray, alpha=0.5)
208
206
 

1

run.py のコードを入れなおしました。宜しくお願いします。

2019/09/10 14:41

投稿

ShumpeiSori
ShumpeiSori

スコア5

test CHANGED
File without changes
test CHANGED
@@ -28,78 +28,196 @@
28
28
 
29
29
 
30
30
 
31
- /home/vagrant/.local/lib/python3.6/site-packages/tensorflow/python/framework/dtypes.py:516: FutureWarning: Passing (type, 1)
32
-
33
- or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
34
-
35
- _np_qint8 = np.dtype([("qint8", np.int8, 1)])
36
-
37
- /home/vagrant/.local/lib/python3.6/site-packages/tensorflow/python/framework/dtypes.py:517: FutureWarning: Passing (type, 1)
38
-
39
- or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
40
-
41
- _np_quint8 = np.dtype([("quint8", np.uint8, 1)])
42
-
43
- /home/vagrant/.local/lib/python3.6/site-packages/tensorflow/python/framework/dtypes.py:518: FutureWarning: Passing (type, 1)
44
-
45
-     ・
46
-
47
-     ・
48
-
49
-     ・
50
-
51
-     ・
52
-
53
-     ・
54
-
55
- TfPoseEstimator/Openpose/MConv_Stage6_L2_5_pointwise/BatchNorm/FusedBatchNorm
56
-
57
- TfPoseEstimator/Openpose/concat_stage7/axis
58
-
59
- TfPoseEstimator/Openpose/concat_stage7
60
-
61
- WARNING:tensorflow:From /home/vagrant/tf-pose-estimation/tf_pose/estimator.py:341: The name tf.placeholder is deprecated. Please use tf.compat.v1.placeholder instead.
62
-
63
-
64
-
65
- 2019-09-10 12:57:56,417 WARNING From /home/vagrant/tf-pose-estimation/tf_pose/estimator.py:341: The name tf.placeholder is deprecated. Please use tf.compat.v1.placeholder instead.
66
-
67
-
68
-
69
- WARNING:tensorflow:From /home/vagrant/tf-pose-estimation/tf_pose/estimator.py:342: The name tf.image.resize_area is deprecated. Please use tf.compat.v1.image.resize_area instead.
70
-
71
-
72
-
73
- 2019-09-10 12:57:56,420 WARNING From /home/vagrant/tf-pose-estimation/tf_pose/estimator.py:342: The name tf.image.resize_area is deprecated. Please use tf.compat.v1.image.resize_area instead.
74
-
75
-
76
-
77
- WARNING:tensorflow:From /home/vagrant/tf-pose-estimation/tf_pose/tensblur/smoother.py:96: The name tf.variable_scope is deprecated. Please use tf.compat.v1.variable_scope instead.
78
-
79
-
80
-
81
- 2019-09-10 12:57:56,442 WARNING From /home/vagrant/tf-pose-estimation/tf_pose/tensblur/smoother.py:96: The name tf.variable_scope is deprecated. Please use tf.compat.v1.variable_scope instead.
82
-
83
-
84
-
85
- WARNING:tensorflow:From /home/vagrant/tf-pose-estimation/tf_pose/estimator.py:354: add_dispatch_support..wrapper (from tensorflow.python.ops.array_ops) is deprecated and will be removed in a future version.
86
-
87
- Instructions for updating:
88
-
89
- Use tf.where in 2.0, which has the same broadcast rule as np.where
90
-
91
- 2019-09-10 12:57:56,463 WARNING From /home/vagrant/tf-pose-estimation/tf_pose/estimator.py:354: add_dispatch_support..wrapper (from tensorflow.python.ops.array_ops) is deprecated and will be removed in a future version.
92
-
93
- Instructions for updating:
94
-
95
- Use tf.where in 2.0, which has the same broadcast rule as np.where
96
-
97
- 2019-09-10 12:57:56.563567: W tensorflow/compiler/jit/mark_for_compilation_pass.cc:1412] (One-time warning): Not using XLA:CPU for cluster because envvar TF_XLA_FLAGS=--tf_xla_cpu_global_jit was not set. If you want XLA:CPU, either set that envvar,
98
-
99
- or use experimental_jit_scope to enable XLA:CPU. To confirm that XLA is active, pass --vmodule=xla_compilation_cache=1 (as a proper command-line flag, not via TF_XLA_FLAGS) or set the envvar XLA_FLAGS=--xla_hlo_profile.
100
-
101
- 2019-09-10 12:57:57.584627: W tensorflow/core/framework/allocator.cc:107] Allocation of 24164352 exceeds 10% of system memory.
102
-
103
- [2019-09-10 12:58:04,331] [TfPoseEstimatorRun] [INFO] inference image: images/p2.jpg in 1.3923 seconds.
104
-
105
- 2019-09-10 12:58:04,331 INFO inference image: images/p2.jpg in 1.3923 seconds.
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
+ -----------------------------------------------