Skip to content

Instantly share code, notes, and snippets.

@evanlouie
Created September 12, 2018 21:16
Show Gist options
  • Save evanlouie/214dc436a76e79213c130788a3f573ef to your computer and use it in GitHub Desktop.
Save evanlouie/214dc436a76e79213c130788a3f573ef to your computer and use it in GitHub Desktop.
Print a target TFRecord file
import argparse
import tensorflow as tf
parser = argparse.ArgumentParser()
parser.add_argument("--example", help="target TFRecord Example file")
parser.add_argument("--sequence_example",
help="target TFRecord SequenceExample file")
args = parser.parse_args()
if args.sequence_example:
for record in tf.python_io.tf_record_iterator(args.sequence_example):
result = tf.train.SequenceExample.FromString(record)
print(result)
elif args.example:
for record in tf.python_io.tf_record_iterator(args.example):
result = tf.train.Example.FromString(record)
print(result)
else:
print('No valid options provided')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment