ubuntu运行Faster R-CNN

论文名:FasterR-CNN: Towards Real-Time Object Detection with Region Proposal Networks

代码链接https://github.com/ShaoqingRen/faster_rcnn

查阅的博客:http://blog.csdn.net/qq_30040223/article/details/48491997

 

接下来是各种版本号:

openCVversion

命令:$ pkg-config --modversion opencv                                                                       

输出:3.0.0

Cuda版本号:7.0

…..

 

错误类型

../lib/libcaffe.so: undefined reference tocv::imread(cv::String const&, int)' collect2: error: ld returned 1 exitstatus make[2]: *** [tools/compute_image_mean] Error 1 make[2]: Leaving

解决:

open yourMakefile with some text editor, locate line 164 (in my case), addopencv_imgcodecs behind.

 LIBRARIES += glog gflags protobuf leveldbsnappy \

  lmdb boost_system hdf5_hl hdf5 m \

  opencv_core opencv_highgui opencv_imgprocopencv_imgcodecs

 (链接: https://github.com/BVLC/caffe/issues/1276)

错误类型

LD -o .build_release/lib/libcaffe.so

/usr/bin/ld:/usr/local/lib/libgflags.a(gflags.cc.o): relocation R_X86_64_32S against`.rodata' can not be used when making a shared object; recompile with -fPIC

/usr/local/lib/libgflags.a: error addingsymbols: Bad value

collect2: error: ld returned 1 exit status

make: *** [.build_release/lib/libcaffe.so]Error 1

解决:

 

Ubuntu下运行Faster-Rcn

Faster-Rcnn 介绍

前几天Shaoqing Ren放出了Faster-Rcnn的代码,可以在他的Github上下载得到,上面也有详细的配置说明。 
我下载下来,在自己的虚拟机上测试了一下,速度上确实比之前的Fast-Rcnn有提高。

SPP-Net,Fast-Rcnn,Faster-Rcnn都是在Ross Girshick2014年发布的RCNN上面的改进与提高,其中SPP-Net,Faster-Rcnn都是Shaoqing Ren的作品,当然其中还有Kaiming He以及Ross Girshick等微软亚研院研究员的贡献。Shaoqing Ren也是个牛人啊,可以去他的个人主页看看他做的一些工作,ICCV,CVPR,ECCV三大会,PAMI都发过论文,今年Faster-Rcnn还发表在了NIPS上,是我的奋斗目标!

Faster-Rcnn相对于Fast-Rcnn的改进在于将Object Proposal利用CNN网络实现,并与Detection的CNN网络结合实现了一个端到端的Object Detection框架。之前Fast-Rcnn的Proposal是利用Selective Search实现的,SS方法虽然得到的Proposal相对于其他方法是较好的,但是其速度比较慢,更不用说跟利用GPU进行加速的Detection步骤相比,由此Proposal的产生便成为了一个瓶颈。

而Faster-Rcnn便解决了这个问题,不单单是加速了Proposal的产生,还将两个网络结合进行优化,于是原本跟Detection任务分离的Proposal步骤被结合了起来,Detection的结果好坏会通过梯度的回传影响到Proposal网络的参数,Faster-Rcnn实现优化的思路采用的是常见的固定一个更新另一个的策略,固定Proposal网络,更新Detection网络,再固定Detection网络,更新Proposal网络。

Faster-Rcnn 配置

参考Shaoqing Ren的配置说明:

(1) 安装Matlab 2014a 
(2) 下载源代码

git clone --recursive https://github.com/ShaoqingRen/faster_rcnn.git

(3)配置Caffe 

将你之前配置过的CaffeMakefile.config拷贝至./faster-rcnn/external/caffe,记得修改Matlab接口,接着编译就可以了。

make -j$(nproc)make 

matcaffe -j$(nproc)

(4) 运行Faster-Rcnn 

A. 在faster-rcnn路径下打开Matlab,或者直接打开Matlab再切换到faster-rcnn路径,运行faster_rcnn_build.m,没有GPU的话在Compiling nms_gpu_mex时会出错,但其他是能够正常编译的,所以没有关系。 
B. 运行startup.m,会加入其所需路径。 
C. 运行fetch_data/fetch_faster_rcnn_final_model.m,下载所需模型。推荐在作者Github上找百度云盘的下载链接,速度会快上不少,下载完将output文件夹解压至./faster-rcnn目录下。 
D. 打开experiments/script_faster_rcnn_demo.m测试文件,没有GPU不要直接运行,其代码默认是用GPU进行测试的,因此在CPU模式下会出错。 
修改下代码,不使用GPU即可: 
修改前:

%% -------------------- CONFIG --------------------
opts.caffe_version          = 'caffe_faster_rcnn';
opts.gpu_id                 = auto_select_gpu;
active_caffe_mex(opts.gpu_id, opts.caffe_version);

opts.per_nms_topN           = 6000;
opts.nms_overlap_thres      = 0.7;
opts.after_nms_topN         = 300;
opts.use_gpu                = True;

opts.test_scales            = 600;

修改后:

%% -------------------- CONFIG --------------------
opts.caffe_version          = 'caffe_faster_rcnn';
%opts.gpu_id                 = auto_select_gpu;
%active_caffe_mex(opts.gpu_id, opts.caffe_version);

opts.per_nms_topN           = 6000;
opts.nms_overlap_thres      = 0.7;
opts.after_nms_topN         = 300;
opts.use_gpu                = false;

opts.test_scales            = 600;

E.运行该测试文件 

默认载入的模型是VGG16网络,如果运行过程中出现kill,那就把模型换成ZF的好了。 
VGG16网络比较大,可能会出现内存不足,所以在虚拟机或者内存较小的机器上推荐使用小模型ZF来进行测试。

%% -------------------- INIT_MODEL --------------------
%model_dir = fullfile(pwd, 'output', 'faster_rcnn_final', 'faster_rcnn_VOC0712_vgg_16layers'); %% VGG-16
model_dir  = fullfile(pwd, 'output', 'faster_rcnn_final', 'faster_rcnn_VOC0712_ZF'); %% ZF
proposal_detection_model    = load_proposal_detection_model(model_dir);

F.测试结果 

我的CPU是I5-4460,测试速度是比Fast-Rcnn更快的。

%% -------------------- INIT_MODEL --------------------
%model_dir = fullfile(pwd, 'output', 'faster_rcnn_final', 'faster_rcnn_VOC0712_vgg_16layers'); %% VGG-16
model_dir  = fullfile(pwd, 'output', 'faster_rcnn_final', 'faster_rcnn_VOC0712_ZF'); %% ZF
proposal_detection_model    = load_proposal_detection_model(model_dir);

这里写图片描述 
这里写图片描述


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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值