windows下编译Fast RCNN实现物体识别

参考:http://blog.csdn.net/happynear/article/details/46822109

faster rcnn 已经推出,建议大家使用速度更快的faster rcnn: 
https://github.com/ShaoqingRen/faster_rcnn

一、准备

1. caffe-windows:https://github.com/happynear/caffe-windows。如果你的caffe-windows版本是2015/07/09之前下载的,请重新下载并重新编译。重新编译时请首先编译python接口,因为马上就要用到。主程序和matlab接口可以有空的时候再编译。

2. fast r-cnn:https://github.com/rbgirshick/fast-rcnn

3. 下载fast r-cnn所需的模型文件。原始文件都在伯克利大学的服务器上,为了不给伯克利服务器增加负担,我把文件都上传到百度云上了[doge]:http://pan.baidu.com/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_tnp.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.pydcython_nms.pyd,把这两个文件复制到fast_rcnn_root/lib/utils中。

在这里,我没有成功,遂安装Microsoft Visual C++ Compiler for Python 2.7(http://www.microsoft.com/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的结果吧!


可以看到,分类效果还是不错的!

  • 0
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值