DeepLearning py faster rcnn - eiichiromomma/CVMLAB GitHub Wiki

(DeepLearning) py-faster-rcnn

py-faster-rcnnを弄ってみる。(UbuntuでCUDA8の環境)

インストールからデモまで

git clone https://github.com/rbgirshick/py-faster-rcnn.git
cd py-faster-rcnn/
git submodule update --init --recursive
cd caffe-fast-rcnn/
git remote add caffe https://github.com/BVLC/caffe.git
git fetch caffe
git merge -X theirs caffe/master
cd ..

でinclude/caffe/layers/python_layer.hppを編集。vim使う場合は

vim include/caffe/layers/python_layer.hpp 

self_.attr("phase") = static_cast<int>(this->phase_);

を削除。(ここ情報)

あとはCaffeのインストールのお約束でMakefile.configの内容を弄る。

cp Makefile.config.example Makefile.config
vim Makefile.config

pythonを使うので、大事なのは

WITH_PYTHON_LAYER:=1

のようにPYTHON_LAYERのコメント外すところ。diffをとると以下のようになる。(ついでにCUDAのarchも削ってる)

--- Makefile.config.example	2017-06-15 18:40:24.036162185 +0900
+++ Makefile.config	2017-06-15 19:02:44.323259423 +0900
@@ -2,7 +2,7 @@
 # Contributions simplifying and improving our build system are welcome!
 
 # cuDNN acceleration switch (uncomment to build with cuDNN).
-# USE_CUDNN := 1
+USE_CUDNN := 1
 
 # CPU-only switch (uncomment to build without GPU support).
 # CPU_ONLY := 1
@@ -33,9 +33,7 @@
 # CUDA architecture setting: going with all of them.
 # For CUDA < 6.0, comment the *_50 through *_61 lines for compatibility.
 # For CUDA < 8.0, comment the *_60 and *_61 lines for compatibility.
-CUDA_ARCH := -gencode arch=compute_20,code=sm_20 \
-		-gencode arch=compute_20,code=sm_21 \
-		-gencode arch=compute_30,code=sm_30 \
+CUDA_ARCH := -gencode arch=compute_30,code=sm_30 \
 		-gencode arch=compute_35,code=sm_35 \
 		-gencode arch=compute_50,code=sm_50 \
 		-gencode arch=compute_52,code=sm_52 \
@@ -88,11 +86,12 @@
 # PYTHON_LIB += $(shell brew --prefix numpy)/lib
 
 # Uncomment to support layers written in Python (will link against Python libs)
-# WITH_PYTHON_LAYER := 1
+WITH_PYTHON_LAYER := 1
 
 # Whatever else you find you need goes here.
-INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include
-LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib
+INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/include/hdf5/serial /usr/local/include
+LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib/x86_64-linux-gnu/hdf5/serial /usr/lib
+
 
 # If Homebrew is installed at a non standard location (for example your home directory) and you use it for general dependencies
 # INCLUDE_DIRS += $(shell brew --prefix)/include

で、build。足りなそうなパッケージも入れておく。

pip install scikit-image pydot
sudo aptitude install graphviz graphviz-dev
make -j16
make pycaffe
make pytest
cd lib
make
cd ..

でbuild完了。試しにデモを動かす。

tools/demo.py 

で以下のように結果が出てくる。かなり速い。

⚠️ **GitHub.com Fallback** ⚠️