Ubuntu16.04從源碼安裝DensePose
Installing DensePose
DensePose官網(wǎng) http://densepose.org/
DensePose代碼 https://github.com/facebookresearch/Densepose
DensePose安裝系統(tǒng)要求:有NVIDIA GPU的Linux系統(tǒng),滿足這一條件便可按照下面的步驟安裝。
安裝Anaconda
官網(wǎng)下載Linux版的Anaconda3,運(yùn)行bash Anaconda3-5.2.0-Linux-x86_64.sh。
安裝caffe2(pytorch)
創(chuàng)建caffe2的conda環(huán)境
conda create -n densepose python=2.7
進(jìn)入新創(chuàng)建的環(huán)境
source activate densepose
安裝一些需要的庫(kù)
(densepose)$ conda install -y future gflags leveldb mkl mkl-include numpy opencv protobuf
(densepose)$ conda install flask graphviz hypothesis jupyter matplotlib pydot pyyaml requests scikit-image scipy setuptools tornado
下載pytorch及其依賴的第三方庫(kù)
# git clone --recursive https://github.com/pytorch/pytorch.git
(densepose)$ git clone -b v0.4.1 --recursive https://github.com/pytorch/pytorch.git # 下載v0.4.1分支代碼
(densepose)$ cd pytorch
(densepose)$ git submodule update --init
編譯并安裝
(densepose)$ rm -rf build && mkdir build && cd build
(densepose)$ cmake -DCMAKE_PREFIX_PATH=~/anaconda3/envs/densepose -DCMAKE_INSTALL_PREFIX=~/anaconda3/envs/densepose -DUSE_NATIVE_ARCH=ON ..
(densepose)$ make -j32 install
測(cè)試是否安裝成功
# To check if Caffe2 build was successful
(densepose)$ python2 -c 'from caffe2.python import core' 2>/dev/null && echo "Success" || echo "Failure"
# 輸出Success即安裝成功,否則失敗
# To check if Caffe2 GPU build was successful
(densepose)$ python2 -c 'from caffe2.python import workspace; print(workspace.NumCudaDevices())'
# 輸出8或者其他,表示顯卡個(gè)數(shù)
安裝cocoapi
# COCOAPI=/path/to/clone/cocoapi
(densepose)$ git clone https://github.com/cocodataset/cocoapi.git $COCOAPI
(densepose)$ cd $COCOAPI/PythonAPI
# Install into global site-packages
(densepose)$ make install
# Alternatively, if you do not have permissions or prefer
# not to install the COCO API into global site-packages
(densepose)$ python2 setup.py install --user
安裝densepose
安裝densepose
(densepose)$ mkdir $DENSEPOSE_DIR && cd $DENSEPOSE_DIR
(densepose)$ git clone https://github.com/facebookresearch/densepose
(densepose)$ cd densepose
(densepose)$ pip install -r requirements.txt # install Python dependencies
(densepose)$ make # set up python modules
(densepose)$ python2 detectron/tests/test_spatial_narrow_as_op.py # check that Detectron tests pass
(densepose)$ make ops # Build the custom operators library
(densepose)$ python2 detectron/tests/test_zero_even_op.py # check that the custom operator tests pass
下載densepose數(shù)據(jù):
(densepose)$ cd DensePoseData
(densepose)$ bash get_densepose_uv.sh
如果需要訓(xùn)練,下載DensePose-COCO數(shù)據(jù)集:
(densepose)$ bash get_DensePose_COCO.sh
如果評(píng)價(jià)(evaluation),還需下載其他需要的文件:
(densepose)$ bash get_eval_data.sh
Inference with Pretrained Models
首先從這里下載與DensePose_ResNet101_FPN_s1x-e2e.yaml相匹配的訓(xùn)練好的模型,并放在weights文件夾下,然后執(zhí)行下面命令:
(densepose)$ python2 tools/infer_simple.py \
--cfg configs/DensePose_ResNet101_FPN_s1x-e2e.yaml \
--output-dir DensePoseData/infer_out/ \
--image-ext jpg \
--wts weights/DensePose_ResNet101_FPN_s1x-e2e.pkl \
DensePoseData/demo_data/demo_im.jpg

浙公網(wǎng)安備 33010602011771號(hào)