tensorflow / models

Models and examples built with TensorFlow
Other
77.25k stars 45.75k forks source link

Single anchor box specification in SSDs #9627

Open sayakpaul opened 3 years ago

sayakpaul commented 3 years ago

Prerequisites

Please answer the following question for yourself before submitting an issue.

1. The entire URL of the documentation with the issue

https://github.com/tensorflow/models/tree/master/research/object_detection/g3doc

2. Describe the issue

Is it possible to modify the config of an SSD MobileNet to allow the network to operate with only one anchor box per feature map? I am suspecting I need to modify the anchor_generator option inside the configuration but I wanted to be sure (if this is possible at all).

hhsinhan commented 3 years ago

i'll try to answer this question.

here's partially the configure looks like:

anchor_generator {
      ssd_anchor_generator {
        num_layers: 6
        min_scale: 0.2
        max_scale: 0.95
        aspect_ratios: 1.0
        aspect_ratios: 2.0
        aspect_ratios: 0.5
        aspect_ratios: 3.0
        aspect_ratios: 0.3333
      }
    }

you can try to write in this way:

anchor_generator {
      ssd_anchor_generator {
        num_layers: 6
        reduce_boxes_in_lowest_layer: false 
        interpolated_scale_aspect_ratio:-1.0 
        min_scale: 0.2
        max_scale: 0.95
        aspect_ratios: 1.0
      }
    }

reference code: last function in: https://github.com/tensorflow/models/blob/master/research/object_detection/anchor_generators/multiple_grid_anchor_generator.py and https://github.com/tensorflow/models/blob/master/research/object_detection/protos/ssd_anchor_generator.proto

  1. reduce_boxes_in_lowest_layer: usually true, which the first ssd anchor layer is hard coded. see line 328, 329. if we set into false, it will consider the anchor we list in the configure file.
  2. interpolated_scale_aspect_ratio: usually create interpolated scale anchor, set it lower than 0 will not create an extra anchor in each layer. see line 336~338

There is no need to change the code in anchor generator. You can print out "box_specs_list" before return to prove if i am right or not.