编译 Faster Rcnn

编译 Faster Rcnn

Rcnn 是比较经典的做目标检测的算法,今天准备学习一下,啥都不用说,先把程序调通。

  • 一、编译caffe
    编译caffe是最麻烦的事情。。
首先下载rcnn 的代码
git clone --recursive https://github.com/rbgirshick/py-faster-rcnn.git 
然后开始编译
cd /home/mmt/Desktop/py-faster-rcnn/lib
make 
编译caffe
cd /home/mmt/Desktop/py-faster-rcnn/caffe-fast-rcnn
cp Makefile.config.example Makefile.config 

然后修改里面的内容
WITH_PYTHON_LAYER := 1  
USE_CUDNN := 1
将这两句前面的 # 号去掉
然后
make -j8 && make pycaffe 
出现错误1
src/caffe/net.cpp:8:18: fatal error: hdf5.h: No such file or directory
解决方法:
将Makefile.config中的
INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include
LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib
修改为:
INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include /usr/include/hdf5/serial
LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib /usr/lib/x86_64-linux-gnumake

将 Makefile中
LIBRARIES += glog gflags protobuf boost_system boost_filesystem m hdf5_hl hdf5
修改为:
LIBRARIES += glog gflags protobuf boost_system boost_filesystem m hdf5_serial_hl hdf5_serial
重新编译:
make -j8 && make pycaffe 

出现错误2 error: too few arguments to functioncudnnStatus_t cudnnSetPooling2dDescriptor(cudnnPoolingDescriptor_t, cudnnPoolingMod
解决方法:
将BVLC(https://github.com/BVLC/caffe)中的下列文件copy 到相应的文件夹,即将这三个文件夹里的cudnn开头的文件全部换成新的:
./include/caffe/util/cudnn.hpp
./include/caffe/layers/cudnn_conv_layer.hpp
./include/caffe/layers/cudnn_relu_layer.hpp
./include/caffe/layers/cudnn_sigmoid_layer.hpp
./include/caffe/layers/cudnn_tanh_layer.hpp
./src/caffe/layers/cudnn_conv_layer.cpp
./src/caffe/layers/cudnn_conv_layer.cu
./src/caffe/layers/cudnn_relu_layer.cpp
./src/caffe/layers/cudnn_relu_layer.cu
./src/caffe/layers/cudnn_sigmoid_layer.cpp
./src/caffe/layers/cudnn_sigmoid_layer.cu
./src/caffe/layers/cudnn_tanh_layer.cpp
./src/caffe/layers/cudnn_tanh_layer.cu

make clean
make -j8
出现build_release/lib/libcaffe.so:对‘cv::imdecode(cv::_InputArray const&, int)’未定义的引用
对于各种cv出错:
解决方法:
修改Makefile:
LIBRARIES += glog gflags protobuf boost_system boost_filesystem m hdf5_serial_hl hdf5_serial matio opencv_core opencv_highgui opencv_imgproc opencv_imgcodecs
下次编译之前要 make clean

make clean 
make -j8
编译成功
make pycaffe
python/caffe/_caffe.cpp:11:31: fatal error: numpy/arrayobject.h: No such file or directory
解决方法:
然后对照 Makefile.config
将第二行加一个local
PYTHON_INCLUDE := /usr/include/python2.7 \
/usr/local/lib/python2.7/dist-packages/numpy/core/include

重新编译成功
  • 二、下载models
    ./data/scripts/fetch_faster_rcnn_models.sh

这里写图片描述
然后 跑一个demo
./tools/demo.py

这里写图片描述这里写图片描述
这里写图片描述
编译到此就成功了。

  • 三、训练 Fast RCNN 出错
    1、在网络初始化到loss_bbox层时会出现smoothL1loss.cpperror :bottom.size=4(3vs.4) If weightsare used, must specify both inside and outside weights之类错误!
解决方法:参考 http://blog.csdn.net/qq_34220460/article/details/72778714
找到SmoothL1loss.cpp,找到出错误的那部分
看到has_weights=(bottom.size()>=3);把它改成has_weights=(bottom.size()==3);然后下面的if语句用//注释掉。接着还要改,看到下面的这几行代码:

    CHECK_EQ(bottom[0]->channels(),bottom[3]->channels());

   CHECK_EQ(bottom[0]->height(), bottom[3]->height());

   CHECK_EQ(bottom[0]->width(), bottom[3]->width());
这三行,也要用//注释掉。Ok!!!!!
再重新编译!!!!make clean     make  -j8

2、AttributeError: ‘module’ object has no attribute ‘text_format’
解决方法:参考网址 http://blog.csdn.net/qq_33202928/article/details/72526710

解决办法1:sudo pip install protobuf==2.5.0
解决办法2:
在文件./lib/fast_rcnn/train.py增加一行import google.protobuf.text_format 即可解决问题

3、TypeError: ‘numpy.float64’ object cannot be interpreted as an index
参考网址:http://m.blog.csdn.net/hongbin_xu/article/details/77278329

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值