GluonCVの「Pose Estimation」はゴルフ上達に役立つか?

環境

Windows10 Pro 64bit (GPUなし)
Python 3.6.8

バージョン確認(pip freeze)

astroid==2.2.5
certifi==2019.3.9
chardet==3.0.4
colorama==0.4.1
cycler==0.10.0
gluoncv==0.4.0.post0
graphviz==0.8.4
idna==2.6
isort==4.3.20
kiwisolver==1.1.0
lazy-object-proxy==1.4.1
matplotlib==3.1.0
mccabe==0.6.1
mxnet==1.4.1
numpy==1.16.4
Pillow==6.0.0
pylint==2.3.1
pyparsing==2.4.0
python-dateutil==2.8.0
requests==2.18.4
scipy==1.3.0
six==1.12.0
tqdm==4.32.1
typed-ast==1.4.0
urllib3==1.22
wrapt==1.11.1

実行スクリプト

from matplotlib import pyplot as plt
from gluoncv import model_zoo, data, utils
from gluoncv.data.transforms.pose import detector_to_simple_pose, heatmap_to_coord

detector = model_zoo.get_model('yolo3_mobilenet1.0_coco', pretrained=True)
pose_net = model_zoo.get_model('simple_pose_resnet18_v1b', pretrained=True)

# Note that we can reset the classes of the detector to only include
# human, so that the NMS process is faster.

detector.reset_class(["person"], reuse_weights=['person'])

im_fname = 'golf2.jpg'
x, img = data.transforms.presets.ssd.load_test(im_fname, short=512)
print('Shape of pre-processed image:', x.shape)

class_IDs, scores, bounding_boxs = detector(x)

pose_input, upscale_bbox = detector_to_simple_pose(img, class_IDs, scores, bounding_boxs)

predicted_heatmap = pose_net(pose_input)
pred_coords, confidence = heatmap_to_coord(predicted_heatmap, upscale_bbox)

coords = pred_coords.asnumpy()
confidence = confidence.asnumpy()

import numpy as np
bg = np.zeros(img.shape)
ax = utils.viz.plot_image(bg)

joint_visible = confidence[:, :, 0] > 0.2
joint_pairs = [[0, 1], [1, 3], [0, 2], [2, 4],
               [5, 6], [5, 7], [7, 9], [6, 8], [8, 10],
               [5, 11], [6, 12], [11, 12],
               [11, 13], [12, 14], [13, 15], [14, 16]]

colormap_index = np.linspace(0, 1, len(joint_pairs))
for i in range(coords.shape[0]):
    pts = coords[i]
    for cm_ind, jp in zip(colormap_index, joint_pairs):
        if joint_visible[i, jp[0]] and joint_visible[i, jp[1]]:
            ax.plot(pts[jp, 0], pts[jp, 1],
                    linewidth=3.0, alpha=0.7, color=plt.cm.cool(cm_ind))
            ax.scatter(pts[jp, 0], pts[jp, 1], s=20)

plt.axis('off')
plt.show()

結果の表示

f:id:touch-sp:20190613083034p:plain

感想

自分のスイングチェックには役に立つ?