物體檢測算法 SSD 的訓練和測試
GitHub:https://github.com/stoneyang/caffe_ssd
Paper: https://arxiv.org/abs/1512.02325
1. 安裝 caffe_SSD:
git clone https://github.com/weiliu89/caffe.git
cd caffe git checkout ssd
2. 編譯該 caffe 文件,在主目錄下:
# Modify Makefile.config according to your Caffe installation. cp Makefile.config.example Makefile.config make -j24 # Make sure to include $CAFFE_ROOT/python to your PYTHONPATH. make pycaffe
# Then, you need to export your Python path into the environment. This Step is important, it may shown you error, if you skip this operation.
export PYTHONPATH=/home/wangxiao/Documents/caffe/python:$PYTHONPATH
但是,事情總是沒那么順利啊,不然你也不會在這里看我瞎bb了。
編譯過程中,會遇到這個bug:json_parser_read.hpp:257:264: error: ‘type name’ declared as function returning an array escape
然后,你想繼續玩這個SSD,就得執行如下操作,以繼續編譯該caffe文件:
修改json_parser_read.hpp:打開文件夾Document,選中computer,在搜索json_parser_read.hpp,找到該文件的路徑之后用如下命令打開
sudo gedit /usr/include/boost/property_tree/detail/json_parser_read.hpp
將257行開始的escape代碼段注釋掉即可,如下:
/*escape = chset_p(detail::widen<Ch>("\"\\/bfnrt").c_str()) [typename Context::a_escape(self.c)] | 'u' >> uint_parser<unsigned long, 16, 4, 4>() [typename Context::a_unicode(self.c)] ;*/
3. 編譯完成后,開始下載作者使用的 在 ImageNet 上預訓練好的 VGG-16 模型:
Download fully convolutional reduced (atrous) VGGNet. By default, we assume the model is stored in $CAFFE_ROOT/models/VGGNet/
4. 下載訓練測試用的數據集:Pascal VOC 2007 2012:
# Download the data. cd $HOME/data wget http://host.robots.ox.ac.uk/pascal/VOC/voc2012/VOCtrainval_11-May-2012.tar wget http://host.robots.ox.ac.uk/pascal/VOC/voc2007/VOCtrainval_06-Nov-2007.tar wget http://host.robots.ox.ac.uk/pascal/VOC/voc2007/VOCtest_06-Nov-2007.tar # Extract the data. tar -xvf VOCtrainval_11-May-2012.tar tar -xvf VOCtrainval_06-Nov-2007.tar tar -xvf VOCtest_06-Nov-2007.tar
5. 將這些文件打包處理,生成 lmdb 文件:
./data/VOC0712/create_list.sh
./data/VOC0712/create_data.sh
6. 數據集處理完畢后,我們就可以修改相關的參數以及路徑等,使得在我們自己的機器上可以爽快的運行:
vim /examples/ssd/ssd_pascal.py
主要包括:
1. 訓練數據集 lmdb 的路徑:
2. 測試數據集 lmdb 的路徑:
3. gpus=”0,1,2,3” ===> 改為”0”
4. batchsize = 32 ==>> 改為 20 比較好,因為有可能會顯存溢出;
7. 將以上幾點都注意到,應該不會再出問題的了,目測我的已經訓練到第 360 次迭代了。。。
以上就是 SSD的訓練部分。
Reference:
1. http://blog.csdn.net/tfy1028/article/details/53289106
2. http://blog.csdn.net/zhang_shuai12/article/details/52346878