簡體   English   中英

ssd mobilenet v1:更改功能 map 布局

[英]ssd mobilenet v1: change feature map layout

我正在嘗試重新訓練 SSD model 以檢測一個 class 的自定義對象(吉他)。 我正在使用ssd_mobilenet_v1_coco model,其中包含從 OpenImage 數據集下載的 1000K 預標記圖像的數據集。
我指的是這個答案,試圖改進對圖像中小物體的檢測。

正如那里所建議的那樣,我想在已經存在的特征圖上添加一個額外的特征 map ( 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 訓練 model 時,我收到錯誤消息


 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`.

我應該修改其他任何東西以使其工作嗎? 謝謝!

好的,想通了。

簡單地說,我必須在 SSDMobileNetV1FeatureExtractor class 的構造函數中修改另一個參數( 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):

匹配新的特征圖數量。

我在嘗試在 ssd multiscale_anchor_generator中使用具有以下配置的 multiscale_anchor_generator 時遇到了問題。 我必須在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
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM