安装densepose的全部过程

Installation instructions
preface: during the installation of densepose, we met with many kind of problems,so I write this Installation instructions
Environment requirements: os: Linux ubuntu 16.04 NVIDIA GPU Python2(the best)
others: Caffe2,use pip to setup various standard Python packages,and the COCO API;Instructions for installing these dependencies are found below
Notes:(1)Detectron module operates currently do not have a CPU implementation;we need a GPU system
(2)Detectron has been tested extensively with CUDA9.0 and cuDNN7.4.02(just for cuda-9.0)
There are five main part of the Installation:
(1) Install caffe2
(2) Install detectron
(3) Install Install the COCO API
(4) Install densepose
(5) Install dataset(densepose and COCO)
(6)Setting-up the COCO dataset.
(7)test densepose
The first part is setup caffe2: Details of installation are as follows
choose the Ubuntu as our Platform and Build From Source as our Install Type
(1)Install Dependencies (安装依赖项) and caffe2
(1)sudo apt-get update----This command accesses every web site in the source list(Notice:the network must be smooth).
(2)sudo apt-get install -y --no-install-recommends
build-essential
git
libgoogle-glog-dev
libgtest-dev
libiomp-dev
libleveldb-dev
liblmdb-dev
libopencv-dev
libopenmpi-dev
libsnappy-dev
libprotobuf-dev
openmpi-bin
openmpi-doc
protobuf-compiler
python-dev
python-pip
this step is install caffe2 dependencies all this is the essential lib normally it has no problem when your network is very good ,there are interrupt when the network very bad ,and another problem is python-pip there will be an warning ,so to solve this warning you could update the pip to the newly edition
(3)pip install --user
future
numpy
protobuf
typing
hypothesis
this step is to install the python lib to support the program,and also there are problems about update and cat not install,remember which can not install install which following is the successful install

(4)install cmake first choose plateform for Ubuntu 16.04
input the command in the terminal:
sudo apt-get install -y --no-install-recommends
libgflags-dev
cmake
of course this step is no problems

(5)if you have a GPU,following this step (normally this is the most important step)
cautious this step (you should according to offical website).you should do three thing.firstlg you shoud ensure your computer has GPU driver if have not.you should install the the GPU driver after you install it input the command: nvidia-smi to check the driver is install success
5.1 install cuda-9.0 download the .run file and into you download directory and into your terminal:
sudo chmod 777 XXX.run (xxx is your setup filename)
sudo sh XXX.run (setup the install file)
gedit ~/.bashrc
export PATH=/usr/local/cuda-9.0/bin: P A T H e x p o r t L D L I B R A R Y P A T H = / u s r / l o c a l / c u d a 9.0 / l i b 64 : PATH export LD_LIBRARY_PATH=/usr/local/cuda-9.0/lib64: LD_LIBRARY_PATH
source ~/.bashrc
test the cuda-9.0: (1)cd /usr/local/cuda-9.0/samples/1_Utilities/deviceQuery (2)sudo make (3)sudo ./deviceQuery
5.2 install cudnn7(corresponding to your cuda-9.0).download the cudnn7 .tgz format file
(1)tar -xzvf cudnn-XXX.tgz
(2)sudo cp cuda/include/cudnn.h /usr/local/cuda/include
(3)sudo cp cuda/lib64/libcudnn* /usr/local/cuda/lib64
(4)sudo chmod a+r /usr/local/cuda/include/cudnn.h /usr/local/cuda/lib64/libcudnn*
test cudnn7
input: nvcc -V there are some message about your cuda and cudnn
(6)clone and build caffe2
(1)git clone https://github.com/pytorch/pytorch.git && cd pytorch
only the network is good this step has little problem success interface

(2)git submodule update --init –recursive
this step also has many problems ensure there were not broken net the success interface

(3)python setup.py install(contieue a very long time)
threre still has problems about this step such as (missing lib .runtime error and permission denied and so on)
missing lab according to the warning you can solve it. Permission denied you can add the command sudo before the python setup.py . Another question is file truncation this problem seems have not a better solve method may be the route is not on the directory or you can replace it with the success one
the success interface fllowing:(4)test the caffe2 installation
input: (1)cd ~ && python -c ‘from caffe2.python import core’ 2>/dev/null &echo “Success” || echo “Failure”

(2)python caffe2/python/operator_test/activation_ops_test.py to test GPU there are many problems and display warning and not support GPU this is very normal problem you can choose current direct _ops_test.py format file to test or input
python2 -c ‘from caffe2.python import workspace; print(workspace.NumCudaDevices())’
there will display 1 suggest the installation is success

