Face Faster RCNN安裝步驟和遇到的問題
1.安裝
-
Build the Cython modules
cd $FRCN_ROOT/lib
make -
Build Caffe and pycaffe
cd $FRCN_ROOT/caffe-fast-rcnn
make -j8 && make pycaffe -
下載預先訓練好的VGG模型
A pre-trained face detection model trained on the WIDER training set is available here.
http://supermoe.cs.umass.edu/%7Ehzjiang/data/vgg16_faster_rcnn_iter_80000.caffemodel
放置目錄:
$FRCN_ROOT/output/faster_rcnn_end2end/train/vgg16_faster_rcnn_iter_80000.caffemodel -
下載測試資料
下載FDDB資料庫放入$FRCN_ROOT/data目錄:
包括:
FDDB
FDDB/FDDB-folds
FDDB/originalPics
2.測試模型在FDDB上
python ./tools/run_face_detection_on_fddb.py --gpu=0
遇到的問題:
1:安裝 Cython,python-opencv,easydict;不然會提示安裝出錯的;
可以直接下載easydict,然後tar -zxvf easydict.1.7.0.tar.gz; cd easydict.1.7.0;
python setup.py install
解決即可正常的執行:
2:caffe設定的問題
1配置python layers
#In your Makefile.config, make sure to have this line uncommented
WITH_PYTHON_LAYER := 1
# Unrelatedly, it's also recommended that you use CUDNN
USE_CUDNN := 1 #可以註釋掉的
3:訓練模型VGG和ZF模型
-
Download pre-computed Faster R-CNN detectors
cd $FRCN_ROOT
./data/scripts/fetch_faster_rcnn_models.sh //也可官網上下載相應的faster_rcnn_models.tgz;然後自己解壓; -
Download the WIDER face dataset. Extract all files into one directory named WIDER
http://mmlab.ie.cuhk.edu.hk/projects/WIDERFace/
WIDER/
WIDER/WIDER_train/
WIDER/WIDER_val/ -
Create symlinks for the WIDER dataset
cd $FRCN_ROOT ln -s $WIDER ~/WIDER //WIDER在home目錄下 -
Follow the next sections to download pre-trained ImageNet models
cd $FRCN_ROOT
./data/scripts/fetch_imagenet_models.sh //也可官網上下載相應的imagenet_models.tgz;然後自己解壓; -
To train a Faster R-CNN face detector using the approximate joint training method, use experiments/scripts/faster_rcnn_end2end.sh. Output is written underneath $FRCN_ROOT/output.
cd FRCN_ROOT
./experiments/scripts/faster_rcnn_end2end.sh [GPU_ID] [NET] wider [–set …]eg:
./experiments/scripts/faster_rcnn_end2end.sh 0 VGG16 wider
第一個問題:TypeError: slice indices must be integers or None or have an index method
這是由於numpy的版本太高,numpy 1.12.0對這個做了些調整,把numpy降級到1.11.0就行了。
sudo pip install -U numpy==1.11.0
同時也可以下載numpy.1.11.0,自己安裝一下;就可以跟新到1.11.0版本;
但是我的伺服器中有兩個python,2.7和3.4,而系統預設pip是裝在python3.4上的,這樣可以看見:
輸入:pip --version
顯示:pip 9.0.1 from /usr/local/lib/python3.4/dist-packages (python 3.4)
所以執行以下程式碼,裝到強制裝到python2.7中:
sudo python2.7 /usr/local/bin/pip install -U numpy==1.11.0
至此py-faster-rcnn在我這兒可以順利訓練了:
第二個問題:提示找不到圖片的問題
主要是資料集的圖片路徑最後會多一個\r,這都是英文下載的圖片標籤windows下和Linux下多一個換行符的問題;
提取錢len-1個字元就可以了,可以在face.py中修改image_name這個字串;