织梦CMS - 轻松建站从此开始!

罗索

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

jackyhwei 发布于 2020-09-11 16:26 点击:次 
基于tensorflow深度学习框架实现的人体姿态识别,有兴趣地朋友可以去找一下。这个项目的原始项目是用caffe框架,c++编写的人体姿态识别(检测人体身体部分、手、脸、脚等部位)。
TAG: 人体姿态识别  姿态识别  tensorflow  

这个项目在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.如何像博主一样在图像上显示坐标:(贡献出我的代码)

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

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

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

(suswulongyuan)
本站文章除注明转载外,均为本站原创或编译欢迎任何形式的转载,但请务必注明出处,尊重他人劳动,同学习共成长。转载请注明:文章转载自:罗索实验室 [http://www.rosoo.net/a/202009/17742.html]
本文出处:CSDN博客 作者:suswulongyuan 原文
顶一下
(0)
0%
踩一下
(0)
0%
------分隔线----------------------------
发表评论
请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
评价:
表情:
用户名: 验证码:点击我更换图片
栏目列表
将本文分享到微信
织梦二维码生成器
推荐内容