sudo gedit ~/.bashrc
export PYTHONPATH=/usr/local: P Y T H O N P A T H e x p o r t P Y T H O N P A T H = PYTHONPATH export PYTHONPATH= PYTHONPATH:/home/feng/pytorch/caffe2/build
export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
source ~/.bashrc
until now the caffe2 installation success!!
(二)install the detectron (Target Detection Framework)
the following step:
(1)sudo git clone https://github.com/facebookresearch/detectron
(2)sudo pip install -r D E T E C T R O N / r e q u i r e m e n t s . t x t ( DETECTRON/requirements.txt ( DETECTION is the route of detectron)
(3)cd $DETECTRON && make (installation if has problem you should add sudo to boost the Jurisdiction)
(4)test detectron: python $DETECTRON/detectron/tests/test_spatial_narrow_as_op.py the success interface

you must ensure every step is correct !!
(三)install COCO API

COCOAPI=/path/to/clone/cocoapi

(1)git clone https://github.com/cocodataset/cocoapi.git $COCOAPI
(2)cd $COCOAPI/PythonAPI

Install into global site-packages

(3)make install remember you should add the sudo to ensure inatall correctly

Alternatively, if you do not have permissions or prefer

not to install the COCO API into global site-packages

(4)python2 setup.py install --user
you also reference the CSDN:https://blog.csdn.net/qq_38522972/article/details/83586285#comments normal problem will be solved
(四)Install densepose (very crucial)
(1)Clone the Densepose repository: sudo git clone
https://github.com/facebookresearch/densepose $DENSEPOSE
(2)Install Python dependencies: pip install -r $DENSEPOSE/requirements.txt(It is essential to add the sudo)
(3)Set up Python modules:cd $DENSEPOSE && make
(4)test the before step:python2 $DENSEPOSE/detectron/tests/test_spatial_narrow_as_op.py
the problem occur

the solution:
trace problem,problem occur in detectron/utils/env.py file def get_detectron_ops_libs().Function not found in environment variable lib/libcaffe2_detectron_ops_gpu.so.This file was compiled earlier caffe2(formal pytorch)file build/lib.so in detectron/utils/env.py file import sys add:
sys.path.insert(0, ‘/path/to/your/pytorch/build’)
reference:https://blog.csdn.net/qq_38522972/article/details/84287670
the success interface:

(5) Build the custom operators library: cd $DENSEPOSE && make ops
this step occur many problems choose two problem and give solution one is permission you should add sudo before the command and another one is CmakeLists file among the file the route is not correct you shoule enter the file and change the route and repeat before command the success interface:

(6)Check that the custom operator tests pass:

python2 $DENSEPOSE/detectron/tests/test_zero_even_op.py

until now we finish Build up desepose
(五) Install dataset(densepose and COCO)
(1)Get necessary files to run, train and evaluate DensePose
cd $DENSEPOSE/DensePoseData
bash get_densepose_uv.sh
(2)For training, download the DensePose-COCO dataset:
bash get_DensePose_COCO.sh
(3)For evaluation, get the necessary files:
bash get_eval_data.sh
(六)Setting-up the COCO dataset.
(1)Create a symlink for the COCO dataset in your datasets/data folder.
ln -s /path/to/coco $DENSEPOSE/detectron/datasets/data/coco
(2)Create symlinks for the DensePose-COCO annotations
ln -s $DENSEPOSE/DensePoseData/DensePose_COCO/densepose_coco_2014_minival.json $DENSEPOSE/detectron/datasets/data/coco/annotations/
ln -s $DENSEPOSE/DensePoseData/DensePose_COCO/densepose_coco_2014_train.json $DENSEPOSE/detectron/datasets/data/coco/annotations/
ln -s $DENSEPOSE/DensePoseData/DensePose_COCO/densepose_coco_2014_valminusminival.json $DENSEPOSE/detectron/datasets/data/coco/annotations/
(3)Your local COCO dataset copy at /path/to/coco should have the following directory structure:
coco
|_ coco_train2014
| |_ .jpg
| |_ …
| |_ .jpg
|_ coco_val2014
|_ …
|_ annotations
|_ instances_train2014.json
|_ …
(七)test densepose
first into the directory of densepoose in the terminal:input the following command

python2 tools/infer_simple.py
–cfg configs/DensePose_ResNet101_FPN_s1x-e2e.yaml
–output-dir DensePoseData/infer_out/
–image-ext jpg
–wts https://dl.fbaipublicfiles.com/densepose/DensePose_ResNet101_FPN_s1x-e2e.pkl
DensePoseData/demo_data/test.jpg
and a pdf file
将计算机视觉中经典的工具和深度学习(自底向上的区域候选框和卷积神经网络)组合是非常重要的。而不是违背科学探索的主线,这两个部分是自然而且必然的结合

猜你喜欢

转载自blog.csdn.net/nbxuwentao/article/details/86658508