Diff of /main.py [000000] .. [968c76]

Switch to unified view

a b/main.py
1
import numpy as np
2
import matplotlib as mpl
3
import matplotlib.pyplot as plt
4
from scipy.misc import imresize, imread
5
6
from human_pose_nn import HumanPoseIRNetwork
7
mpl.use('Agg')
8
9
net_pose = HumanPoseIRNetwork()
10
net_pose.restore('../Thesis_solution/models/MPII+LSP.ckpt')
11
12
img = imread('images/dummy.jpg')
13
img = imresize(img, [299, 299])
14
img_batch = np.expand_dims(img, 0)
15
16
y, x, a = net_pose.estimate_joints(img_batch)
17
y, x, a = np.squeeze(y), np.squeeze(x), np.squeeze(a)
18
19
joint_names = [
20
    'right ankle ',
21
    'right knee ',
22
    'right hip',
23
    'left hip',
24
    'left knee',
25
    'left ankle',
26
    'pelvis',
27
    'thorax',
28
    'upper neck',
29
    'head top',
30
    'right wrist',
31
    'right elbow',
32
    'right shoulder',
33
    'left shoulder',
34
    'left elbow',
35
    'left wrist'
36
]
37
38
# Print probabilities of each estimation
39
for i in range(16):
40
    print('%s: %.02f%%' % (joint_names[i], a[i] * 100))
41
42
colors = ['r', 'r', 'b', 'm', 'm', 'y', 'g', 'g', 'b', 'c', 'r', 'r', 'b', 'm', 'm', 'c']
43
for i in range(16):
44
    if i < 15 and i not in {5, 9}:
45
        plt.plot([x[i], x[i + 1]], [y[i], y[i + 1]], color = colors[i], linewidth = 5)
46
47
plt.imshow(img)
48
plt.savefig('images/dummy_pose.jpg')