我正在使用 Tensorflow 的对象检测 API 在 Cloud ML Engine 上训练 Inception SSD 对象检测模型,并且我想使用preprocessor.proto文件data_augmentation_options
中提到的各种方法。
我目前有兴趣使用的是操作和ssd_random_crop_pad
更改.min_padded_size_ratio
max_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_ratio
是max_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_ratio
and的格式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)]]