ubuntu16.04配置py-faster-rcnn(CPU版)

Caffe配置:

采用http://blog.csdn.net/u013989576/article/details/56677749配置好caffe

py-faster-rcnn配置:

1、下载py-faster-rcnn源码

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


2、安装cython、easydict

sudo pip install cython  
sudo pip install easydict 


3、编译cython:修改py-faster-rcnn/lib下的setup.py文件,注释掉GPU的相关代码,然后make,修改如下:

#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']]  
    #),  

make


4、编译caffe:修改py-faster-rcnn/caffe-fast-rcnn下的Makefile.config文件和CMakeLists.txt文件,对于Makefile.config文件的修改,和 caffe配置中的修改一样,对于CMakeLists.txt文件,将OFF改成ON,即:
caffe_option(CPU_ONLY  "Build Caffe without CUDA support" ON) # TODO: rename to USE_CUDA  

cd ~/py-faster-rcnn/caffe-fast-rcnn  
make -j8&& make pycaffe 


5、测试demo

5.1 下载训练好的模型

cd ~/py-faster-rcnn  
./data/scripts/fetch_faster_rcnn_models.sh  
有的时候下载不下来,我们可以点击 链接下载,再放到py-faster-rcnn/data下。

5.2 进行如下修改:

A 修改py-faster-rcnn/lib/fast-rcnn下的config.py文件,即:__C.USE_GPU_NMS = False

B 修改py-faster-rcnn/tools下的test_net.py、train_net.py文件,将caffe.set_mode_gpu() 改为caffe.set_mode_cpu()

C 修改py-faster-rcnn/lib/fast-rcnn下的nms_wrapper.py文件,即:

 #from nms.gpu_nms import gpu_nms

def nms(dets, thresh, force_cpu= True)

5.3 运行demo

cd ~/py-faster-rcnn  
./tools/demo.py --cpu

但是CPU速度比较慢,而且容易内存溢出,所以我们可以使用ZF模型(默认为VGG16):

cd ~/py-faster-rcnn  
./tools/demo.py --cpu --net zf

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值