0

我正在使用 Tensorflow 的对象检测 API 在 Cloud ML Engine 上训练 Inception SSD 对象检测模型,并且我想使用preprocessor.proto文件data_augmentation_options中提到的各种方法。

我目前有兴趣使用的是操作和ssd_random_crop_pad更改.min_padded_size_ratiomax_padded_size_ratio

preprocessor.proto中提到的文档说明了以下内容:

// Min ratio of padded image height and width to the input image's height and
  // width. Two entries per operation.
  repeated float min_padded_size_ratio = 8;

  // Max ratio of padded image height and width to the input image's height and
  // width. Two entries per operation.
repeated float max_padded_size_ratio = 9;

preprocessor.py中提到的文档将函数定义为:

def ssd_random_crop_pad(image,
                        boxes,
                        labels,
                        label_scores=None,
                        multiclass_scores=None,
                        min_object_covered=(0.1, 0.3, 0.5, 0.7, 0.9, 1.0),
                        aspect_ratio_range=((0.5, 2.0),) * 6,
                        area_range=((0.1, 1.0),) * 6,
                        overlap_thresh=(0.1, 0.3, 0.5, 0.7, 0.9, 1.0),
                        random_coef=(0.15,) * 6,
                        min_padded_size_ratio=((1.0, 1.0),) * 6,
                        max_padded_size_ratio=((2.0, 2.0),) * 6,
                        pad_color=(None,) * 6,
                        seed=None,
preprocess_vars_cache=None)

其中 和 的参数min_padded_size_ratiomax_padded_size_ratio(h, w) 形式的元组。

config但是,当我以下面给出的格式在文件中提供这些参数时:

data_augmentation_options {
    ssd_random_crop_pad {
      operations {
        min_padded_size_ratio: (16.0, 16.0)
        max_padded_size_ratio: (16.0, 16.0)
        random_coef: 0.5
      }
    }
  }

我遇到以下错误:

ps-replica-2
Traceback (most recent call last): File "/usr/lib/python2.7/runpy.py", line 174, in _run_module_as_main "__main__", fname, loader, pkg_name) File "/usr/lib/python2.7/runpy.py", line 72, in _run_code exec code in run_globals File "/root/.local/lib/python2.7/site-packages/object_detection/train.py", line 163, in <module> tf.app.run() File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/platform/app.py", line 48, in run _sys.exit(main(_sys.argv[:1] + flags_passthrough)) File "/root/.local/lib/python2.7/site-packages/object_detection/train.py", line 91, in main FLAGS.pipeline_config_path) File "/root/.local/lib/python2.7/site-packages/object_detection/utils/config_util.py", line 43, in get_configs_from_pipeline_file text_format.Merge(proto_str, pipeline_config) File "/usr/local/lib/python2.7/dist-packages/google/protobuf/text_format.py", line 533, in Merge descriptor_pool=descriptor_pool) File "/usr/local/lib/python2.7/dist-packages/google/protobuf/text_format.py", line 587, in MergeLines return parser.MergeLines(lines, message) File "/usr/local/lib/python2.7/dist-packages/google/protobuf/text_format.py", line 620, in MergeLines self._ParseOrMerge(lines, message) File "/usr/local/lib/python2.7/dist-packages/google/protobuf/text_format.py", line 635, in _ParseOrMerge self._MergeField(tokenizer, message) File "/usr/local/lib/python2.7/dist-packages/google/protobuf/text_format.py", line 735, in _MergeField merger(tokenizer, message, field) File "/usr/local/lib/python2.7/dist-packages/google/protobuf/text_format.py", line 823, in _MergeMessageField self._MergeField(tokenizer, sub_message) File "/usr/local/lib/python2.7/dist-packages/google/protobuf/text_format.py", line 735, in _MergeField merger(tokenizer, message, field) File "/usr/local/lib/python2.7/dist-packages/google/protobuf/text_format.py", line 823, in _MergeMessageField self._MergeField(tokenizer, sub_message) File "/usr/local/lib/python2.7/dist-packages/google/protobuf/text_format.py", line 735, in _MergeField merger(tokenizer, message, field) File "/usr/local/lib/python2.7/dist-packages/google/protobuf/text_format.py", line 823, in _MergeMessageField self._MergeField(tokenizer, sub_message) File "/usr/local/lib/python2.7/dist-packages/google/protobuf/text_format.py", line 735, in _MergeField merger(tokenizer, message, field) File "/usr/local/lib/python2.7/dist-packages/google/protobuf/text_format.py", line 823, in _MergeMessageField self._MergeField(tokenizer, sub_message) File "/usr/local/lib/python2.7/dist-packages/google/protobuf/text_format.py", line 735, in _MergeField merger(tokenizer, message, field) File "/usr/local/lib/python2.7/dist-packages/google/protobuf/text_format.py", line 870, in _MergeScalarField value = tokenizer.ConsumeFloat() File "/usr/local/lib/python2.7/dist-packages/google/protobuf/text_format.py", line 1201, in ConsumeFloat raise self.ParseError(str(e)) ParseError: 166:31 : Couldn't parse float: (

