物体识别"/>
windows下编译Fast RCNN实现物体识别
参考:/happynear/article/details/46822109
faster rcnn 已经推出,建议大家使用速度更快的faster rcnn:
https://github/ShaoqingRen/faster_rcnn
一、准备
1. caffe-windows:https://github/happynear/caffe-windows。如果你的caffe-windows版本是2015/07/09之前下载的,请重新下载并重新编译。重新编译时请首先编译python接口,因为马上就要用到。主程序和matlab接口可以有空的时候再编译。
2. fast r-cnn:https://github/rbgirshick/fast-rcnn。
3. 下载fast r-cnn所需的模型文件。原始文件都在伯克利大学的服务器上,为了不给伯克利服务器增加负担,我把文件都上传到百度云上了[doge]:/s/1kTzQYgR。下载完成后,请将3个文件夹放置在fast_rcnn_root/data
中。
4. 按照这篇博客的说明安装protobuf的python接口。
5. 打开cmd,输入pip install cython
和 pip install easydict
来安装cython和easydict,如果你使用的是Anaconda-64,cython默认是安装上了的。
如果提示安装失败,可能是由于你的pip的版本过低,请先使用
pip install pip --upgrade
升级你的pip。
二、编译
1. 将caffe_windows_root/python
目录,复制到fast_rcnn_root/caffe-fast-rcnn
中。
2. 用文本编辑器打开fast_rcnn_root/lib/utils/nms.pyx
,将第25行的np.int_t
修改为(np.int64_t)np.intp_t
。
3. 用文本编辑器打开fast_rcnn_root/lib/setup.py
,将第18行和23行的
"-Wno-cpp", "-Wno-unused-function"
指令删除,只留下空的中括号[]
即可。
4. 打开cmd,定位至fast_rcnn_root/lib
目录中,执行python setup.py install
。
如果提示Unable to find vcvarsall.bat
的话,请输入以下指令:
VS2012:SET VS90COMNTOOLS=%VS110COMNTOOLS%
VS2013:SET VS90COMNTOOLS=%VS120COMNTOOLS%
setup.py安装完成后,到python_root/Lib/site-packages/utils
中可以找到两个文件cython_bbox.pyd
和cython_nms.pyd
,把这两个文件复制到fast_rcnn_root/lib/utils
中。
在这里,我没有成功,遂安装Microsoft Visual C++ Compiler for Python 2.7(/en-us/download/details.aspx?id=44266),设置环境变量:SET VS90COMNTOOLS="C:\Users\houwenbin\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\",并修改F:\Anaconda2\Lib\distutils\msvc9compiler.py的
def find_vcvarsall(version):
"""Find the vcvarsall.bat file
At first it tries to find the productdir of VS 2008 in the registry. If
that fails it falls back to the VS90COMNTOOLS env var.
"""
vsbase = VS_BASE % version
try:
productdir = Reg.get_value(r"%s\Setup\VC" % vsbase,
"productdir")
except KeyError:
productdir = None
# trying Express edition
if productdir is None:
vsbase = VSEXPRESS_BASE % version
try:
productdir = Reg.get_value(r"%s\Setup\VC" % vsbase,
"productdir")
except KeyError:
productdir = None
log.debug("Unable to find productdir in registry")
if not productdir or not os.path.isdir(productdir):
toolskey = "VS%0.f0COMNTOOLS" % version
toolsdir = os.environ.get(toolskey, None)
#log.info("%s----%s", toolskey, toolsdir)
if toolsdir and os.path.isdir(toolsdir):
#productdir = os.path.join(toolsdir, os.pardir, os.pardir, "VC")
#productdir = os.path.abspath(productdir)
productdir = os.path.abspath(toolsdir) #modify by houwenbin
log.info("%s----", productdir)
if not os.path.isdir(productdir):
log.debug("%s is not a valid directory" % productdir)
return None
else:
log.debug("Env var %s is not set or invalid" % toolskey)
if not productdir:
log.debug("No productdir found")
return None
vcvarsall = os.path.join(productdir, "vcvarsall.bat")
if os.path.isfile(vcvarsall):
return vcvarsall
log.debug("Unable to find vcvarsall.bat")
return None
5. 定位至fast_rcnn_root
,执行python tools/demo.py --cpu(我没有N卡)
,等待demo的结果吧!
可以看到,分类效果还是不错的!
更多推荐
windows下编译Fast RCNN实现物体识别
发布评论