SSD (single Shot Multibox Detector) is a relatively good target detection algorithm, the main direction is the speed, of course, the accuracy is higher than the YOLO, Recently implemented in ubuntu16.04 code run, this blog main content from the original author of GitHub, plus some personal understanding, welcome to explore.
Preparation: Linux+cuda+caffe is standard, I will not detail, recommended blog:
Ubuntu16.04+nvidia Gt740m+cuda7.5+caffe installation, Test experience http://blog.csdn.NET/WoPawn/article/details/52313914
The following official start: 1. Get the source code
[plain] view plain copy git clone https://github.com/weiliu89/caffe.git cd caffe git Checkout SSD
Description: SSD is in the Caffe folder embedded routines in the way, the author changed the original Caffe, so you need to remove the original Caffe folder, git command will create a new program with the SSD Caffe folder, of course, this new caffe to recompile once. 2. Compiling Caffe [plain] view plain copy cd/home/mx/caffe CP Makefile.config.example Makefile.config
Run times wrong constantly, after the summary, need to modify the configuration file, with Gedit or vim open the configuration file for modification:
1) in the Makefile.config file
Add Use_cudnn: =1 uncomment
2) in the Makefile.config file
Include_dirs: = $ (python_include)/usr/local/include after a space,
Then add/usr/include/hdf5/serial, if not this sentence will be reported a hdf5.h can not find the error
3) in the makefile file
Replacement Nvccflags + =-ccbin=$ (CXX)-xcompiler-fpic $ (common_flags)
For nvccflags + =-d_force_inlines-ccbin=$ (CXX)-xcompiler-fpic $ (common_flags)
Save exit.
Continue to enter commands
[plain] view plain copy make-j8 #8线程 make py made test-j8 make Runtest-j8 #貌似不是必须的, it took more than 10 minutes to run
3. Training Model
The time-saving approach is to directly download the model that the original author has finalized:
Http://www.cs.unc.edu/~wliu/projects/SSD/models_VGGNet_VOC0712_SSD_300x300.tar.gz
After decompression, put the voc0712 folder under/home/mx/caffe/models/vggnet/
Or: Students with good condition can download picture data and pre-training model, carry out finetuning, get the final model, the steps are as follows:
1) Download the pre-training model
Https://gist.github.com/weiliu89/2ed6e13bfd5b57cf81d6
Put it in the new folder/home/mx/caffe/models/vggnet/
2) Download voc2007 and voc2012 datasets
[plain] view plain copy cd/home/mx/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
If the terminal download is too slow, then manually download the file according to the address, still put in the folder/home/mx/data/
Unzip the files, in order to
[plain] view plain copy cd/home/mx/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
3) Convert image to Lmdb file for training
[plain] view plain copy Cd/home/mx/caffe./data/voc0712/create_list.sh./data/voc0712/create_data.sh
The script used here implements batching, and there may be errors: No module named Caffe or no module named Caffe-proto, that is Caffe Python environment variable not configured, workaround:
[plain] view plain copy echo "Export Pythonpath=/home/username/caffe/python" >> ~/.profile source ~/.pr Ofile Echo $PYTHONPATH #检查环境变量的值
Once the environment variable is set, rerun the command without error.
4) Training model (finetuning)