1.安裝
-
Clone the face Faster R-CNN repository
Git clone –recursive https://github.com/playerkk/face-py-faster-rcnn.git
-
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/
- Download the (http://jianghz.me/files/wider_face_train_annot.txt) and put it under the WIDER directory.
-
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這個字元串;
參考部落格:http://blog.csdn.net/zengdong_1991/article/details/66475821