繼續玩 Fast R-CNN

繼續玩 Fast R-CNN

標籤(空格分隔):vision


Beyond the demo: installation for training and testing models

  1. Download the training, validation, test data and VOCdevkit

    wget http://pascallin.ecs.soton.ac.uk/challenges/VOC/voc2007/VOCtrainval_06-Nov-2007.tar
    wget http://pascallin.ecs.soton.ac.uk/challenges/VOC/voc2007/VOCtest_06-Nov-2007.tar
    wget http://pascallin.ecs.soton.ac.uk/challenges/VOC/voc2007/VOCdevkit_08-Jun-2007.tar

    沒法下載,只能從其他地方下下來,然後傳到Ubuntu機器上。

  2. Extract all of these tars into one directory named VOCdevkit

    tar xvf VOCtrainval_06-Nov-2007.tar
    tar xvf VOCtest_06-Nov-2007.tar
    tar xvf VOCdevkit_08-Jun-2007.tar
  3. It should have this basic structure

    $VOCdevkit/                           # development kit
    $VOCdevkit/VOCcode/                   # VOC utility code 
    $VOCdevkit/VOC2007                    # image sets,anotation
    
    # ... and several other directories ...
    

    VOCdevkit/VOCcode/ 這個目錄我爲什麼沒有?

  4. Create symlinks for the PASCAL VOC dataset

    cd $FRCN_ROOT/data
    ln -s $VOCdevkit VOCdevkit2007

    Using symlinks is a good idea because you will likely want to share the same PASCAL dataset installation between multiple projects. 創建一個Symbolic (還是叫Soft) link是一個好的習慣。

  5. [Optional] follow similar steps to get PASCAL VOC 2010 and 2012 (下載不了)

Download pre-computed Selective Search object proposals

Pre-computed selective search boxes can also be downloaded for VOC2007 and VOC2012.

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

This will populate the $FRCN_ROOT/data folder with selective_selective_data.
在這個目錄中有如下一些Matlab的數據文件,很容易看出這些文件應該包含何種的內容,應該就是在各個圖像上運行Selective Search得到的Roi Proposals。

voc_2007_test.mat   voc_2007_val.mat    voc_2012_trainval.mat
voc_2007_train.mat     voc_2012_test.mat   voc_2012_val.mat
voc_2007_trainval.mat  voc_2012_train.mat

Download pre-trained ImageNet models

Pre-trained ImageNet models can be downloaded for the three networks described in the paper: CaffeNet (model S), VGG_CNN_M_1024 (model M), and VGG16 (model L).
FR-CNN的輸入有兩個:一個是在ImageNet上訓練的多層CNN的輸出,另一個就是上面的Selective Search得到的Roi Proposals。所以這裏把訓練好的多層CNN下載下來(FR-CNN的Fine tune也不會修改這個層次的網絡?)。

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

These models are all available in the Caffe Model Zoo, but are provided here for your convenience.

ls data/imagenet_models
CaffeNet.v2.caffemodel   (最小)
VGG16.v2.caffemodel    (最大)
VGG_CNN_M_1024.v2.caffemodel  (中等)

Usage

Train a Fast R-CNN detector. For example, train a VGG16 network on VOC 2007 trainval:

./tools/train_net.py --gpu 0 --solver models/VGG16/solver.prototxt \
    --weights data/imagenet_models/VGG16.v2.caffemodel

只是在CPU上試試,所以不能用上面的命令。改成:

./tools/train_net.py --cpu --solver models/CaffeNet/solver.prototxt --weights data/imagenet_models/CaffeNet.v2.caffemodel

If you see this error

EnvironmentError: MATLAB command 'matlab' not found. Please add 'matlab' to your PATH.

then you need to make sure the matlab binary is in your $PATH. MATLAB is currently required for PASCAL VOC evaluation.

Test a Fast R-CNN detector. For example, test the VGG 16 network on VOC 2007 test:

./tools/test_net.py --gpu 1 --def models/VGG16/test.prototxt \
    --net output/default/voc_2007_trainval/vgg16_fast_rcnn_iter_40000.caffemodel

Test output is written underneath $FRCN_ROOT/output.

Compress a Fast R-CNN model using truncated SVD on the fully-connected layers:

./tools/compress_net.py --def models/VGG16/test.prototxt \
    --def-svd models/VGG16/compressed/test.prototxt \
    --net output/default/voc_2007_trainval/vgg16_fast_rcnn_iter_40000.caffemodel
# Test the model you just compressed
./tools/test_net.py --gpu 0 --def models/VGG16/compressed/test.prototxt \
    --net output/default/voc_2007_trainval/vgg16_fast_rcnn_iter_40000_svd_fc6_1024_fc7_256.caffemodel

Experiment scripts

Scripts to reproduce the experiments in the paper (up to stochastic variation) are provided in $FRCN_ROOT/experiments/scripts. Log files for experiments are located in experiments/logs.

Note: Until recently (commit a566e39), the RNG seed for Caffe was not fixed during training. Now it’s fixed, unless train_net.py is called with the --rand flag.
Results generated before this commit will have some stochastic variation.

Extra downloads

發佈了39 篇原創文章 · 獲贊 7 · 訪問量 14萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章