mac上跑仅cpu模式的fast-rcnn

rbg大神github传送门

在mac上跑fast-rcnn的过程大致和rbg大神在github上写的过程差不多,就是有些配置文件需要注意一下

前提是你已经安装好caffe并配好python环境,不懂的可以参考上一篇博客

以下是配置过程和问题解决方案

1、克隆rbg大神的代码,一定要加--recursive哦

git clone --recursive https://github.com/rbgirshick/fast-rcnn.git
2、进入lib目录下编译
cd $FRCN_ROOT/lib
make

3、进入caffe-fast-cnn目录运行

cd $FRCN_ROOT/caffe-fast-rcnn
make -j8 && make pycaffe

4、下载模型

cd $FRCN_ROOT
./data/scripts/fetch_fast_rcnn_models.sh

如果本地下不下来的,可以从我的百度云下载 链接:https://pan.baidu.com/s/1kwtr-4McgoF89eVCbtFPNg  密码:9gme

5、运行demo

cd $FRCN_ROOT/tools
./demo.py --cpu --net caffenet

6、运行结果


遇到的问题:

1、在lib下make时遇到

fatal error: 'numpy/arrayobject.h' file not found #include "numpy/arrayobject.h"

我的numpy安装过了,且makefile.config中PYTHON_INCLUDE地址配置无误的情况下

进入python,执行

import numpy

numpy.get_include()

会显示如下地址

/usr/local/lib/python2.7/site-packages/numpy/core/include/numpy

再执行  cp -r /usr/local/lib/python2.7/site-packages/numpy/core/include/numpy /usr/local/include  即可(虽然不知道为什么,反正我的程序好了。。。)

2、在caffe-fast-rcnn里面运行时出现各种问题,比如

ld: cannot link directly with /System/Library/Frameworks//vecLib.framework/vecLib for architecture x86_64
clang:
error: linker command failed with exit code 1 (use -v to see invocation)

make: *** [.build_release/lib/libcaffe.so] Error 1

ld: symbol(s) not found for architecture x86_64等

这些都是makefile.config的问题,,可以参考安装caffe时的配置

我是改了blas(安装openblas)

# open for OpenBlas
BLAS := open
BLAS_INCLUDE := /usr/local/Cellar/openblas/0.2.20_1/include
BLAS_LIB := /usr/local/Cellar/openblas/0.2.20_1/lib

放开以下几行代码

WITH_PYTHON_LAYER = 1 fast-rcnn需要支持Python接口,因此需要打开
USE_PKG_CONFIG = 1 记得打开,要不然会找不到一些库文件,PKG是linux用来管理库文件
CPU_ONLY := 1  用cpu运行

以下是我的makefile.config

CPU_ONLY := 1
CUDA_DIR := /usr/local/cuda
CUDA_ARCH := -gencode arch=compute_20,code=sm_20 \
        -gencode arch=compute_20,code=sm_21 \
        -gencode arch=compute_30,code=sm_30 \
        -gencode arch=compute_35,code=sm_35 \
        -gencode arch=compute_50,code=sm_50 \
        -gencode arch=compute_50,code=compute_50
BLAS := open
BLAS_INCLUDE := /usr/local/Cellar/openblas/0.2.20_1/include
BLAS_LIB := /usr/local/Cellar/openblas/0.2.20_1/lib
PYTHON_INCLUDE := /usr/local/Frameworks/Python.framework/Versions/2.7/include/python2.7/ \
/usr/local/lib/python2.7/site-packages/numpy/core/include
PYTHON_LIB := /usr/local/Frameworks/Python.framework/Versions/2.7/lib/
WITH_PYTHON_LAYER := 1
INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include
LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib
USE_PKG_CONFIG := 1
BUILD_DIR := build
DISTRIBUTE_DIR := distribute
TEST_GPUID := 0
Q ?= @


阅读更多
文章标签: caffe fast-rcnn
个人分类: 目标检测
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

关闭
关闭
关闭