Skip to content

Commit 7cc976d

Browse files
committed
fix number of anchor ratio
1 parent 1ace507 commit 7cc976d

File tree

7 files changed

+20
-18
lines changed

7 files changed

+20
-18
lines changed

README.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ This repository contains codes of the reimplementation of [SSD: Single Shot Mult
44

55
There are already some TensorFlow based SSD reimplementation codes on GitHub, the main special features of this repo inlcude:
66

7-
- state of the art performance(77.4%mAP) when training from VGG-16 pre-trained model (SSD300-VGG16).
8-
- the model is trained using TensorFlow high level API [tf.estimator](https://www.tensorflow.org/api_docs/python/tf/estimator/Estimator). Although TensorFlow provides many APIs, the Estimator API is highly recommended to yield scalable, high-performance models.
7+
- state of the art performance(77.9%mAP) when training from VGG-16 pre-trained model (SSD300-VGG16).
8+
- the model is trained using TensorFlow high level API [tf.estimator](https://www.tensorflow.org/api_docs/python/tf/estimator/Estimator). Although TensorFlow provides many APIs, the Estimator API is highly recommended to yield scalable, high-performance models.
99
- all codes were writen by pure TensorFlow ops (no numpy operation) to ensure the performance and portability.
1010
- using ssd augmentation pipeline discribed in the original paper.
1111
- PyTorch-like model definition using high-level [tf.layers](https://www.tensorflow.org/api_docs/python/tf/layers) API for better readability ^-^.
@@ -23,7 +23,7 @@ There are already some TensorFlow based SSD reimplementation codes on GitHub, th
2323
| |->...
2424
|->VOC2012/
2525
| |->Annotations/
26-
| |->ImageSets/
26+
| |->ImageSets/
2727
| |->...
2828
|->VOC2007TEST/
2929
| |->Annotations/
@@ -38,13 +38,13 @@ There are already some TensorFlow based SSD reimplementation codes on GitHub, th
3838
- Run the following script to start training:
3939

4040
```sh
41-
python train_ssd.py
41+
python train_ssd.py
4242
```
4343
- Run the following script for evaluation and get mAP:
4444

4545
```sh
46-
python eval_ssd.py
47-
python voc_eval.py
46+
python eval_ssd.py
47+
python voc_eval.py
4848
```
4949
Note: you need first modify some directory in voc_eval.py.
5050
- Run the following script for visualization:
@@ -65,13 +65,13 @@ All the codes was tested under TensorFlow 1.6, Python 3.5, Ubuntu 16.04 with CUD
6565

6666
## Results (VOC07 Metric)
6767

68-
This implementation(SSD300-VGG16) yield **mAP 77.4%** on PASCAL VOC 2007 test dataset(the original performance described in the paper is 77.2%mAP), the details are as follows:
68+
This implementation(SSD300-VGG16) yield **mAP 77.9%** on PASCAL VOC 2007 test dataset(the original performance described in the paper is 77.2%mAP), the details are as follows:
6969

7070
| sofa | bird | pottedplant | bus | diningtable | cow | bottle | horse | aeroplane | motorbike
7171
|:-------|:-----:|:-------:|:-------:|:-------:|:-------:|:-------:|:-------:|:-------:|:-------:|
72-
| 78.8 | 76.3 | 53.3 | 86.2 | 77.7 | 83.0 | 52.7 | 85.5 | 82.3 | 82.2 |
72+
| 80.1 | 75.9 | 54.1 | 85.4 | 77.8 | 85.2 | 48.7 | 85.8 | 83.6 | 82.3 |
7373
| **sheep** | **train** | **boat** | **bicycle** | **chair** | **cat** | **tvmonitor** | **person** | **car** | **dog** |
74-
| 77.2 | 87.3 | 69.7 | 83.3 | 59.0 | 88.2 | 74.6 | 79.6 | 84.8 | 85.1 |
74+
| 80.3 | 85.9 | 71.6 | 83.7 | 62.6 | 89.0 | 74.8 | 79.3 | 85.6 | 86.6 |
7575

7676
You can download the trained model(VOC07+12 Train) from [GoogleDrive](https://drive.google.com/open?id=1sr3khWzrXZtcS5mmkQDL00y07Rj7erW5) for further research.
7777

@@ -98,22 +98,22 @@ Here is the training logs and some detection results:
9898
- Why: There maybe some inconsistent between different TensorFlow version.
9999
- How: If you got this error, try change the default value of checkpoint_path to './model/vgg16.ckpt' in [train_ssd.py](https://github.com/HiKapok/SSD.TensorFlow/blob/86e3fa600d8d07122e9366ae664dea8c3c87c622/train_ssd.py#L107). For more information [issue6](https://github.com/HiKapok/SSD.TensorFlow/issues/6) and [issue9](https://github.com/HiKapok/SSD.TensorFlow/issues/9).
100100
- Nan loss during training
101-
- Why: This is caused by the default learning rate which is a little higher for some TensorFlow version.
101+
- Why: This is caused by the default learning rate which is a little higher for some TensorFlow version.
102102
- How: I don't know the details about the different behavior between different versions. There are two workarounds:
103103
- Adding warm-up: change some codes [here](https://github.com/HiKapok/SSD.TensorFlow/blob/d9cf250df81c8af29985c03d76636b2b8b19f089/train_ssd.py#L99) to the following snippet:
104104

105105
```python
106106
tf.app.flags.DEFINE_string(
107-
'decay_boundaries', '2000, 80000, 100000',
107+
'decay_boundaries', '1000, 80000, 100000',
108108
'Learning rate decay boundaries by global_step (comma-separated list).')
109109
tf.app.flags.DEFINE_string(
110110
'lr_decay_factors', '0.1, 1, 0.1, 0.01',
111111
'The values of learning_rate decay factor for each segment between boundaries (comma-separated list).')
112112
```
113-
- Lower the learning rate and run more steps until convergency.
113+
- Lower the learning rate and run more steps until convergency.
114114
- Why this re-implementation perform better than the reported performance
115115
- I don't know
116116

117117

118118
## ##
119-
Apache License, Version 2.0
119+
Apache License, Version 2.0

demo/demo1.jpg

-3.22 KB
Loading

demo/demo2.jpg

-908 Bytes
Loading

demo/demo3.jpg

-13.5 KB
Loading

eval_ssd.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,8 @@ def ssd_model_fn(features, labels, mode, params):
151151
anchor_encoder_decoder = anchor_manipulator.AnchorEncoder(positive_threshold=None, ignore_threshold=None, prior_scaling=[0.1, 0.1, 0.2, 0.2])
152152
all_anchor_scales = [(30.,), (60.,), (112.5,), (165.,), (217.5,), (270.,)]
153153
all_extra_scales = [(42.43,), (82.17,), (136.23,), (189.45,), (242.34,), (295.08,)]
154-
all_anchor_ratios = [(2., .5), (2., 3., .5, 0.3333), (2., 3., .5, 0.3333), (2., 3., .5, 0.3333), (2., .5), (2., .5)]
154+
all_anchor_ratios = [(1., 2., .5), (1., 2., 3., .5, 0.3333), (1., 2., 3., .5, 0.3333), (1., 2., 3., .5, 0.3333), (1., 2., .5), (1., 2., .5)]
155+
#all_anchor_ratios = [(2., .5), (2., 3., .5, 0.3333), (2., 3., .5, 0.3333), (2., 3., .5, 0.3333), (2., .5), (2., .5)]
155156

156157
with tf.variable_scope(params['model_scope'], default_name=None, values=[features], reuse=tf.AUTO_REUSE):
157158
backbone = ssd_net.VGG16Backbone(params['data_format'])

simple_ssd_demo.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,8 @@ def main(_):
8686

8787
all_anchor_scales = [(30.,), (60.,), (112.5,), (165.,), (217.5,), (270.,)]
8888
all_extra_scales = [(42.43,), (82.17,), (136.23,), (189.45,), (242.34,), (295.08,)]
89-
all_anchor_ratios = [(2., .5), (2., 3., .5, 0.3333), (2., 3., .5, 0.3333), (2., 3., .5, 0.3333), (2., .5), (2., .5)]
89+
all_anchor_ratios = [(1., 2., .5), (1., 2., 3., .5, 0.3333), (1., 2., 3., .5, 0.3333), (1., 2., 3., .5, 0.3333), (1., 2., .5), (1., 2., .5)]
90+
# all_anchor_ratios = [(2., .5), (2., 3., .5, 0.3333), (2., 3., .5, 0.3333), (2., 3., .5, 0.3333), (2., .5), (2., .5)]
9091

9192
with tf.variable_scope(FLAGS.model_scope, default_name=None, values=[features], reuse=tf.AUTO_REUSE):
9293
backbone = ssd_net.VGG16Backbone(FLAGS.data_format)

train_ssd.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,10 @@
100100
'The minimal end learning rate used by a polynomial decay learning rate.')
101101
# for learning rate piecewise_constant decay
102102
tf.app.flags.DEFINE_string(
103-
'decay_boundaries', '80000, 100000',
103+
'decay_boundaries', '1000, 80000, 100000',
104104
'Learning rate decay boundaries by global_step (comma-separated list).')
105105
tf.app.flags.DEFINE_string(
106-
'lr_decay_factors', '1, 0.1, 0.01',
106+
'lr_decay_factors', '0.1, 1, 0.1, 0.01',
107107
'The values of learning_rate decay factor for each segment between boundaries (comma-separated list).')
108108
# checkpoint related configuration
109109
tf.app.flags.DEFINE_string(
@@ -176,7 +176,7 @@ def input_fn():
176176

177177
all_anchor_scales = [(30.,), (60.,), (112.5,), (165.,), (217.5,), (270.,)]
178178
all_extra_scales = [(42.43,), (82.17,), (136.23,), (189.45,), (242.34,), (295.08,)]
179-
all_anchor_ratios = [(2., .5), (2., 3., .5, 0.3333), (2., 3., .5, 0.3333), (2., 3., .5, 0.3333), (2., .5), (2., .5)]
179+
all_anchor_ratios = [(1., 2., .5), (1., 2., 3., .5, 0.3333), (1., 2., 3., .5, 0.3333), (1., 2., 3., .5, 0.3333), (1., 2., .5), (1., 2., .5)]
180180
all_layer_shapes = [(38, 38), (19, 19), (10, 10), (5, 5), (3, 3), (1, 1)]
181181
all_layer_strides = [8, 16, 32, 64, 100, 300]
182182
total_layers = len(all_layer_shapes)

0 commit comments

Comments
 (0)