R-CNN配置

R-CNN: Regions with Convolutional Neural Network Features
该方法在2014由rbg大神提出,在github开源项目地址:https://github.com/rbgirshick/rcnn

服务器环境:
Ubuntu16.04 x64环境,TITAN Xp,CUDA8,cudnn5.1, OpenCV3.2, Matlab2016b

依赖项目:

R-CNN项目是使用matlab来实现的,机器学习库使用caffe,项目中提供的安装说明,给出的是Matlab2012b,Linux 64-bit,Caffev0.999的组合,实际上,这是很陈旧的软件版本了,现在是2017.12.7,Matlab都要退出2018版本了,Caffev0.999更是4年前的实现了。
caffev0.9999配置
因为需要编译caffe,为r-cnn提供matlab版深度学习函数库,所以这里特别强调下它对后面操作的有着重要影响。

经过尝试,caffev0.999版本的caffe下载之后,配置Makefile.config, 然后开始编译,总是报错,而且也没找到最终的解决方法。

好在在caffe项目tag方式查找历史版本的时候,最近的一个版本caffev0.9999在生成的matlab版caffe库和caffev0.999版形式是一致的,而caffe主分支是不满足的,主要体现在其中的matlab文件夹下名称不同,因此在这里不能使用主分支的caffe编译得到的matlab版caffe库。
这里写图片描述

这里写图片描述

这里给出caffev0.9999的编译配置过程。

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

修改成

## Refer to http://caffe.berkeleyvision.org/installation.html
# Contributions simplifying and improving our build system are welcome!

# CPU-only switch (uncomment to build without GPU support).
# CPU_ONLY := 1

# To customize your choice of compiler, uncomment and set the following.
# N.B. the default for Linux is g++ and the default for OSX is clang++
# CUSTOM_CXX := g++

# CUDA directory contains bin/ and lib/ directories that we need.
CUDA_DIR := /usr/local/cuda
# On Ubuntu 14.04, if cuda tools are installed via
# "sudo apt-get install nvidia-cuda-toolkit" then use this instead:
# CUDA_DIR := /usr

# CUDA architecture setting: going with all of them (up to CUDA 5.5 compatible).
# For the latest architecture, you need to install CUDA >= 6.0 and uncomment
# the *_50 lines below.
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_50,code=compute_50

# BLAS choice:
# atlas for ATLAS (default)
# mkl for MKL
# open for OpenBlas
BLAS := mkl
# Custom (MKL/ATLAS/OpenBLAS) include and lib directories.
# Leave commented to accept the defaults for your choice of BLAS
# (which should work)!
# BLAS_INCLUDE := /path/to/your/blas
# BLAS_LIB := /path/to/your/blas

# This is required only if you will compile the matlab interface.
# MATLAB directory should contain the mex binary in /bin.
MATLAB_DIR := /usr/local/MATLAB/R2016b
# MATLAB_DIR := /Applications/MATLAB_R2012b.app

# NOTE: this is required only if you will compile the python interface.
# We need to be able to find Python.h and numpy/arrayobject.h.
PYTHON_INCLUDE := /usr/include/python2.7 \
        /usr/lib/python2.7/dist-packages/numpy/core/include
# Anaconda Python distribution is quite popular. Include path:
# PYTHON_INCLUDE := $(HOME)/anaconda/include \
        # $(HOME)/anaconda/include/python2.7 \
        # $(HOME)/anaconda/lib/python2.7/site-packages/numpy/core/include

# We need to be able to find libpythonX.X.so or .dylib.
PYTHON_LIB := /usr/lib
# PYTHON_LIB := $(HOME)/anaconda/lib

# Whatever else you find you need goes here.
INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include /usr/include/hdf5/serial
LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib /usr/lib/x86_64-linux-gnu /usr/lib/x86_64-linux-gnu/hdf5/serial

BUILD_DIR := build
DISTRIBUTE_DIR := distribute

# Uncomment for debugging. Does not work on OSX due to https://github.com/BVLC/caffe/issues/171
# DEBUG := 1

# The ID of the GPU that 'make runtest' will use to run unit tests.
TEST_GPUID := 0

make all -j32开始编译,提示错误,undefined reference to cv::imread, 网上查找到解决方案,定位在opencv_imgcodecs 链接上,一种有效的解决方案是:把opencv需要的lib添加到Makefile文件中,即在Makefile文件中找到LIBRARIES , (在PYTHON_LIBRARIES := boost_python python2.7 前一行)并修改为:

LIBRARIES += glog gflags protobuf leveldb snappy \ lmdb boost_system hdf5_hl hdf5 m \ opencv_core opencv_highgui opencv_imgproc opencv_imgcodecs

再重新编译,

make clean
make all -j16
make matcaffe

参考链接:
* Caffe 工程的一些编译错误以及解决方案(undefined reference to cv::imread)
* .build_release/lib/libcaffe.so: undefined reference to cv::imread
* R-CNN在GTX1080上运行

RCNN配置:
首先下载下源码

git clone https://github.com/rbgirshick/rcnn.git

创建软链接:
在caffe的根目录,运行export CAFFE_ROOT=$(pwd), 在rcnn根目录下,执行ln -sf $CAFFE_ROOT external/caffe,

在终端中在输入matlab,进入到matlab中,会输出提示信息R-CNN startup done, 在输入>>rcnn_build(), 创建liblinear &Selective Search,编译时会出现一些警告信息,不用担心,这是正常的。
最后我们输入>> key = caffe('get_init_key');, 除非key = -2,否则我们就配置成功了。

运行demo
先下载预训练模型

./data/fetch_models.sh

在rcnn根目录下运行matlab2016,输入rcnn_demo, 结果
这里写图片描述

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值