From 2d8b0cb9b2e70281bf9dce438ff17ffa5e59075c Mon Sep 17 00:00:00 2001 From: PlainSailing <861012986@qq.com> Date: Sat, 11 Aug 2018 19:12:10 +0800 Subject: [PATCH] fix number of anchor ratio --- README.md | 22 +++++++++++----------- eval_ssd.py | 3 ++- simple_ssd_demo.py | 3 ++- train_ssd.py | 6 +++--- 4 files changed, 18 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 2fbe1a1..dee8d5e 100644 --- a/README.md +++ b/README.md @@ -5,14 +5,14 @@ This repository contains codes of the reimplementation of [SSD: Single Shot Mult There are already some TensorFlow based SSD reimplementation codes on GitHub, the main special features of this repo inlcude: - state of the art performance(77.8%mAP) when training from VGG-16 pre-trained model (SSD300-VGG16). -- 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. +- 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. - all codes were writen by pure TensorFlow ops (no numpy operation) to ensure the performance and portability. - using ssd augmentation pipeline discribed in the original paper. - PyTorch-like model definition using high-level [tf.layers](https://www.tensorflow.org/api_docs/python/tf/layers) API for better readability ^-^. - high degree of modularity to ease futher development. - using replicate\_model\_fn makes it flexible to use one or more GPUs. -***New Update(77.4%mAP): using absolute bbox coordinates instead of normalized coordinates, checkout [here](https://github.com/HiKapok/SSD.TensorFlow/tree/AbsoluteCoord).*** +***New Update(77.9%mAP): using absolute bbox coordinates instead of normalized coordinates, checkout [here](https://github.com/HiKapok/SSD.TensorFlow/tree/AbsoluteCoord).*** ## ## ## Usage @@ -25,7 +25,7 @@ There are already some TensorFlow based SSD reimplementation codes on GitHub, th | |->... |->VOC2012/ | |->Annotations/ - | |->ImageSets/ + | |->ImageSets/ | |->... |->VOC2007TEST/ | |->Annotations/ @@ -40,13 +40,13 @@ There are already some TensorFlow based SSD reimplementation codes on GitHub, th - Run the following script to start training: ```sh - python train_ssd.py + python train_ssd.py ``` - Run the following script for evaluation and get mAP: ```sh - python eval_ssd.py - python voc_eval.py + python eval_ssd.py + python voc_eval.py ``` Note: you need first modify some directory in voc_eval.py. - Run the following script for visualization: @@ -71,9 +71,9 @@ This implementation(SSD300-VGG16) yield **mAP 77.8%** on PASCAL VOC 2007 test da | sofa | bird | pottedplant | bus | diningtable | cow | bottle | horse | aeroplane | motorbike |:-------|:-----:|:-------:|:-------:|:-------:|:-------:|:-------:|:-------:|:-------:|:-------:| -| 79.6 | 76.0 | 52.8 | 85.9 | 76.9 | 83.5 | 49.9 | 86.0 | 82.9 | 81.0 | +| 78.9 | 76.2 | 53.5 | 85.2 | 75.5 | 85.0 | 48.6 | 86.7 | 82.2 | 83.4 | | **sheep** | **train** | **boat** | **bicycle** | **chair** | **cat** | **tvmonitor** | **person** | **car** | **dog** | -| 81.6 | 86.2 | 71.8 | 84.2 | 60.2 | 87.8 | 76.7 | 80.5 | 85.5 | 86.2 | +| 82.4 | 87.6 | 72.7 | 83.0 | 61.3 | 88.2 | 74.5 | 79.6 | 85.3 | 86.4 | You can download the trained model(VOC07+12 Train) from [GoogleDrive](https://drive.google.com/open?id=1yeYcfcOURcZ4DaElEn9C2xY1NymGzG5W) for further research. @@ -100,7 +100,7 @@ Here is the training logs and some detection results: - Why: There maybe some inconsistent between different TensorFlow version. - 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). - Nan loss during training - - Why: This is caused by the default learning rate which is a little higher for some TensorFlow version. + - Why: This is caused by the default learning rate which is a little higher for some TensorFlow version. - How: I don't know the details about the different behavior between different versions. There are two workarounds: - Adding warm-up: change some codes [here](https://github.com/HiKapok/SSD.TensorFlow/blob/d9cf250df81c8af29985c03d76636b2b8b19f089/train_ssd.py#L99) to the following snippet: @@ -112,10 +112,10 @@ Here is the training logs and some detection results: 'lr_decay_factors', '0.1, 1, 0.1, 0.01', 'The values of learning_rate decay factor for each segment between boundaries (comma-separated list).') ``` - - Lower the learning rate and run more steps until convergency. + - Lower the learning rate and run more steps until convergency. - Why this re-implementation perform better than the reported performance - I don't know ## ## -Apache License, Version 2.0 \ No newline at end of file +Apache License, Version 2.0 diff --git a/eval_ssd.py b/eval_ssd.py index 722b21c..1a064b8 100644 --- a/eval_ssd.py +++ b/eval_ssd.py @@ -128,7 +128,8 @@ def input_fn(): layers_shapes = [(38, 38), (19, 19), (10, 10), (5, 5), (3, 3), (1, 1)], anchor_scales = [(0.1,), (0.2,), (0.375,), (0.55,), (0.725,), (0.9,)], extra_anchor_scales = [(0.1414,), (0.2739,), (0.4541,), (0.6315,), (0.8078,), (0.9836,)], - anchor_ratios = [(2., .5), (2., 3., .5, 0.3333), (2., 3., .5, 0.3333), (2., 3., .5, 0.3333), (2., .5), (2., .5)], + 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)], + #anchor_ratios = [(2., .5), (2., 3., .5, 0.3333), (2., 3., .5, 0.3333), (2., 3., .5, 0.3333), (2., .5), (2., .5)], layer_steps = [8, 16, 32, 64, 100, 300]) all_anchors, all_num_anchors_depth, all_num_anchors_spatial = anchor_creator.get_all_anchors() diff --git a/simple_ssd_demo.py b/simple_ssd_demo.py index cb64da6..67540bc 100644 --- a/simple_ssd_demo.py +++ b/simple_ssd_demo.py @@ -158,7 +158,8 @@ def main(_): layers_shapes = [(38, 38), (19, 19), (10, 10), (5, 5), (3, 3), (1, 1)], anchor_scales = [(0.1,), (0.2,), (0.375,), (0.55,), (0.725,), (0.9,)], extra_anchor_scales = [(0.1414,), (0.2739,), (0.4541,), (0.6315,), (0.8078,), (0.9836,)], - anchor_ratios = [(2., .5), (2., 3., .5, 0.3333), (2., 3., .5, 0.3333), (2., 3., .5, 0.3333), (2., .5), (2., .5)], + 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)], + #anchor_ratios = [(2., .5), (2., 3., .5, 0.3333), (2., 3., .5, 0.3333), (2., 3., .5, 0.3333), (2., .5), (2., .5)], layer_steps = [8, 16, 32, 64, 100, 300]) all_anchors, all_num_anchors_depth, all_num_anchors_spatial = anchor_creator.get_all_anchors() diff --git a/train_ssd.py b/train_ssd.py index aaab83c..a6c09a8 100644 --- a/train_ssd.py +++ b/train_ssd.py @@ -97,10 +97,10 @@ 'The minimal end learning rate used by a polynomial decay learning rate.') # for learning rate piecewise_constant decay tf.app.flags.DEFINE_string( - 'decay_boundaries', '80000, 100000', + 'decay_boundaries', '500, 80000, 100000', 'Learning rate decay boundaries by global_step (comma-separated list).') tf.app.flags.DEFINE_string( - 'lr_decay_factors', '1, 0.1, 0.01', + 'lr_decay_factors', '0.1, 1, 0.1, 0.01', 'The values of learning_rate decay factor for each segment between boundaries (comma-separated list).') # checkpoint related configuration tf.app.flags.DEFINE_string( @@ -170,7 +170,7 @@ def input_fn(): layers_shapes = [(38, 38), (19, 19), (10, 10), (5, 5), (3, 3), (1, 1)], anchor_scales = [(0.1,), (0.2,), (0.375,), (0.55,), (0.725,), (0.9,)], extra_anchor_scales = [(0.1414,), (0.2739,), (0.4541,), (0.6315,), (0.8078,), (0.9836,)], - anchor_ratios = [(2., .5), (2., 3., .5, 0.3333), (2., 3., .5, 0.3333), (2., 3., .5, 0.3333), (2., .5), (2., .5)], + 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)], layer_steps = [8, 16, 32, 64, 100, 300]) all_anchors, all_num_anchors_depth, all_num_anchors_spatial = anchor_creator.get_all_anchors()