论文及源代码网址:html
https://github.com/ZheC/Realtime_Multi-Person_Pose_Estimationpython
地址2:git
https://github.com/CMU-Perceptual-Computing-Lab/openpose/blob/master/doc/installation.mdgithub
首先是跑一个例子试试,使用shell
https://github.com/CMU-Perceptual-Computing-Lab/openpose/json
按照做者的指导,以下:bootstrap
cd training; bash getData.sh
to obtain the COCO images in dataset/COCO/images/
, keypoints annotations in dataset/COCO/annotations/
and COCO official toolbox in dataset/COCO/coco/
.
getANNO.m
in matlab to convert the annotation format from json to mat in dataset/COCO/mat/
.genCOCOMask.m
in matlab to obatin the mask images for unlabeled person. You can use 'parfor' in matlab to speed up the code.
genJSON('COCO')
to generate a json file in dataset/COCO/json/
folder. The json files contain raw informations needed for training.python genLMDB.py
to generate your LMDB. (You can also download our LMDB for the COCO dataset (189GB file) by: bash get_lmdb.sh
)python setLayers.py --exp 1
to generate the prototxt and shell file for training.bash train_pose.sh 0,1
(generated by setLayers.py) to start the training with two gpus.
这种跑一个例子失败以后,ubuntu
转而使用最根本的方法从头按照步骤编译,不走捷径:参考下面的网址vim
由于电脑里已经安装过caffe的依赖环境了,因此把caffe编译一下就能够用了,参考下面的话 [3] 安全
### Install Caffe ### cd 3rdparty/caffe/ # Select your desired Makefile file (run only one of the next 4 commands) cp Makefile.config.Ubuntu14_cuda7.example Makefile.config # Ubuntu 14, cuda 7 cp Makefile.config.Ubuntu14_cuda8.example Makefile.config # Ubuntu 14, cuda 8 cp Makefile.config.Ubuntu16_cuda7.example Makefile.config # Ubuntu 16, cuda 7 cp Makefile.config.Ubuntu16_cuda8.example Makefile.config # Ubuntu 16, cuda 8 # Change any custom flag from the resulting Makefile.config (e.g. OpenCV 3, Atlas/OpenBLAS/MKL, etc.) # Compile Caffemake all -j${number_of_cpus} && make distribute -j${number_of_cpus}
好比make all -j16(使用16个CPU同时运行)
3. 安装 OpenPose cd ../../models/ bash ./getModels.sh # It just downloads the Caffe trained models cd .. # Same file cp command as the one used for Caffe cp ubuntu/Makefile.config.Ubuntu14_cuda7.example Makefile.config # Change any custom flag from the resulting Makefile.config (e.g. OpenCV 3, Atlas/OpenBLAS/MKL, etc.) make all -j${number_of_cpus}
必定要严格按照顺序(实验室服务器用的是zsh,因此注意替换bash为zsh)
若是使用OpenCV 3版本的话,能够经过全部make,可是不能运行实际的例子
按照做者在某个Issue下的回答,应该使用OpenCV2.4,而后折腾好久,见另外一篇博客 [7]
而后出现没法make,错误中关键行为这个
../lib/libcaffe.so: undefined reference to cv::imread(cv::String const&, int)'
搜索以后获得解答:[4]
open your Makefile with some text editor, locate line 164 (in my case), add opencv_imgcodecs behind.
LIBRARIES += glog gflags protobuf leveldb snappy \ lmdb boost_system hdf5_hl hdf5 m \ opencv_core opencv_highgui opencv_imgproc opencv_imgcodecs
在vim里使用
:se nu
而后回车,能够显示行号;使用
/opencv
能够快速定位到第一个出现的opencv字符串的位置
添加后能够make了,而后不出意料的仍是不能运行实际的例子:
实际例子运行方法:[3]
1. Running on Video
# Ubuntu ./build/examples/openpose/openpose.bin --video examples/media/video.avi # With face and hands ./build/examples/openpose/openpose.bin --video examples/media/video.avi --face --hand
会出现
zsh: abort (core dumped) ./build/examples/openpose/openpose.bin --video examples/media/video.avi
再试试别的运行方法:
3. Running on Images
# Ubuntu ./build/examples/openpose/openpose.bin --image_dir examples/media/ # With face and hands ./build/examples/openpose/openpose.bin --image_dir examples/media/ --face --hand
会出现
Starting pose estimation demo.
Error:
boost::filesystem::directory_iterator::construct: No such file or directory
Coming from:
- src/openpose/utilities/fileSystem.cpp:getFilesOnDirectory():186
- src/openpose/producer/imageDirectoryReader.cpp:getImagePathsOnDirectory():25
- src/openpose/utilities/flagsToOpenPose.cpp:flagsToProducer():133
terminate called after throwing an instance of 'std::runtime_error'
what():
Error:
boost::filesystem::directory_iterator::construct: No such file or directory
Coming from:
- src/openpose/utilities/fileSystem.cpp:getFilesOnDirectory():186
- src/openpose/producer/imageDirectoryReader.cpp:getImagePathsOnDirectory():25
- src/openpose/utilities/flagsToOpenPose.cpp:flagsToProducer():133
zsh: abort (core dumped) ./build/examples/openpose/openpose.bin --image_dir examples/media/
而后搜索后,根据 [5] DuinoDu的回答,去 [6] 里找答案,“install boost from src.”
根据user3715812的回答,输入如下命令行来安装BOOST:
wget -O boost_1_55_0.tar.gz http://sourceforge.net/projects/boost/files/boost/1.55.0/boost_1_55_0.tar.gz/download tar xzvf boost_1_55_0.tar.gz cd boost_1_55_0/ ./bootstrap.sh --prefix=/usr/local // 这里改为本身想要安装到的目录 ./b2 ./b2 install // 没有SUDO权限可是也能够
而后再去运行
./build/examples/openpose/openpose.bin --image_dir examples/media/
此次的报错和上次不同了,是
Starting pose estimation demo. Auto-detecting GPUs... Detected 16 GPU(s), using them all. Starting thread(s) : cannot connect to X server E0819 00:20:53.031266 20765 common.cpp:114] Cannot create Cublas handle. Cublas won't be available. E0819 00:20:53.031266 20766 common.cpp:114] Cannot create Cublas handle. Cublas won't be available. E0819 00:20:53.031266 20771 common.cpp:114] Cannot create Cublas handle. Cublas won't be available. E0819 00:20:53.031266 20773 common.cpp:114] Cannot create Cublas handle. Cublas won't be available. E0819 00:20:53.031266 20767 common.cpp:114] Cannot create Cublas handle. Cublas won't be available. E0819 00:20:53.031266 20775 common.cpp:114] Cannot create Cublas handle. Cublas won't be available. E0819 00:20:53.031266 20776 common.cpp:114] Cannot create Cublas handle. Cublas won't be available. E0819 00:20:53.031266 20777 common.cpp:114] Cannot create Cublas handle. Cublas won't be available. E0819 00:20:53.031266 20778 common.cpp:114] Cannot create Cublas handle. Cublas won't be available. E0819 00:20:53.031266 20765 common.cpp:121] Cannot create Curand generator. Curand won't be available. E0819 00:20:53.031266 20769 common.cpp:114] Cannot create Cublas handle. Cublas won't be available. E0819 00:20:53.031266 20768 common.cpp:114] Cannot create Cublas handle. Cublas won't be available. E0819 00:20:53.031266 20774 common.cpp:114] Cannot create Cublas handle. Cublas won't be available. E0819 00:20:53.031266 20770 common.cpp:114] Cannot create Cublas handle. Cublas won't be available. E0819 00:20:53.031266 20779 common.cpp:114] Cannot create Cublas handle. Cublas won't be available. E0819 00:20:53.031266 20772 common.cpp:114] Cannot create Cublas handle. Cublas won't be available. E0819 00:20:53.031266 20779 common.cpp:121] Cannot create Curand generator. Curand won't be available. E0819 00:20:53.031266 20771 common.cpp:121] Cannot create Curand generator. Curand won't be available. E0819 00:20:53.031266 20773 common.cpp:121] Cannot create Curand generator. Curand won't be available. F0819 00:20:53.031266 20779 common.cpp:152] Check failed: error == cudaSuccess (29 vs. 0) driver shutting downF0819 00:20:53.031266 20771 common.cpp:152] Check failed: error == cudaSuccess (29 vs. 0) driver shutting downF0819 00:20:53.035267 20773 common.cpp:152] Check failed: error == cudaSuccess (29 vs. 0) driver shutting down *** Check failure stack trace: *** E0819 00:20:53.031266 20780 common.cpp:114] Cannot create Cublas handle. Cublas won't be available. E0819 00:20:53.031266 20778 common.cpp:121] Cannot create Curand generator. Curand won't be available. E0819 00:20:53.031266 20775 common.cpp:121] Cannot create Curand generator. Curand won't be available. E0819 00:20:53.031266 20767 common.cpp:121] Cannot create Curand generator. Curand won't be available. F0819 00:20:53.031266 20779 common.cpp:152] Check failed: error == cudaSuccess (29 vs. 0) driver shutting downF0819 00:20:53.031266 20771 common.cpp:152] Check failed: error == cudaSuccess (29 vs. 0) driver shutting downF0819 00:20:53.035267 20773 common.cpp:152] Check failed: error == cudaSuccess (29 vs. 0) driver shutting downF0819 00:20:53.035267 20778 common.cpp:152] Check failed: error == cudaSuccess (29 vs. 0) driver shutting downF0819 00:20:53.035267 20775 common.cpp:152] Check failed: error == cudaSuccess (29 vs. 0) driver shutting downF0819 00:20:53.035267 20767 common.cpp:152] Check failed: error == cudaSuccess (29 vs. 0) driver shutting down *** Check failure stack trace: *** F0819 00:20:53.031266 20765 common.cpp:152] Check failed: error == cudaSuccess (29 vs. 0) driver shutting down zsh: abort (core dumped) ./build/examples/openpose/openpose.bin --image_dir examples/media/
而后在GITHUB 的ISSUE区准备提问的时候,根据提示
Note: add
--logging_level 0
to get higher debug information.
在运行的命令行后加上了这个,即:
./build/examples/openpose/openpose.bin --image_dir examples/media/ --logging_level 0
因而获得了较为准确的信息:
能够理解为又一个图形界面要展现可是出不来 [8](X server相关),
查阅资料后根据 [9] 的xiaoyan的回答:
Add "export DISPLAY=your ip:0.0" in ~/.bashrc, source ~/.bashrc (ip is your host IP, where you wanna display plots or things like that. If you are using Windows, cmd-ipconfig, find your IP).
因而再也不出现X server问题了,出现了下图的问题
找了很久没找到问题,最后求助了组里的史博士,这里表示很是感谢!!!
缘由是这个Demo默认使用全部探测到的CUDA 设备,而实验室的CUDA设备还有不少人在用,这会形成问题(多是冲突或者资源不够,或者不被容许我的使用这么多个?)
因此在运行的命令行前面要加上必定的限制:
CUDA_VISIBLE_DEVICES=2 ./build/examples/openpose/openpose.bin --net_resolution "160x80" --video examples/media/video.avi
使得被探测到的设备数量只有两个。
而后发现仍是运行不了,为何呢?
由于OS X上的SHELL并不具有显示远程窗口的功能,
因此在史博士的推荐下使用了MobaXterm(在WIN10下),而后就成功了,由于这个软件直接内置了X server的接口
更新:若是想在Mac上运行,能够参考
[10] http://blog.csdn.net/dobell/article/details/55047811
安装XQuartz, https://www.xquartz.org 按说明安装好 打开 mac terminal ssh -X {用户名}@{远程端ip}; (注意大写的X) 此次就能够了
实际运行截图以下:
你也能够读一下我在GITHUB上的提问:
https://github.com/CMU-Perceptual-Computing-Lab/openpose/issues/184
可能会有帮助
另外:
由于实验室的服务器出于安全考虑不容许使用
sudo pip install
, 因此使用
pip install --user
来替代。[2]
[1] http://www.cnblogs.com/emituofo/archive/2011/11/13/2247523.html
[2] https://stackoverflow.com/questions/31512422/pip-install-r-oserror-errno-13-permission-denied
[3] https://github.com/CMU-Perceptual-Computing-Lab/openpose/blob/master/doc/installation.md
[4] https://github.com/BVLC/caffe/issues/1276
[5] https://github.com/CMU-Perceptual-Computing-Lab/openpose/issues/17
[6] https://stackoverflow.com/questions/12578499/how-to-install-boost-on-ubuntu
[7] http://www.cnblogs.com/QingHuan/p/7278357.html
[8] http://www.cnblogs.com/super119/archive/2010/12/18/1910065.html
[9] https://askubuntu.com/questions/571116/cannot-connect-to-x-server-error