CPU run fast R-CNN

本文介绍如何在不使用GPU的情况下配置并运行Fast R-CNN。主要步骤包括从GitHub克隆项目,调整代码以禁用GPU支持,安装依赖项,并下载所需数据集。
only cpu run fast R-CNN
linux14.04 下安装好了python+opencv+caffe


1.从github上clone项目文件,注意:一定要在clone时加入--recursive参数,避免不必要的麻烦,也不要直接下载:


$git clone --recursive https://github.com/rbgirshick/py-faster-rcnn.git


2.进入py-fast-rcnn文件夹,选择lib文件,使用gedit编辑器打开setup.py文件,对里边的代码进行修改:
$cd py-fast-rcnn
$cd lib
$sudo gedit setup.py
 
  2.1对setup.py进行修改:


 ...
 ...
       #CUDA=locate_cuda() (注释掉该行)
 ...
 ...
        #self.set_executable('compiler_so',CUDA['nvcc'])
 ...
 ...
 ...
 ...
#   Extension('nms.gpu_nms',
#      ['nms/nms_kernel.cu', 'nms/gpu_nms.pyx'],
#       library_dirs=[CUDA['lib64']],
#       libraries=['cudart'],
#      language='c++',
#      runtime_library_dirs=[CUDA['lib64']],
# this syntax is specific to this build system
# we're only going to use certain compiler args with nvcc and not with
# gcc the implementation of this trick is in customize_compiler() below
#      extra_compile_args={'gcc': ["-Wno-unused-function"],
#                           'nvcc': ['-arch=sm_35',
#                                    '--ptxas-options=-v',
#                                    '-c',
#                                   '--compiler-options',
#                                    "'-fPIC'"]},
#      include_dirs = [numpy_include, CUDA['include']]
#   ),


   
    2.2进入fast-rcnn修改nms_wrapper.py
        ...
        #from nms.gpu_nms import gpu_nms
        ...
        def nms(dets, thresh, force_cpu=True):
        ...


    进入tools修改test_net.py和train_net.py
       test_net.py中 caffe.set_mode_gpu() 修改为caffe.set_mode_cpu()
       train_net.py中caffe.set_mode_gpu() 修改为caffe.set_mode_cpu()
    进入py-faster-rcnn/lib然后进行make
     
$make


3.在py-faster-rcnn/caffe-faster-rcnn中
  $cp Makefile.config.example Makefile.config
  $sudo gedit Makefile.config
  对打开的文件进行修改
  CPU_ONLY :=1 取消注释
  WITH_PYTHON_LAYER :=1 取消注释
  
  在该目录下执行:make-j8 && make pycaffe
  $make -j8
  $make pycaffe


4. 下载数据
  $cd py-faster-rcnn/data/scripts
  $./fetch_faster_rcnn_models.sh


  最后执行:$python ./demo.py --cpu
  
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值