本文整理汇总了Python中object_detection.create_pascal_tf_record.dict_to_tf_example方法的典型用法代码示例。如果您正苦于以下问题:Python create_pascal_tf_record.dict_to_tf_example方法的具体用法?Python create_pascal_tf_record.dict_to_tf_example怎么用?Python create_pascal_tf_record.dict_to_tf_example使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类object_detection.create_pascal_tf_record
的用法示例。
在下文中一共展示了create_pascal_tf_record.dict_to_tf_example方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_records
# 需要导入模块: from object_detection import create_pascal_tf_record [as 别名]
# 或者: from object_detection.create_pascal_tf_record import dict_to_tf_example [as 别名]
def create_records(data_dir, to_path='data/train.tfrecord'):
annotations_dir, examples_path = get_fun_paths(data_dir)
writer = tf.python_io.TFRecordWriter(to_path)
labels = {}
examples_list = dataset_util.read_examples_list(examples_path)
assert len(examples_list) > 0, examples_path
for i, example in enumerate(examples_list):
path = os.path.join(annotations_dir, example + '.xml')
data = xml_to_dict(path)
assert 'object' in data, data['filename']
labels[i] = [k['name'] for k in data['object']]
try:
tf_example = dict_to_tf_example(data, data_dir, label_map_dict)
except Exception as e: #TODO(SS): remove me
print(e)
import pdb; pdb.set_trace()
writer.write(tf_example.SerializeToString())
writer.close()
return labels # to inspect a bit