日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 >

ubuntu运行Faster R-CNN

發(fā)布時間:2025/3/21 133 豆豆
生活随笔 收集整理的這篇文章主要介紹了 ubuntu运行Faster R-CNN 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

轉(zhuǎn)載自:http://blog.csdn.net/helloeveryon/article/details/48789079

論文名: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下運(yùn)行Faster-Rcn

Faster-Rcnn 介紹

前幾天Shaoqing Ren放出了Faster-Rcnn的代碼,可以在他的Github上下載得到,上面也有詳細(xì)的配置說明。?
我下載下來,在自己的虛擬機(jī)上測試了一下,速度上確實(shí)比之前的Fast-Rcnn有提高。

SPP-Net,Fast-Rcnn,Faster-Rcnn都是在Ross Girshick2014年發(fā)布的RCNN上面的改進(jìn)與提高,其中SPP-Net,Faster-Rcnn都是Shaoqing Ren的作品,當(dāng)然其中還有Kaiming He以及Ross Girshick等微軟亞研院研究員的貢獻(xiàn)。Shaoqing Ren也是個牛人啊,可以去他的個人主頁看看他做的一些工作,ICCV,CVPR,ECCV三大會,PAMI都發(fā)過論文,今年Faster-Rcnn還發(fā)表在了NIPS上,是我的奮斗目標(biāo)!

Faster-Rcnn相對于Fast-Rcnn的改進(jìn)在于將Object Proposal利用CNN網(wǎng)絡(luò)實(shí)現(xiàn),并與Detection的CNN網(wǎng)絡(luò)結(jié)合實(shí)現(xiàn)了一個端到端的Object Detection框架。之前Fast-Rcnn的Proposal是利用Selective Search實(shí)現(xiàn)的,SS方法雖然得到的Proposal相對于其他方法是較好的,但是其速度比較慢,更不用說跟利用GPU進(jìn)行加速的Detection步驟相比,由此Proposal的產(chǎn)生便成為了一個瓶頸。

而Faster-Rcnn便解決了這個問題,不單單是加速了Proposal的產(chǎn)生,還將兩個網(wǎng)絡(luò)結(jié)合進(jìn)行優(yōu)化,于是原本跟Detection任務(wù)分離的Proposal步驟被結(jié)合了起來,Detection的結(jié)果好壞會通過梯度的回傳影響到Proposal網(wǎng)絡(luò)的參數(shù),Faster-Rcnn實(shí)現(xiàn)優(yōu)化的思路采用的是常見的固定一個更新另一個的策略,固定Proposal網(wǎng)絡(luò),更新Detection網(wǎng)絡(luò),再固定Detection網(wǎng)絡(luò),更新Proposal網(wǎng)絡(luò)。

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) 運(yùn)行Faster-Rcnn?

A. 在faster-rcnn路徑下打開Matlab,或者直接打開Matlab再切換到faster-rcnn路徑,運(yùn)行faster_rcnn_build.m,沒有GPU的話在Compiling nms_gpu_mex時會出錯,但其他是能夠正常編譯的,所以沒有關(guān)系。?
B. 運(yùn)行startup.m,會加入其所需路徑。?
C. 運(yùn)行fetch_data/fetch_faster_rcnn_final_model.m,下載所需模型。推薦在作者Github上找百度云盤的下載鏈接,速度會快上不少,下載完將output文件夾解壓至./faster-rcnn目錄下。?
D. 打開experiments/script_faster_rcnn_demo.m測試文件,沒有GPU不要直接運(yùn)行,其代碼默認(rèn)是用GPU進(jìn)行測試的,因此在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.運(yùn)行該測試文件?

默認(rèn)載入的模型是VGG16網(wǎng)絡(luò),如果運(yùn)行過程中出現(xiàn)kill,那就把模型換成ZF的好了。?
VGG16網(wǎng)絡(luò)比較大,可能會出現(xiàn)內(nèi)存不足,所以在虛擬機(jī)或者內(nèi)存較小的機(jī)器上推薦使用小模型ZF來進(jìn)行測試。

%% -------------------- 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.測試結(jié)果?

我的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);

?

總結(jié)

以上是生活随笔為你收集整理的ubuntu运行Faster R-CNN的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。