PaddleHub人体骨骼关键点检测
human_pose_estimation_resnet50_mpii
人体骨骼关键点检测(Pose Estimation) 是计算机视觉的基础性算法之一,在诸多计算机视觉任务起到了基础性的作用,如行为识别、人物跟踪、步态识别等相关领域。具体应用主要集中在智能视频监控,病人监护系统,人机交互,虚拟现实,人体动画,智能家居,智能安防,运动员辅助训练等等。 该模型的论文《Simple Baselines for Human Pose Estimation and Tracking》由 MSRA 发表于 ECCV18,使用 MPII 数据集训练完成。
NOTE: 如果您在本地运行该项目示例,需要首先安装PaddleHub。如果您在线运行,需要首先fork该项目示例。之后按照该示例操作即可。
human_pose_estimation_resnet50_mpii模型链接:https://www.paddlepaddle.org.cn/hubdetail?name=human_pose_estimation_resnet50_mpii&en_category=KeyPointDetection
环境:PaddlePaddle2.0.0rc PaddleHub2.0.0b1 human_pose_estimation_resnet50_mpii 1.1.1(最新版)
一、安装新版Hub
!pip install paddlehub==2.0.0b1 -i https://pypi.tuna.tsinghua.edu.cn/simple
二、定义待预测照片
以本示例中文件夹下girl.jpg为待预测图片
![](https://i-blog.csdnimg.cn/blog_migrate/d676125090b650a17f6e151fef10189b.jpeg)
image = "girl.jpg"
三、API预测
def keypoint_detection(self,
images=None,
paths=None,
batch_size=1,
use_gpu=False,
output_dir='output_pose',
visualization=False)
预测API,识别出人体骨骼关键点。
参数
- images (list[numpy.ndarray]): 图片数据,ndarray.shape 为 [H, W, C];
- paths (list[str]): 图片的路径;
- batch_size (int): batch 的大小;
- use_gpu (bool): 是否使用 GPU;
- visualization (bool): 是否将识别结果保存为图片文件;
- output_dir (str): 图片的保存路径,默认设为 output_pose。
返回
- res (listdict): 识别元素的列表,列表元素为 dict,关键字为 ‘path’, ‘data’,相应的取值为:
- path (str): 原图的路径;
- data (OrderedDict): 人体骨骼关键点的坐标。
import cv2
import paddlehub as hub
pose_estimation = hub.Module(name="human_pose_estimation_resnet50_mpii")
result = pose_estimation.keypoint_detection(images=[cv2.imread(image)],visualization=True)
print(result)
# or
# result = pose_estimation.keypoint_detection(paths=['/PATH/TO/IMAGE'])
四、命令行预测
!hub run human_pose_estimation_resnet50_mpii --input_path "girl.jpg"
五、实现效果
![](https://i-blog.csdnimg.cn/blog_migrate/d676125090b650a17f6e151fef10189b.jpeg)
![](https://i-blog.csdnimg.cn/blog_migrate/731b069775b58a7bd035f0a7464a6ffd.jpeg)