配置完Caffe后配置CPU版本的faster-rcnn环境

下载项目,里面包含的caffe–rcnn与第一部分的caffe并不相同。

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

安装cython和easydict:

Cython作为一个Python的编译器,在科学计算方面很流行,是用一个简单的方法来整合C的速度和C数据类型到 Python 函数中去从而提高Python的速度,通过OpenMPI库还可以进行并行计算。

EasyDict允许将dict值作为属性访问(递归运行)。

sudo pip install cython  
sudo pip install easydict   

编译cython:到/py-faster-rcnn/lib/目录下修改setup.py文件,然后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']]  
    #),  

编译caffe:到/py-faster-rcnn/caffe-fast-rcnn/目录下,修改Makefile.config文件(和第一部分中的修改一样)和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  

测试demo:
首先下载训练好的数据集:

cd ~/py-faster-rcnn  
./data/scripts/fetch_faster_rcnn_models.sh  

然后修改一些文件:
A:修改/py-faster-rcnn/lib/fast_rcnn/config.py文件(True改成False)
# Use GPU implementation of non-maximum suppression
__C.USE_GPU_NMS = False
B:将/py-faster-rcnn/tools/test_net.py和 /py-faster-rcnn/tools/train_net.py的caffe.set_mode_gpu()修改为caffe.set_mode_cpu().

C:修改/py-faster-rcnn/lib/fast_rcnn/nms_wrapper.py文件(注释该引用,并将False改成True)
#from nms.gpu_nms import gpu_nms
def nms(dets, thresh, force_cpu=True):
最后,运行demo:

cd ~/py-faster-rcnn  
./tools/demo.py --cpu  
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值