cd /home/Username
$ git clone --recursive https://ShaoqingRen/faster_rcnn.git
$ cd external/caffe
If there is no files of caffe, just download Caffe as before (Linux Install Caffe in TNT).
$ cp Makefile.config.example Makefile.config
$ vim Makefile.config
modify: MATLAB_DIR :=
as
MATLAB_DIR := /usr/local/MATLAB/R2014a
Tipp: It's better use Matlab_R2014a, I have tryed R2016b, there is many bugs.
find the file upgrade_proto.cpp
:
$ cd /home/Username/faster_rcnn/external/caffe/src/caffe/util
modify upgrade_proto.cpp
:
$ vim upgrade_proto.cpp
after case V1LayerParameter_LayerType_THRESHLOD: return "Threshold";
add:
case V1LayerParameter_LayerType_RESHAPE:
return "Reshape";
case V1LayerParameter_LayerType_ROIPOOLING:
return "ROIPooling";
case V1LayerParameter_LayerType_SMOOTH_L1_LOSS:
return "SmoothL1Loss";
then Esc
add :
wq
return
$ cd caffe
$ make clean
$ make all -j16
$ make test -j16
$ make runtest -j16
$ make matcaffe
Install matlab API, become MEX File
$ make pycaffe
Install python API
in MATLAB run:
$ run fetch_data/fetch_faster_rcnn_final_model.m
$ run faster_rcnn_build.m
and
$ run startup.m
$ run experiments/script_faster_rcnn_demo.m
Run fetch_data/fetch_model_ZF.m
to download an ImageNet-pre-trained ZF net.Run fetch_data/fetch_model_VGG16.m
to download an ImageNet-pre-trained VGG-16 net.- Download VOC 2007 and 2012 data to ./datasets
Run experiments/script_faster_rcnn_VOC2007_ZF.m
to train a model with ZF net. It runs four steps as follows:
- Train RPN with conv layers tuned; compute RPN results on the train/test sets.
- Train Fast R-CNN with conv layers tuned using step-1 RPN proposals; evaluate detection mAP.
- Train RPN with conv layers fixed; compute RPN results on the train/test sets.
- Train Fast R-CNN with conv layers fixed using step-3 RPN proposals; evaluate detection mAP.
- Note: the entire training time is ~12 hours on K40.
Run experiments/script_faster_rcnn_VOC2007_VGG16.m
to train a model with VGG net.
- Note: the entire training time is ~2 days on K40.
- Check other scripts in
./experiments
for more settings.
Tipps:
-
The first time I run the
script_faster_rcnn_VOC2007_ZF.m
, ther is a error abouttext_read
, I think there is something wrong withdatasets
. You can fing in about 28th and 29th rows ofscript_faster_rcnn_VOC2007_ZF.m
, it usevoc2007_trainval
. Open this file and modify about 11th and14th rows,trainval
totrain
(or the other name, the train model in your model's name/faster_rcnn/datasets/VOCdevkit2007/VOC2007/ImageSets/Main/*.txt/
). And then try again, it works. -
when you run train Model in rcnn (Linux OX), there is a Error:
Check failure: fd != -1 (-1 vs. -1) File not find: .\models\rpn_prototxts\ZF\train_val.prototxt
Because.\
is not a valid path in Ubuntu (Server athene of TNT use Ubuntu OX ). Solution: change all the\\
to/
in./faster_rcnn/models/rpn_prorotexts/*.prototxt
Attetion: modify every file under./faster_rcnn/models/faster_rcnn_prototxts
und./faster_rcnn/models/rpn_prororxts
- Build your own Dataset (like VOCdevkit2007)
My Datasets is NYU_deep data, but in faster_rcnn we have to train the dataset, which like VOC2007 format -- Image name (000001.jpg), Boundingbox information -- .xml files. ther is three Conversion script to build Datasets: datasets_tools:
- creat_traintxt.m (link: http://blog.csdn.net/u014696921/article/details/52950218)
- creat_xml.m (by liao)
- png_jpg.m (by wei)
-
Build files in faster_rcnn
- In
VOCdevkit2007/result
build a file with your Datasets' name likeNYU_rcnn
, and under this file build a fileMain
- In
VOCdevkit2007/local
build a file with your Datasets' name likeNYU_rcnn
- In
-
Modify code
here you can know the number of your classes K
- In `functions/fast_rcnn/fast_rcnn_train.m`
modify val_iters
to 1/5 of your val
- funvtions/rpn/proposal_train.m
same as before
- In imdb/imdb_eval_voc.m
modify to:
- Modify model
Attention:
- If there is bug in your training, before start restart, don't forget delete old
output
andimdb/cache
- xml must be same format as VOC2007(./datasets/VOCdevkit2007/VOC2007Annotations)
space
can not insteadtabel
- Modify the number of Iterations: in
./experiments/+Model/ZF_for_Faster_RCNN_VOC2007.m
the codesolver_30k40k
that menas use which file of Interations, you can open./models/fast_rcnn_prototxts
and./models/rpn_prototxts
build new.prototxts
for your own Iterations.- In
imdb\imdb_eval_voc.m
modifydo_eval = (str2num(year) <= 2007) | ~strcmp(test_set,'test');
to%do_eval = (str2num(year) <= 2007) | ~strcmp(test_set,'test'); do_eval = 1;
- 2 usefull blogs for training faster_rcnn link: http://blog.csdn.net/sinat_30071459/article/details/50546891 http://blog.csdn.net/u014696921/article/details/52950218
- Run
experiments/script_faster_rcnn_VOC2007_ZF.m
stay your path just in 'faster_rcnn', not in 'experiments'