Use dump_tensorflow_weights.py to dump the weights of conv layer and batchnorm layer.
Use load_caffe_weights.py to load the dumped weights to deploy.caffemodel.
Use the code in src to accelerate your training if you have a cudnn7, or add "engine: CAFFE" to your depthwise convolution layer to solve the memory issue.
The original tensorflow model is trained on MSCOCO dataset, maybe you need deploy.caffemodel for VOC dataset, use coco2voc.py to get deploy_voc.caffemodel.
Train your own dataset
Generate the trainval_lmdb and test_lmdb from your dataset.
Write a labelmap.prototxt
Use gen_model.py to generate some prototxt files, replace the "CLASS_NUM" with class number of your own dataset.
Copy coco/solver_train.prototxt and coco/train.sh to your project and start training.
Note
There are some differences between caffe and tensorflow implementation:
The padding method 'SAME' in tensorflow sometimes use the [0, 0, 1, 1] paddings, means that top=0, left=0, bottom=1, right=1 padding. In caffe, there is no parameters can be used to do that kind of padding.
MobileNet on Tensorflow use ReLU6 layer y = min(max(x, 0), 6), but caffe has no ReLU6 layer. Replace ReLU6 with ReLU cause a bit accuracy drop in ssd-mobilenetv2, but very large drop in ssdlite-mobilenetv2. There is a ReLU6 layer implementation in my fork of ssd.
请发表评论