Commit 32533a06 authored by Marianne Linhares Monteiro's avatar Marianne Linhares Monteiro Committed by GitHub
Browse files

Creating convert_to_tfrecord function

Changing file to follow examples/how_tos/reading_data/convert_to_records.py
parent 751bfb3f
......@@ -58,16 +58,9 @@ def read_pickle_from_file(filename):
return data_dict
def main(argv):
del argv # Unused.
file_names = _get_file_names()
for file_name in file_names:
input_file = os.path.join(FLAGS.input_dir, file_name)
output_file = os.path.join(FLAGS.output_dir, file_name + '.tfrecords')
def convert_to_tfrecord(input_file, name):
"""Converts a file to tfrecords."""
print('Generating %s' % output_file)
record_writer = tf.python_io.TFRecordWriter(output_file)
data_dict = read_pickle_from_file(input_file)
......@@ -84,6 +77,16 @@ def main(argv):
record_writer.write(example.SerializeToString())
record_writer.close()
def main(argv):
del argv # Unused.
file_names = _get_file_names()
for file_name in file_names:
input_file = os.path.join(FLAGS.input_dir, file_name)
output_file = os.path.join(FLAGS.output_dir, file_name + '.tfrecords')
# Convert to Examples and write the result to TFRecords.
convert_to_tfrecord(input_file, output_file)
print('Done!')
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment