論文及源代碼網址: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