1.编译py-faster-rcnn库
修改py-faster-rcnn\lib\setup_cuda.py:
a. 将第14行改为'-arch=sm_35'。
b. 将第33行
include_dirs = [numpy_include, 'C:\\Programming\\CUDA\\v7.5\\include'])
改为本机的CUDA-include,如
include_dirs = [numpy_include, 'D:\\CUDA\\v8.0\\include'])
调用cmd,打开至py-faster-rcnn\lib路径下,运行命令:
python setup.py install
python setup.py build_ext --inplace
python setup_cuda.py install
可能出现以下几个问题:
(1)cl.exe failed with exit status2
方法:原因是python和VC版本冲突。找到Python\Lib\distutils\msvc9compiler.py,将第304行VERSION = get_build_version()修改为VERSION = 12(此数字为你的VC版本,VS2013为12)。
(2)Microsoft Visual C++ 9.0 is required.
方法:输入SET VS90COMNTOOLS=%VS120COMNTOOLS%(VS2013为120),输入前应该先添加VS120COMNTOOLS环境变量,如下图。
若无效,则可用(1)方法解决。
(3)No Models Import XXX
方法:缺少XXX库,调用cmd,输入pip install xxx,如pip install cython。
当提示如下时,则编译正确。
Finished processing dependencies for py-fast-rcnn-gpu==0.0.0
2.运行demo
下载已经训练好的model放在.\py-faster-rcnn-master\data\faster_rcnn_models下,下载地址用git运行.\py-faster-rcnn\data\scripts\fetch_faster_rcnn_models.sh,建议直接百度。
调用cmd,到达.\py-faster-rcnn\tools,输入
python demo.py