-
Notifications
You must be signed in to change notification settings - Fork 144
/
Copy pathmain.py
48 lines (40 loc) · 1.15 KB
/
main.py
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
import numpy as np
import matplotlib as mpl
import matplotlib.pyplot as plt
from scipy.misc import imresize, imread
from human_pose_nn import HumanPoseIRNetwork
mpl.use('Agg')
net_pose = HumanPoseIRNetwork()
net_pose.restore('../Thesis_solution/models/MPII+LSP.ckpt')
img = imread('images/dummy.jpg')
img = imresize(img, [299, 299])
img_batch = np.expand_dims(img, 0)
y, x, a = net_pose.estimate_joints(img_batch)
y, x, a = np.squeeze(y), np.squeeze(x), np.squeeze(a)
joint_names = [
'right ankle ',
'right knee ',
'right hip',
'left hip',
'left knee',
'left ankle',
'pelvis',
'thorax',
'upper neck',
'head top',
'right wrist',
'right elbow',
'right shoulder',
'left shoulder',
'left elbow',
'left wrist'
]
# Print probabilities of each estimation
for i in range(16):
print('%s: %.02f%%' % (joint_names[i], a[i] * 100))
colors = ['r', 'r', 'b', 'm', 'm', 'y', 'g', 'g', 'b', 'c', 'r', 'r', 'b', 'm', 'm', 'c']
for i in range(16):
if i < 15 and i not in {5, 9}:
plt.plot([x[i], x[i + 1]], [y[i], y[i + 1]], color = colors[i], linewidth = 5)
plt.imshow(img)
plt.savefig('images/dummy_pose.jpg')