This is a tutorial of how tp train the MobileNet-SSD detection network. The implementation of MobileNet-SSD detection network used was taken from here.
- Download the caffe source code from BVLC or here and compile.
- Put the MobileNet-SSD directory in caffe/examples.
- Run demo.py.
- Prepare the caffe-ssd VOC training datasets.
- Put MyDataSet directory in caffe/data.
- Replace the content in MyDataSet/Images with the VOC training datasets Images (should be original images), replace and content in MyDataSet/Labels with the VOC training datasets Labels (should be xml files). Each image in Images folder should have a unique label file in Labels folder with same name.
- Modify MyDataSet/create_data.py file if necessary.
- Create MyDataSet/ImageSets/Main.
- Run MyDataSet/create_data.py, which will generate four txt files in ImageSets/Main.
- Modify the paths and directories in
create_list.shandcreate_data.shas specified in same file in comments (The scripts was taken from here). - Modify
labelmap_voc.prototxtaccording to your classes defined in the caffe-ssd VOC training datasets. - Run
create_list.shandcreate_data.sh.
- Go to caffe/examples/MobileNet-SSD
- Run
gen_model.shwith one argumentnwhere n is the number of your classes defined in MyDataSet/labelmap_voc.prototxt (e.g.bash gen_model.sh 2and there are 2 classed including background defined in MyDataSet/labelmap_voc.prototxt). - Create symlinks.
ln -s PATH_TO_YOUR_TRAIN_LMDB trainval_lmdb
ln -s PATH_TO_YOUR_TEST_LMDB test_lmdb
- Modify
train.shif necessary (Currently the training mode is CUP-ONLY). - Run
train.shwhich will generate snapshots in caffe/examples/MobileNet-SSD/snapshot directory. - Run
merge_bn.pyto obtain the caffemodel and prototxt based on snapshots generated from the previous step. One example:
python merge_bn.py --model ./example/MobileNetSSD_deploy.prototxt --weights ./snapshot/mobilenet_iter_50000.caffemodel