谁能帮助我将参数传递给min_padded_size_ratioand的格式max_padded_size_ratio

编辑 1:config使用以下参数更改文件:

ssd_random_crop_pad {
operations {
min_padded_size_ratio: 16.0
min_padded_size_ratio: 16.0
max_padded_size_ratio: 16.0
max_padded_size_ratio: 16.0
random_coef: 0.5
}
}

现在遇到以下错误:

Executor failed to create kernel. Invalid argument: Aspect ratio range must be non-negative: [0, 0]

[[Node: cond/RandomCropImage/SampleDistortedBoundingBox = SampleDistortedBoundingBox[T=DT_INT32, area_range=[0, 0], aspect_ratio_range=[0, 0], max_attempts=100, min_object_covered=0, seed=0, seed2=0, use_image_if_no_bounding_boxes=true, _device="/job:master/replica:0/task:0/cpu:0"](cond/RandomCropImage/Shape, cond/RandomCropImage/ExpandDims)]]
4

3 回答 3

1

我面临同样的问题,对我来说,论点是通过:

  data_augmentation_options {
    random_crop_pad_image {
      min_padded_size_ratio: 1
      min_padded_size_ratio: 1
      max_padded_size_ratio: 2
      max_padded_size_ratio: 2
      random_coef: 0.5
      min_aspect_ratio: 0.5
      max_aspect_ratio: 2.0
    }

所以,也许你应该operations完全删除。另外,根据我的经验,您不应该过多地依赖 tensorflow 文档(它们往往会被破坏,或者至少可悲地经常更改)。直接检查您的原型以获取选项。例如,我的情况是该论点aspect_ratio_range出现在文档中,但没有出现在我的原型中,因此它抱怨了。我的原型包含代码:

message RandomCropPadImage {
  // Cropping operation must cover at least one box by this fraction.
  optional float min_object_covered = 1 [default=1.0];

  // Aspect ratio bounds of image after cropping operation.
  optional float min_aspect_ratio = 2 [default=0.75];
  optional float max_aspect_ratio = 3 [default=1.33];

这表明我应该使用min_aspect_ratioandmax_aspect_ratio代替它。

于 2018-10-09T14:33:02.793 回答
1

我也遇到了错误。我可以通过传递以下参数来解决它:

data_augmentation_options {                                            
   ssd_random_crop_pad_fixed_aspect_ratio {
   operations{
        min_object_covered: 1
        min_aspect_ratio: 0.9
        max_aspect_ratio: 1.1
        min_area: 0.4
        max_area: 1
   }
   aspect_ratio: 1
}                                                                            
}
于 2021-04-29T08:47:42.573 回答
1

如前所述您需要一种不同的方式来准备原始文本。请为您的进一步问题提供更多详细信息。

于 2018-06-10T16:31:09.423 回答