【问题标题】:ssd mobilenet v1: change feature map layoutssd mobilenet v1:更改特征图布局
【发布时间】:2020-02-23 20:25:03
【问题描述】:

我正在尝试重新训练 SSD 模型以检测一类自定义对象(吉他)。 我正在使用 ssd_mobilenet_v1_coco 模型,其中包含从 OpenImage 数据集下载的 1000K 预标记图像的数据集。
我指的是this answer,以尝试改进对图像中小物体的检测。

按照那里的建议,我想在已经存在的特征图上添加一个额外的特征图 (Conv2d_5_pointwise),因此总共有 7 个特征图。所以,我这样修改了“models/ssd_mobilenet_v1_feature_extractor.py”:

 feature_map_layout = {
        'from_layer': ['Conv2d_5_pointwise','Conv2d_11_pointwise', 'Conv2d_13_pointwise', '', '',
                       '', ''][:self._num_layers],
        'layer_depth': [-1, -1, -1, 512, 256, 256, 128][:self._num_layers],
        'use_explicit_padding': self._use_explicit_padding,
        'use_depthwise': self._use_depthwise,
    }

因此,我也将配置文件中的 num_layers 更改为 7。


    anchor_generator {
      ssd_anchor_generator {
        num_layers: 7
        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
      }
    }

但是,当尝试使用 main_model.py 训练模型时,我收到错误消息


 File "/home/carlo/projects/tf_models/research/object_detection/core/anchor_generator.py", line 105, in generate
    raise ValueError('Number of feature maps is expected to equal the length '
ValueError: Number of feature maps is expected to equal the length of `num_anchors_per_location`.

我是否应该修改其他任何内容以使其正常工作? 谢谢!

【问题讨论】:

    标签: python tensorflow object-detection object-detection-api mobilenet


    【解决方案1】:

    好的,想通了。

    简单地说,我必须在 SSDMobileNetV1FeatureExtractor 类的构造函数中修改另一个参数(num_layers):

    def __init__(self,
               is_training,
               depth_multiplier,
               min_depth,
               pad_to_multiple,
               conv_hyperparams_fn,
               reuse_weights=None,
               use_explicit_padding=False,
               use_depthwise=False,
    
               num_layers=7,    <--- HERE
    
               override_base_feature_extractor_hyperparams=False):
    

    匹配新的特征图数量。

    【讨论】:

      【解决方案2】:

      我在尝试将multiscale_anchor_generator 与 ssd 模型中的以下配置一起使用时遇到了问题。我必须在 feature_extractor 部分下将 num_layers 设置为 5 才能修复它。

      multiscale_anchor_generator {
        min_level: 3
        max_level: 7
        anchor_scale: 4.0
        aspect_ratios: [1.0, 2.0, 0.5]
        scales_per_octave: 2
      }
      

      【讨论】:

        猜你喜欢
        • 2020-03-26
        • 2020-01-30
        • 2020-11-07
        • 2018-09-22
        • 2018-11-07
        • 1970-01-01
        • 2020-04-16
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多