我正在使用Tensorflow的Object Detection API在Cloud ML Engine上训练一个Inception SSD对象检测模型,我想使用preprocessor.proto文件中提到的各种data_augmentation_options
。< / p>
我目前有兴趣使用的是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
和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)]]
答案 0 :(得分:1)
如上所述here,您需要一种不同的方式来准备原型文本。有关您的进一步问题,请提供更多详细信息。
答案 1 :(得分: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
}
}
答案 2 :(得分:0)
我面临着同样的问题,对我来说,论点是通过以下方式传递的:
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
出现在docs中,但没有出现在mu proto中,因此它抱怨了。我的原型包含以下代码:
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_ratio
和max_aspect_ratio
。