下载Faster-RCNN
1 | cd ~ |
安装Python依赖包
1 | sudo apt-get install python-pip |
生成Cython模块
1 | cd ~/py-faster-rcnn/lib/ |
安装Atlas
1 | sudo apt-get install libatlas-base-dev |
生成Caffe和pycaffe
1 | cd ~/py-faster-rcnn/caffe-fast-rcnn |
编辑Makefile.config,根据自己的需要修改相应模式,其中重点关注CPU_ONLY 和WITH_PYTHON_LAYER以及CUDNN等处,若是在CPU的情况下,请务必修改为CPU_ONLY := 1
编译环境
1 | cd ~/py-faster-rcnn/caffe-fast-rcnn |
下载fetch_fast_rcnn_models
下载网址:(链接:http://pan.baidu.com/s/1pJVburD 密码:11m0)
将下载好的faster_rcnn_models.tgz放到/py-faster-rcnn/data这个目录下,右键提取到此处,即是解压。
CPU环境下所需要的操作
1
vim ~/py-faster-rcnn/lib/fast_rcnn/config.py
将 __C.USE_GPU_NMS = False
1
vim ~/py-faster-rcnn/tools/test_net.py
注释掉:caffe.set_mode_gpu() ,其下方添加: caffe.set_mode_cpu()
1
vim ~/py-faster-rcnn/tools/train_net.py
注释掉:caffe.set_mode_gpu() ,其下方添加: caffe.set_mode_cpu()
1
vim ~/py-faster-rcnn/lib/setup.py
注释掉GPU相关代码,如下
1
#CUDA = locate_cuda()
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17# 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']]
# ),1
vim ~/py-faster-rcnn/lib/fast_rcnn/nms_wrapper.py
注释掉 #from nms.gpu_nms import gpu_nms
运行Demo
1 | cd ~/py-faster-rcnn/tools |
若提示缺少某个模块(module),网上搜索下,安装给出的教程安装相应模块,建议尽量终端中命令安装.
效果图如下(仅贴了一张图):