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預(yù)訓(xùn)練模型

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

注意:此模型通過VOC2007進(jìn)行訓(xùn)練,且需要翻墻下載

5.測試模型

cd $FRCN_ROOT

./tools/demo.py

可能會遇到以下問題:

問題1:py-faster RCNN源代碼只支持cudnn v4在cudnn v5下編譯需要更改部分cudnn文件:

方案1:git版本合并

cd caffe-fast-rcnn
#將BLVC/caffe添加為遠(yuǎn)程倉庫,命名為caffe
git remote add caffe https://github.com/BVLC/caffe.git
#獲取BLVC/caffe代碼
git fetch caffe
#將BLVC/caffe的master分支合并到當(dāng)前分支
# -X theirs指定在合并遇到?jīng)_突時以BLVC/caffe版本為主
git merge -X theirs caffe/master

可能會遇到輸入郵箱和姓名的內(nèi)容,直接將提示信息復(fù)制后執(zhí)行即可。


圖片 1.png

執(zhí)行g(shù)it merge -X theirs caffe/master
會要求輸入信息,不必輸入任何內(nèi)容,直接按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:需要有界面才能執(zhí)行的問題

方案3:將demo.py做以下修改:
剛開始加入兩行

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

在顯示函數(shù)vis_detections加入一行保存文件,方便下載下載看

def vis_detections(im, class_name, dets, thresh=0.5):
    .................
    plt.savefig("/home/yourname/picFaster.jpg")
圖片 2.png
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容