Skip to content

Commit c46732d

Browse files
author
yaochuanqi
committed
move pretrained caffemodels to google drive
1 parent ba00fc9 commit c46732d

11 files changed

+3465
-270
lines changed

README.md

Lines changed: 19 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,31 @@
11
# MobileNet-SSD
2-
A caffe implementation of Google MobileNet SSD detection network, with pretrained weights on VOC0712.
2+
A caffe implementation of MobileNet-SSD detection network, with pretrained weights on VOC0712 and mAP=0.727.
3+
4+
Network|mAP|Download|Download
5+
:---:|:---:|:---:|:---:
6+
MobileNet-SSD|72.7|[train](https://drive.google.com/open?id=0B3gersZ2cHIxVFI1Rjd5aDgwOG8)|[deploy](https://drive.google.com/open?id=0B3gersZ2cHIxRm5PMWRoTkdHdHc)
37

48
### Run
59
1. Download [SSD](https://github.com/weiliu89/caffe/tree/ssd) source code and compile (follow the SSD README).
6-
2. Put all the files in SSD_HOME/examples/
7-
3. Run merge_bn.py to generate deploy caffemodel.
8-
4. Run demo.py to test the detection result.
10+
2. Download the pretrained deploy weights from the link above.
11+
3. Put all the files in SSD_HOME/examples/
12+
4. Run demo.py to show the detection result.
913

1014

1115
### Train your own dataset
12-
1. Convert your own dataset to lmdb database (follow the SSD README).
13-
2. Modify the MobileNetSSD_train.prototxt like this (or use gen.py):
14-
* Change the lmdb database and labelmap file path.
15-
```
16-
data_param {
17-
source: "/home/yaochuanqi/data/VOCdevkit/VOC0712/lmdb/VOC0712_trainval_lmdb" # change to your lmdb path
18-
batch_size: 32
19-
backend: LMDB
20-
}
21-
22-
...
23-
24-
label_map_file: "../../data/VOC0712/labelmap_voc.prototxt" # change to your labelmap file
25-
```
26-
* Change the mbox_conf layer output num for all 5 mbox_conf layers, and change the layer name of 5 mbox_conf.
27-
```
28-
convolution_param {
29-
num_output: 84 # 84 = 21 * 4, set to (classnum + 1) * 4 , "+1" is for background
30-
bias_term: false
31-
32-
...
33-
34-
convolution_param {
35-
num_output: 126 # 126 = 21 * 6, set to (classnum + 1) * 6 , "+1" is for background
36-
bias_term: false
37-
```
16+
1. Convert your own dataset to lmdb database (follow the SSD README), and create symlinks to current directory.
3817
```
39-
layer {
40-
name: "conv11_mbox_conf" #set to a different name, e.g. "conv11_mbox_conf_voc"
41-
type: "Convolution"
42-
bottom: "conv11"
18+
ln -s PATH_TO_YOUR_TRAIN_LMDB trainval_lmdb
19+
ln -s PATH_TO_YOUR_TEST_LMDB test_lmdb
4320
```
44-
3. Run train.sh, after about 30000 iteration, the loss should be 2.0 - 3.0.
45-
4. Run merge_bn.py to generate your own deploy caffemodel.
21+
2. Create the labelmap.prototxt file and put it into current directory.
22+
3. Use gen_model.sh to generate your own training model.
23+
4. Download the MobileNetSSD_train.caffemodel from the link above, and run train.sh, after about 30000 iterations, the loss should be 1.5 - 2.5.
24+
5. Run test.sh to evaluate the result.
25+
6. Run merge_bn.py to generate your own deploy caffemodel.
4626

4727
### About some details
48-
There are 3 differences between my model and [MobileNet-SSD on tensorflow](https://github.com/tensorflow/models/blob/master/object_detection/g3doc/detection_model_zoo.md):
49-
1. I replaced the tensorflow's ReLU6 layer with ReLU.
50-
2. My batch normal eps=0.00001 vs tensorflow's eps=0.001.
51-
3. For the conv11 anchors, I use [(0.2, 1.0), (0.2, 2.0), (0.2, 0.5)] vs tensorflow's [(0.1, 1.0), (0.2, 2.0), (0.2, 0.5)].
28+
There are 2 primary differences between this model and [MobileNet-SSD on tensorflow](https://github.com/tensorflow/models/blob/master/object_detection/g3doc/detection_model_zoo.md):
29+
1. ReLU6 layer is replaced by ReLU.
30+
2. For the conv11_mbox_prior layer, the anchors is [(0.2, 1.0), (0.2, 2.0), (0.2, 0.5)] vs tensorflow's [(0.1, 1.0), (0.2, 2.0), (0.2, 0.5)].
5231

gen_model.sh

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/bin/sh
2+
if test -z $1 ;then
3+
echo usage: $0 CLASSNUM
4+
echo " for voc the classnum is 21"
5+
exit 1
6+
fi
7+
echo $1 |grep '^[0-9]*$' >/dev/null 2>&1
8+
if [ $? != 0 ];then
9+
echo usage: $0 CLASSNUM
10+
echo " for voc the classnum is 21"
11+
exit 1
12+
fi
13+
cls_num=$1
14+
cls_num3=$(expr $1 \* 3)
15+
cls_num6=$(expr $1 \* 6)
16+
trainfile=example/MobileNetSSD_train.prototxt
17+
testfile=example/MobileNetSSD_test.prototxt
18+
deploybnfile=example/MobileNetSSD_deploy_bn.prototxt
19+
deployfile=example/MobileNetSSD_deploy.prototxt
20+
21+
mkdir -p example
22+
23+
cp template/MobileNetSSD_train_template.prototxt $trainfile
24+
sed -i "s/cls6x/${cls_num6}/g" $trainfile
25+
sed -i "s/cls3x/${cls_num3}/g" $trainfile
26+
sed -i "s/cls1x/${cls_num}/g" $trainfile
27+
28+
cp template/MobileNetSSD_test_template.prototxt $testfile
29+
sed -i "s/cls6x/${cls_num6}/g" $testfile
30+
sed -i "s/cls3x/${cls_num3}/g" $testfile
31+
sed -i "s/cls1x/${cls_num}/g" $testfile
32+
33+
#cp template/MobileNetSSD_deploy_bn_template.prototxt $deploybnfile
34+
#sed -i "s/cls6x/${cls_num6}/g" $deploybnfile
35+
#sed -i "s/cls3x/${cls_num3}/g" $deploybnfile
36+
#sed -i "s/cls1x/${cls_num}/g" $deploybnfile
37+
38+
cp template/MobileNetSSD_deploy_template.prototxt $deployfile
39+
sed -i "s/cls6x/${cls_num6}/g" $deployfile
40+
sed -i "s/cls3x/${cls_num3}/g" $deployfile
41+
sed -i "s/cls1x/${cls_num}/g" $deployfile
42+

solver.prototxt renamed to solver_test.prototxt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@ test_iter: 673
44
test_interval: 10000
55
base_lr: 0.0005
66
display: 10
7-
max_iter: 120000
7+
max_iter: 0
88
lr_policy: "multistep"
99
gamma: 0.5
1010
weight_decay: 0.00005
11-
snapshot: 1000
11+
snapshot: 0
1212
snapshot_prefix: "snapshot/mobilenet"
1313
solver_mode: GPU
1414
debug_info: false
15-
snapshot_after_train: true
16-
test_initialization: false
15+
snapshot_after_train: false
16+
test_initialization: true
1717
average_loss: 10
1818
stepvalue: 20000
1919
stepvalue: 40000

solver_train.prototxt

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
train_net: "example/MobileNetSSD_train.prototxt"
2+
test_net: "example/MobileNetSSD_test.prototxt"
3+
test_iter: 673
4+
test_interval: 10000
5+
base_lr: 0.0005
6+
display: 10
7+
max_iter: 120000
8+
lr_policy: "multistep"
9+
gamma: 0.5
10+
weight_decay: 0.00005
11+
snapshot: 1000
12+
snapshot_prefix: "snapshot/mobilenet"
13+
solver_mode: GPU
14+
debug_info: false
15+
snapshot_after_train: true
16+
test_initialization: false
17+
average_loss: 10
18+
stepvalue: 20000
19+
stepvalue: 40000
20+
iter_size: 1
21+
type: "RMSProp"
22+
eval_type: "detection"
23+
ap_version: "11point"
24+

0 commit comments

Comments
 (0)