How to inspect a Tensorflow .tfrecord file?
Found it!
import tensorflow as tf
for example in tf.python_io.tf_record_iterator("data/foobar.tfrecord"):
print(tf.train.Example.FromString(example))
You can also add:
from google.protobuf.json_format import MessageToJson
...
jsonMessage = MessageToJson(tf.train.Example.FromString(example))
Above solutions didn't work for me so for TF 2.0 use this:
import tensorflow as tf
raw_dataset = tf.data.TFRecordDataset("path-to-file")
for raw_record in raw_dataset.take(1):
example = tf.train.Example()
example.ParseFromString(raw_record.numpy())
print(example)
https://www.tensorflow.org/tutorials/load_data/tfrecord#reading_a_tfrecord_file_2