1、下载Faster-rcnn源码

caffe:

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

tensorflow:

git clone --recursive https://github.com/smallcorgi/Faster-RCNN_TF.git

2、编译

进入目录cd py-faster-rcnn/lib

make

出现错误:

python setup.py build_ext --inplace
Traceback (most recent call last):
  File "setup.py", line 58, in <module>
    CUDA = locate_cuda()
  File "setup.py", line 46, in locate_cuda
    raise EnvironmentError('The nvcc binary could not be '
EnvironmentError: The nvcc binary could not be located in your $PATH. Either add it to your path, or set $CUDAHOME
make: *** [all] Error 1

解决办法是打开setup.py文件将以下注释,即可:

#CUDA = locate_cuda()

 #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']]
    #),
    #Extension(
    #    'pycocotools._mask',
    #    sources=['pycocotools/maskApi.c', 'pycocotools/_mask.pyx'],
    #    include_dirs = [numpy_include, 'pycocotools'],
    #    extra_compile_args={
    #        'gcc': ['-Wno-cpp', '-Wno-unused-function', '-std=c99']},
    #),

再次make

3、下载预训练模型:

运行py-faster-rcnn/data/scripts下的fetch_faster_rcnn_models.sh脚本文件下载

但这里我没有下载成功,估计需要翻墙,在网上看见下载种子,亲测可用

针对caffe结构的:

http://academictorrents.com/details/cca56021739c8a75af3b58f536d4930266c25d5e/tech

针对tensorflow架构:

https://github.com/leihe001/tensorflow-vgg

https://github.com/leihe001/tensorflow-resnet

4、最后运行demo

./tools/demo.py

好像需要安装cuda才能运行,cpu下运行不通过,原因未知!

5、本人初学faster-rcnn,望各位指教,有意者可交流学习!

Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