深度学习tf-pose-estimation人体姿态识别实现教程

在这里插入图片描述这个项目在github上非常火,项目地址是:https://github.com/ildoonet/tf-pose-estimation,是基于tensorflow深度学习框架实现的人体姿态识别,有兴趣地朋友可以去找一下。这个项目的原始项目是用caffe框架,c++编写的人体姿态识别(检测人体身体部分、手、脸、脚等部位)。
参考的文献如下,有兴趣的同学可以读一下:
(1)OpenPose: Realtime Multi-Person 2D Pose Estimation using Part Affinity Fields
(2)Realtime Multi-Person 2D Pose Estimation using Part Affinity Fields
(3)Hand Keypoint Detection in Single Images using Multiview Bootstrapping
(4)Convolutional Pose Machines

下面我主要介绍一下tf-pose-estimation环境配置步骤,对这个项目感兴趣的同学,可以根据我的步骤完成实验:
**1.首先在github上下载tf-pose-estimation (点击clone and download)**http://www.github.com/ildoonet/tf-openpose

2.创建一个虚拟环境(我这里用的是conda虚拟环境,也可以用venv)。
conda create -n tf-pose python=3.7
#tf-pose是你创建的环境名称
activate tf-pose
#激活你创建的环境

3.安装相应的依赖项
pip install -r requirements.txt
pip install opencv
pip install tensorflow-gpu
更新:pip install --ignore-installed --upgrade tensorflow-gpu

4.build c++ library
(1)先下载swig,然后用swig命令去编译
下载地址:http://prdownloads.sourceforge.net/swig/swigwin-3.0.12.zip
解压到任意目录,我这里放在C:\swigwin-3.0.12,把该目录加入环境变 量path。
(2)cd tf-pose-estimation/tf_pose/pafprocess/
运行:swig -python -c++ pafprocess.i && python3 setup.py build_ext --inplace

5.下载tensorflow 训练好的graph文件(pb file)
该项目提供的文件有四个:
cmu (trained in 656x368)
mobilenet_thin (trained in 432x368)
mobilenet_v2_large (trained in 432x368)
mobilenet_v2_small (trained in 432x368)
因为graph太大了,所以项目作者把它放到了云上,如果您想使用cmu的原始模型,应该下载它们。model文件夹中提供了下载脚本。
$ cd models/graph/cmu
$ bash download.sh
其他的不需要安装。

6.开始运行:
(1)使用一个图片运行:
python run.py --model=mobilenet_thin --resize=432x368 --image=./images/p1.jpg

(2)实时的webcam
python run_webcam.py --model=mobilenet_thin --resize=432x368 --camera=0
下图是效果图:(连衣服上的人都检测出来了,哈哈哈)
有兴趣的同学可以私聊我。
在这里插入图片描述可以参考:https://www.jianshu.com/p/402201fc6f04

提问

1.如何像博主一样在图像上显示坐标:(贡献出我的代码)

centers = {}
        flat = [0.0 for i in range(36)]
        for human in humans:
            # draw point
            for i in range(common.CocoPart.Background.value):
                if i not in human.body_parts.keys():
                    continue
 
                body_part = human.body_parts[i]
                center = (int(body_part.x * image_w + 0.5), int(body_part.y * image_h + 0.5))
                centers[i] = center
                flat[i * 2] = center[0]
                flat[i * 2 + 1] = center[1]
                cv2.circle(npimg, center, 3, common.CocoColors[i], thickness=3, lineType=8, shift=0)
            # draw x,y
                text = "X:" + str(center[0]) + "Y:" + str(center[1])
                cv2.putText(npimg, text, (center[0], center[1]), cv2.FONT_HERSHEY_PLAIN, 1, (255, 255, 255), thickness=1)

2.训练好的graph文件下载很慢
那是因为,是国外的项目,放在了国外服务器上。我的方法就是直接把bash里面出现的网址,复制在浏览器上下载。

3.gpu配置问题和环境部署问题
这个坑留到以后填上,以后会介绍高大上的工具,docker

  • 14
    点赞
  • 97
    收藏
    觉得还不错? 一键收藏
  • 74
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 74
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值