py-faster-rcnn配置记录

官方代码:https://github.com/rbgirshick/py-faster-rcnn

1.下载代码到本机

git clone --recursive https://github.com/rbgirshick/py-faster-rcnn.git
--recursive 递归更新子文件夹

2.编辑Cython模型($FRCN_ROOT是下载后程序名称)

cd $FRCN_ROOT/lib
make

3.编辑caffe和pycaffe

cd $FRCN_ROOT/caffe-fast-rcnn
# Now follow the Caffe installation instructions here:
# http://caffe.berkeleyvision.org/installation.html
# If you're experienced with Caffe and have all of the requirements installed
# and your Makefile.config in place, then simply do:
make -j8 && make pycaffe

4.下载Faster RCNN预训练模型

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

注意:此模型通过VOC2007进行训练,且需要翻墙下载

5.测试模型

cd $FRCN_ROOT

./tools/demo.py

可能会遇到以下问题:

问题1:py-faster RCNN源代码只支持cudnn v4在cudnn v5下编译需要更改部分cudnn文件:

方案1:git版本合并

cd caffe-fast-rcnn
#将BLVC/caffe添加为远程仓库,命名为caffe
git remote add caffe https://github.com/BVLC/caffe.git
#获取BLVC/caffe代码
git fetch caffe
#将BLVC/caffe的master分支合并到当前分支
# -X theirs指定在合并遇到冲突时以BLVC/caffe版本为主
git merge -X theirs caffe/master

可能会遇到输入邮箱和姓名的内容,直接将提示信息复制后执行即可。


图片 1.png

执行git merge -X theirs caffe/master
会要求输入信息,不必输入任何内容,直接按Ctrl-X离开。

问题2:

Traceback (most recent call last):
File "./tools/demo.py", line 135, in <module>
net = caffe.Net(prototxt, caffemodel, caffe.TEST)
AttributeError: can't set attribute

方案2:需要注释掉源码中的一行,并重新编译。include/caffe/layers/python_layer.hpp 中,注释掉:

self_.attr("phase") = static_cast(this->phase_);

问题3:需要有界面才能执行的问题

方案3:将demo.py做以下修改:
刚开始加入两行

import _init_paths
import matplotlib
matplotlib.use('Agg')
from fast_rcnn.config import cfg
.................

在显示函数vis_detections加入一行保存文件,方便下载下载看

def vis_detections(im, class_name, dets, thresh=0.5):
    .................
    plt.savefig("/home/yourname/picFaster.jpg")
图片 2.png
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容