本文整理匯總了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