質問編集履歴
3
modified title
title
CHANGED
@@ -1,1 +1,1 @@
|
|
1
|
-
CentOSの仮想環境でmatplotlibが表示されないguest: host: windows10
|
1
|
+
CentOSの仮想環境でmatplotlibが表示されないguest: centos7 host: windows10
|
body
CHANGED
File without changes
|
2
見づらかったのでコメントを削除しました
title
CHANGED
File without changes
|
body
CHANGED
@@ -55,7 +55,7 @@
|
|
55
55
|
else:
|
56
56
|
e = TfPoseEstimator(get_graph_path(args.model), target_size=(w, h))
|
57
57
|
|
58
|
-
|
58
|
+
|
59
59
|
image = common.read_imgfile(args.image, None, None)
|
60
60
|
if image is None:
|
61
61
|
logger.error('Image can not be read, path=%s' % args.image)
|
@@ -81,7 +81,6 @@
|
|
81
81
|
bgimg = cv2.cvtColor(image.astype(np.uint8), cv2.COLOR_BGR2RGB)
|
82
82
|
bgimg = cv2.resize(bgimg, (e.heatMat.shape[1], e.heatMat.shape[0]), interpolation=cv2.INTER_AREA)
|
83
83
|
|
84
|
-
# show network output
|
85
84
|
a = fig.add_subplot(2, 2, 2)
|
86
85
|
plt.imshow(bgimg, alpha=0.5)
|
87
86
|
tmp = np.amax(e.heatMat[:, :, :-1], axis=2)
|
@@ -94,13 +93,13 @@
|
|
94
93
|
|
95
94
|
a = fig.add_subplot(2, 2, 3)
|
96
95
|
a.set_title('Vectormap-x')
|
97
|
-
|
96
|
+
|
98
97
|
plt.imshow(tmp2_odd, cmap=plt.cm.gray, alpha=0.5)
|
99
98
|
plt.colorbar()
|
100
99
|
|
101
100
|
a = fig.add_subplot(2, 2, 4)
|
102
101
|
a.set_title('Vectormap-y')
|
103
|
-
|
102
|
+
|
104
103
|
plt.imshow(tmp2_even, cmap=plt.cm.gray, alpha=0.5)
|
105
104
|
plt.colorbar()
|
106
105
|
plt.show()
|
1
run.py のコードを入れなおしました。宜しくお願いします。
title
CHANGED
File without changes
|
body
CHANGED
@@ -13,41 +13,100 @@
|
|
13
13
|
[vagrant@localhost tf-pose-estimation]$ python3 run.py
|
14
14
|
--model=mobilenet_thin --resize=432x368 --image=images/p2.jpg
|
15
15
|
|
16
|
-
/home/vagrant/.local/lib/python3.6/site-packages/tensorflow/python/framework/dtypes.py:516: FutureWarning: Passing (type, 1)
|
17
|
-
or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
|
18
|
-
_np_qint8 = np.dtype([("qint8", np.int8, 1)])
|
19
|
-
/home/vagrant/.local/lib/python3.6/site-packages/tensorflow/python/framework/dtypes.py:517: FutureWarning: Passing (type, 1)
|
20
|
-
or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
|
21
|
-
_np_quint8 = np.dtype([("quint8", np.uint8, 1)])
|
22
|
-
/home/vagrant/.local/lib/python3.6/site-packages/tensorflow/python/framework/dtypes.py:518: FutureWarning: Passing (type, 1)
|
23
|
-
・
|
24
|
-
・
|
25
|
-
・
|
26
|
-
・
|
27
|
-
・
|
28
|
-
TfPoseEstimator/Openpose/MConv_Stage6_L2_5_pointwise/BatchNorm/FusedBatchNorm
|
29
|
-
TfPoseEstimator/Openpose/concat_stage7/axis
|
30
|
-
|
16
|
+
----------------------------------
|
31
|
-
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.
|
32
17
|
|
33
|
-
|
18
|
+
import argparse
|
19
|
+
import logging
|
20
|
+
import sys
|
21
|
+
import time
|
34
22
|
|
23
|
+
from tf_pose import common
|
24
|
+
import cv2
|
25
|
+
import numpy as np
|
26
|
+
from tf_pose.estimator import TfPoseEstimator
|
35
|
-
|
27
|
+
from tf_pose.networks import get_graph_path, model_wh
|
36
28
|
|
29
|
+
logger = logging.getLogger('TfPoseEstimatorRun')
|
30
|
+
logger.handlers.clear()
|
31
|
+
logger.setLevel(logging.DEBUG)
|
32
|
+
ch = logging.StreamHandler()
|
33
|
+
ch.setLevel(logging.DEBUG)
|
37
|
-
|
34
|
+
formatter = logging.Formatter('[%(asctime)s] [%(name)s] [%(levelname)s] %(message)s')
|
35
|
+
ch.setFormatter(formatter)
|
36
|
+
logger.addHandler(ch)
|
38
37
|
|
39
|
-
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.
|
40
38
|
|
39
|
+
if __name__ == '__main__':
|
40
|
+
parser = argparse.ArgumentParser(description='tf-pose-estimation run')
|
41
|
+
parser.add_argument('--image', type=str, default='./images/p1.jpg')
|
42
|
+
parser.add_argument('--model', type=str, default='cmu',
|
41
|
-
|
43
|
+
help='cmu / mobilenet_thin / mobilenet_v2_large / mobilenet_v2_small')
|
44
|
+
parser.add_argument('--resize', type=str, default='0x0',
|
45
|
+
help='if provided, resize images before they are processed. '
|
46
|
+
'default=0x0, Recommends : 432x368 or 656x368 or 1312x736 ')
|
47
|
+
parser.add_argument('--resize-out-ratio', type=float, default=4.0,
|
48
|
+
help='if provided, resize heatmaps before they are post-processed. default=1.0')
|
42
49
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
50
|
+
args = parser.parse_args()
|
51
|
+
|
52
|
+
w, h = model_wh(args.resize)
|
53
|
+
if w == 0 or h == 0:
|
54
|
+
e = TfPoseEstimator(get_graph_path(args.model), target_size=(432, 368))
|
55
|
+
else:
|
56
|
+
e = TfPoseEstimator(get_graph_path(args.model), target_size=(w, h))
|
57
|
+
|
58
|
+
# estimate human poses from a single image !
|
59
|
+
image = common.read_imgfile(args.image, None, None)
|
60
|
+
if image is None:
|
61
|
+
logger.error('Image can not be read, path=%s' % args.image)
|
62
|
+
sys.exit(-1)
|
63
|
+
|
64
|
+
t = time.time()
|
65
|
+
humans = e.inference(image, resize_to_default=(w > 0 and h > 0), upsample_size=args.resize_out_ratio)
|
66
|
+
elapsed = time.time() - t
|
67
|
+
|
68
|
+
logger.info('inference image: %s in %.4f seconds.' % (args.image, elapsed))
|
69
|
+
|
70
|
+
image = TfPoseEstimator.draw_humans(image, humans, imgcopy=False)
|
71
|
+
|
72
|
+
try:
|
73
|
+
import matplotlib
|
74
|
+
import matplotlib.pyplot as plt
|
75
|
+
|
76
|
+
fig = plt.figure()
|
77
|
+
a = fig.add_subplot(2, 2, 1)
|
78
|
+
a.set_title('Result')
|
79
|
+
plt.imshow(cv2.cvtColor(image, cv2.COLOR_BGR2RGB))
|
80
|
+
|
81
|
+
bgimg = cv2.cvtColor(image.astype(np.uint8), cv2.COLOR_BGR2RGB)
|
82
|
+
bgimg = cv2.resize(bgimg, (e.heatMat.shape[1], e.heatMat.shape[0]), interpolation=cv2.INTER_AREA)
|
83
|
+
|
84
|
+
# show network output
|
85
|
+
a = fig.add_subplot(2, 2, 2)
|
86
|
+
plt.imshow(bgimg, alpha=0.5)
|
87
|
+
tmp = np.amax(e.heatMat[:, :, :-1], axis=2)
|
88
|
+
plt.imshow(tmp, cmap=plt.cm.gray, alpha=0.5)
|
89
|
+
plt.colorbar()
|
90
|
+
|
91
|
+
tmp2 = e.pafMat.transpose((2, 0, 1))
|
92
|
+
tmp2_odd = np.amax(np.absolute(tmp2[::2, :, :]), axis=0)
|
93
|
+
tmp2_even = np.amax(np.absolute(tmp2[1::2, :, :]), axis=0)
|
94
|
+
|
95
|
+
a = fig.add_subplot(2, 2, 3)
|
96
|
+
a.set_title('Vectormap-x')
|
97
|
+
# plt.imshow(CocoPose.get_bgimg(inp, target_size=(vectmap.shape[1], vectmap.shape[0])), alpha=0.5)
|
98
|
+
plt.imshow(tmp2_odd, cmap=plt.cm.gray, alpha=0.5)
|
99
|
+
plt.colorbar()
|
100
|
+
|
101
|
+
a = fig.add_subplot(2, 2, 4)
|
102
|
+
a.set_title('Vectormap-y')
|
103
|
+
# plt.imshow(CocoPose.get_bgimg(inp, target_size=(vectmap.shape[1], vectmap.shape[0])), alpha=0.5)
|
104
|
+
plt.imshow(tmp2_even, cmap=plt.cm.gray, alpha=0.5)
|
105
|
+
plt.colorbar()
|
106
|
+
plt.show()
|
107
|
+
except Exception as e:
|
108
|
+
logger.warning('matplotlib error, %s' % e)
|
109
|
+
cv2.imshow('result', image)
|
110
|
+
cv2.waitKey()
|
111
|
+
|
112
|
+
-----------------------------------------------
|