项目地址:https://github.com/michalfaber/keras_Realtime_Multi-Person_Pose_Estimation
论文地址:https://arxiv.org/abs/1611.08050
COCO数据集下载地址:
train2017 http://images.cocodataset.org/zips/train2017.zip (18G)
val2017 http://images.cocodataset.org/zips/val2017.zip (1G)
train2017/val2017 annotation http://images.cocodataset.org/annotations/annotations_trainval2017.zip(241M)
test2017 http://images.cocodataset.org/zips/test2017.zip (6G)
对于使用COCO数据集的这些项目,复现的一个关键点就是pycocotools的安装,在windows和ubuntu下安装方式有区别,具体可以参考“Ubuntu、win10安装pycocotools”,如果只是加载
Step1:环境配置
用Anaconda创建一个python3.6虚拟环境,然后依次安装所需的包
# 创建虚拟环境并激活
conda create -n pose python=3.6
conda activate pose
# 安装包,以下都需要,多次尝试得出的结论
# tensorflow、keras是否安装gpu版根据自身情况来定
conda install tensorflow==1.13.1
conda install keras==2.2.4
conda install cython # 这是pycocotools的关键依赖包
conda install pycocotools
pip install opencv-python
conda install pillow
conda install ipython
conda install configobj
conda install matplotlib
conda install pandas
conda install tensorpack==0.9 # 这个必须版本固定0.9,往上往下的版本都会报错
Step2:测试一张图片
先下载预训练的keras模型https://www.dropbox.com/s/llpxd14is7gyj0z/model.h5
下好之后在项目文件夹的model中新建一个文件夹keras,然后将h5文件放进去
最后运行官方测试用例
python demo_image.py --image sample_images/ski.jpg
运行之后会在文件夹中保存一个result.jpg文件
Step3:训练
如果按照上面的方法把所有的包都装好了,直接运行训练文件应该是不会报错,但是我也在其他一下奇怪的地方复现过,比如阿里云服务器之类的,有可能会出现下面的问题:
ImportError:libSM.so.6:cannot open shared object file:No such file or directory
ImportError:libXrender.so.1:cannot open shared object file:No such file or directory
这个问题有一个比较好的解决办法,可以参考这个https://blog.csdn.net/hesongzefairy/article/details/106217692
还有最后一个问题,当train文件运行起来之后,会下载vgg19的模型,这个可能是我网不好,总是下不下来,这里给同样网不好的同学提供一个解决方案,根据程序运行时命令行提示的下载网址,自己挂vpn去下,下好之后放在指定位置,这样跑训练的时候会检测到vgg19的模型已经下载了,直接进入下一步。这个模型指定的位置是/.keras/model,/.keras这个文件夹是个隐藏文件夹,需要设置一下隐藏文件夹可见才行。
那么训练准备好数据集就可以开始了
python train_pose.py