百度AI攻略:Paddlehub實現關鍵點檢測

PaddleHub能夠便捷地獲取PaddlePaddle生態下的預訓練模型,完成模型的管理和一鍵預測。配合使用Fine-tune API,能夠基於大規模預訓練模型快速完成遷移學習,讓預訓練模型能更好地服務於用戶特定場景的應用。算法

模型概述學習

人體骨骼關鍵點檢測(Pose Estimation) 是計算機視覺的基礎性算法之一,在諸多計算機視覺任務起到了基礎性的做用,如行爲識別、人物跟蹤、步態識別等相關領域。具體應用主要集中在智能視頻監控,病人監護系統,人機交互,虛擬現實,人體動畫,智能家居,智能安防,運動員輔助訓練等等。 該模型的論文《Simple Baselines for Human Pose Estimation and Tracking》由 MSRA 發表於 ECCV18,使用 MPII 數據集訓練完成。動畫

代碼及效果示例:3d

import paddlehub as hub視頻

import matplotlib.pyplot as pltblog

import matplotlib.image as mpimgip

#pose_resnet50_mpiiinput

module = hub.Module(name="pose_resnet50_mpii")io

test_img_path = "./body2.jpg"test

# 預測結果展現

img = mpimg.imread(test_img_path)

plt.imshow(img)

plt.axis('off')

plt.show()

# set input dict

input_dict = {"image": [test_img_path]}

# execute predict and print the result

results = module.keypoint_detection(data=input_dict)

for result in results:

    print(result)

test_img_path = "./output_pose/rendered_body2.jpg"

img = mpimg.imread(test_img_path)

plt.imshow(img)

plt.axis('off')

plt.show()

[2020-01-05 12:20:51,492] [    INFO] - Installing pose_resnet50_mpii module

2020-01-05 12:20:51,492-INFO: Installing pose_resnet50_mpii module

[2020-01-05 12:20:51,508] [    INFO] - Module pose_resnet50_mpii already installed in /home/aistudio/.paddlehub/modules/pose_resnet50_mpii

2020-01-05 12:20:51,508-INFO: Module pose_resnet50_mpii already installed in /home/aistudio/.paddlehub/modules/pose_resnet50_mpii

[2020-01-05 12:20:51,958] [    INFO] - 282 pretrained paramaters loaded by PaddleHub

2020-01-05 12:20:51,958-INFO: 282 pretrained paramaters loaded by PaddleHub

{'path': 'output_pose/rendered_body2.jpg', 'data': {'left_ankle': [178, 250], 'left_knee': [220, 224], 'left_hip': [201, 215], 'right_hip': [243, 215], 'right_knee': [243, 224], 'right_ankle': [234, 247], 'pelvis': [225, 215], 'thorax': [220, 123], 'upper neck': [220, 98], 'head top': [220, 57], 'right_wrist': [112, 212], 'right_elbow': [168, 180], 'right_shoulder': [182, 126], 'left_shoulder': [257, 120], 'left_elbow': [276, 180], 'left_wrist': [309, 218]}}

module = hub.Module(name="pose_resnet50_mpii")

test_img_path = "./body10.jpg"

# 預測結果展現

img = mpimg.imread(test_img_path)

plt.imshow(img)

plt.axis('off')

plt.show()

# set input dict

input_dict = {"image": [test_img_path]}

# execute predict and print the result

results = module.keypoint_detection(data=input_dict)

for result in results:

    print(result)

test_img_path = "./output_pose/rendered_body10.jpg"

img = mpimg.imread(test_img_path)

plt.imshow(img)

plt.axis('off')

plt.show()

[2020-01-05 12:22:10,407] [    INFO] - Installing pose_resnet50_mpii module

2020-01-05 12:22:10,407-INFO: Installing pose_resnet50_mpii module

[2020-01-05 12:22:10,422] [    INFO] - Module pose_resnet50_mpii already installed in /home/aistudio/.paddlehub/modules/pose_resnet50_mpii

2020-01-05 12:22:10,422-INFO: Module pose_resnet50_mpii already installed in /home/aistudio/.paddlehub/modules/pose_resnet50_mpii

[2020-01-05 12:22:10,919] [    INFO] - 282 pretrained paramaters loaded by PaddleHub

2020-01-05 12:22:10,919-INFO: 282 pretrained paramaters loaded by PaddleHub

{'path': 'output_pose/rendered_body10.jpg', 'data': {'left_ankle': [335, 870], 'left_knee': [306, 642], 'left_hip': [313, 555], 'right_hip': [335, 533], 'right_knee': [298, 653], 'right_ankle': [408, 761], 'pelvis': [328, 533], 'thorax': [298, 435], 'upper neck': [306, 413], 'head top': [364, 337], 'right_wrist': [320, 348], 'right_elbow': [298, 391], 'right_shoulder': [291, 424], 'left_shoulder': [313, 457], 'left_elbow': [408, 500], 'left_wrist': [495, 533]}}

相關文章
相關標籤/搜索