1. 程式人生 > >tf-faster-rcnn問題與研究總結

tf-faster-rcnn問題與研究總結

github地址:https://github.com/endernewton/tf-faster-rcnn

自己拿來研究時,總結的一些問題:
安裝過程報錯:
(1).
[[email protected] PythonAPI]# make
python setup.py build_ext --inplace
running build_ext
building ‘pycocotools._mask’ extension
error: unknown file type ‘.pyx’ (from ‘pycocotools/_mask.pyx’)
make: *** [all] Error 1
[

[email protected] PythonAPI]#

解決:下載Pyrex-0.9.9.tar.gz ,並安裝。

(2).
[[email protected] PythonAPI]# make
python setup.py build_ext --inplace
running build_ext
pyrexc pycocotools/_mask.pyx --> pycocotools/_mask.c
/data/gpu_tf_py2_201812/tf-faster-rcnn/data/coco/PythonAPI/pycocotools/_mask.pyx:42:34: Expected ‘)’
building ‘pycocotools._mask’ extension
gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -I/usr/lib64/python2.7/site-packages/numpy/core/include -I…/common -I/usr/include/python2.7 -c …/common/maskApi.c -o build/temp.linux-x86_64-2.7/…/common/maskApi.o -Wno-cpp -Wno-unused-function -std=c99
…/common/maskApi.c: In function ‘rleToBbox’:
…/common/maskApi.c:141:31: warning: ‘xp’ may be used uninitialized in this function [-Wmaybe-uninitialized]
if(j%2==0) xp=x; else if(xp<x) { ys=0; ye=h-1; }
^
gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -I/usr/lib64/python2.7/site-packages/numpy/core/include -I…/common -I/usr/include/python2.7 -c pycocotools/_mask.c -o build/temp.linux-x86_64-2.7/pycocotools/_mask.o -Wno-cpp -Wno-unused-function -std=c99
gcc: error: pycocotools/_mask.c: No such file or directory
gcc: fatal error: no input files
compilation terminated.
error: command ‘gcc’ failed with exit status 4
make: *** [all] Error 1

解決方法:
手動用cython生成_mask.c
cd $FRCN_ROOT/lib/pycocotools
cython _mask.pyx

(3).
[[email protected] scripts]# ./fetch_faster_rcnn_models.sh
Downloading Resnet 101 Faster R-CNN models Pret-trained on VOC 07+12 (340M)…
./fetch_faster_rcnn_models.sh: line 30: wget: command not found
Unzipping…
tar (child): voc_0712_80k-110k.tgz: Cannot open: No such file or directory
tar (child): Error is not recoverable: exiting now
tar: Child returned status 2
tar: Error is not recoverable: exiting now
Done. Please run this command again to verify that checksum = cb32e9df553153d311cc5095b2f8c340.

解決方法:
[[email protected] scripts]# yum -y install wget

(4).
[[email protected] scripts]# ./fetch_faster_rcnn_models.sh
Downloading Resnet 101 Faster R-CNN models Pret-trained on VOC 07+12 (340M)…
–2018-12-28 05:47:51-- http://ladoga.graphics.cs.cmu.edu/xinleic/tf-faster-rcnn/res101/voc_0712_80k-110k.tgz
Resolving ladoga.graphics.cs.cmu.edu (ladoga.graphics.cs.cmu.edu)… 128.2.220.68
Connecting to ladoga.graphics.cs.cmu.edu (ladoga.graphics.cs.cmu.edu)|128.2.220.68|:80… failed: Connection timed out.
Retrying.

解決方法:
網盤中下載:https://pan.baidu.com/s/1kWkF3fT
下載後copy到相應資料夾進行解壓:
tar xvf voc_0712_80k-110k.tgz

(5).Create a folder and a soft link to use the pre-trained model
此步驟中,下面命令需要注意相對路徑是否正確,如果不正確,連結會紅色告警。
ln -s …/…/…/data/voc_2007_trainval+voc_2012_trainval ./default

(6).Demo for testing on custom images
此步驟中,需要注意demo.py的相對路徑是否正確,py檔案中直接定義了output開頭的相對路徑,這個命令需要認證核查下。
CUDA_VISIBLE_DEVICES=${GPU_ID} ./tools/demo.py

檢測時原理:
對於一幅影象,生成一定數量的anthor,分別生成這個anthor對應的21個類別的分數和邊框。對於每個類別的所有邊框,進行NMS,獲取NMS結果(NMS閾值用的0.3)。然後進行分數閾值過濾,得到最終結果,閾值這裡用的0.8。

效能記錄:
在這裡插入圖片描述