fast-rcnn+matlab配置与测试过程

时间:2021-05-09 19:37:26

一.从官网下载必要的源文件

1.matlab版本的fast-rcnn源文件:https://github.com/ShaoqingRen/faster_rcnn

2.caffe for fast-rcnn源文件:https://github.com/ShaoqingRen/caffe/tree/faster-R-CNN


二.编译caffe for fast-rcnn生成需要mex文件

2.1.安装相应的软件

  a.安装VS2013 : http://jingyan.baidu.com/article/09ea3ede3b2496c0afde3944.html

  b.安装合适的CUDA: https://developer.nvidia.com/cuda-toolkit

2.2 下载相应的库文件

  openCV库文件:http://opencv.org/downloads.html

  boost库文件:https://sourceforge.net/projects/boost/files/boost-binaries/

  MKL库文件: https://software.intel.com/en-us/intel-parallel-studio-xe

  caffe库文件3rdparty:http://pan.baidu.com/s/1087tjG

  caffe所需的其他库文件:https://www.dropbox.com/s/mqw7b7qqx0dojkb/caffe_library.zip?dl=0

 

2.3 编译

  如果你安装的CUDA6.5,则直接运行faster_rcnn-master/fetch_data/fetch_caffe_mex_windows_vs2013_cuda65.m,获取相应的mex文件.

  如果你安装的是其他版本则需要自己编译。

  编译过程如下:

  打开 caffe-faster-R-CNN\windows\caffe\caffe.vcxproj

  修改250行 <ProjectReference Include="Library\protobuf-2.6.0\vsprojects\libprotobuf.vcxproj">,改成自己的路径

  修改292与477行CUDA的版本

  修改303与331行,改成上述自己下载的库文件路径,如果不知道怎么改就改成自己的绝对路径

   <LibraryPath>D:\software\matlab\R2014a\extern\lib\win64\microsoft;$(SolutionDir)\Library\boost\boost_1_56_0\lib64-msvc-12.0;$(SolutionDir)\caffe\lib;$(SolutionDir)\Library\mkl\lib\intel64;$(SolutionDir)\Library\mkl\compiler\lib\intel64;$(SolutionDir)\Library\opencv\opencv_3_0\build\x64\vc12\lib;$(OutDir);$(VCInstallDir)lib\amd64;$(VCInstallDir)atlmfc\lib\amd64;$(WindowsSDK_LibraryPath_x64);$(CUDA_PATH_V8_0)\lib\$(Platform)</LibraryPath>
    <IncludePath>D:\software\matlab\R2014a\extern\include;D:\software\matlab\R2014a\toolbox\distcomp\gpu\extern\include;$(SolutionDir)\Library\boost\boost_1_56_0;$(SolutionDir)\Library\opencv\opencv_3_0\build\include;$(SolutionDir)\Library\mkl\include;$(SolutionDir)\caffe;$(SolutionDir)\caffe\include;$(SolutionDir)\caffe\include\openblas;$(SolutionDir)\caffe\include\caffe\proto;$(SolutionDir)\Library\glog-0.3.3\src\windows;$(SolutionDir)\Library\protobuf-2.6.0\src;$(SolutionDir)\Library\protobuf-2.6.0\gtest\include;$(SolutionDir)\Library\gflags\include;$(SolutionDir)\Library\HDF5\1.8.13\include;$(SolutionDir)\Library\snappy-windows-1.1.1.8\include;$(SolutionDir)\Library\leveldb\include;$(SolutionDir)\Library\lmdb-0.9.15;$(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(WindowsSDK_IncludePath);$(CUDA_PATH_V8_0)\include;$(IncludePath)</IncludePath>
  修改346行改成自己的lib库文件,我这里主要修改了openCV的lib文件

 <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;comdlg32.lib;advapi32.lib;cublas.lib;cuda.lib;curand.lib;cudart.lib;gflags.lib;libglog.lib;mkl_intel_lp64.lib;mkl_intel_thread.lib;mkl_core.lib;libiomp5md.lib;pthreadVC2_x64.lib;opencv_ts300d.lib;opencv_world300d.lib;leveldb.lib;lmdb.lib;hdf5.lib;hdf5_hl.lib</AdditionalDependencies>
   双击caffe.vcxproj,用vs打开,改成release_mex运行生成所需的mex文件。

生成的mex文件在caffe-faster-R-CNN\x64\Release_Mex文件夹下,我这里总共有24项。将这24项拷贝到faster_rcnn-master\external\caffe\matlab\caffe_faster_rcnn文件中.同时将caffe-faster-R-CNN\matlab中的+caffe的文件夹拷贝到faster_rcnn-master\external\caffe\matlab\caffe_faster_rcnn文件夹下。


三.测试

(1)运行faster_rcnn-master\faster_rcnn_build.m

 (2)运行faster_rcnn-master\startup.m

(3)运行faster_rcnn-master\fetch_data\fetch_faster_rcnn_final_model.m  下载训练好的模型

(下载失败的话,可以用百度云下载:https://pan.baidu.com/s/1hsFKmeK ,解压到faster_rcnn-master下)

(4)修改faster_rcnn-master\experiments\script_faster_rcnn_demo.m的model_dir为你下载的模型,然后运行。



参考博客:http://blog.csdn.net/sinat_30071459/article/details/50546891