tensorflowroboflow

Difference between .record and .tfrecord


I've downloaded a dataset from https://public.roboflow.com/ which contains test.tfrecord and train.tfrecord

Is it the same than test.record and train.record?


Solution

  • Yes, the file extension doesn't matter, they're in the TFRecord format. You can think of it a bit like a zip file though in that its structure can be freeform.

    These specific ones are for use with the Tensorflow Object Detection API which expects the data inside the tfrecord to be laid out in a specific structure and order like this:

    tf_example = tf.train.Example(features=tf.train.Features(feature={
            'image/height': dataset_util.int64_feature(height),
            'image/width': dataset_util.int64_feature(width),
            'image/filename': dataset_util.bytes_feature(filename),
            'image/source_id': dataset_util.bytes_feature(filename),
            'image/encoded': dataset_util.bytes_feature(encoded_jpg),
            'image/format': dataset_util.bytes_feature(image_format),
            'image/object/bbox/xmin': dataset_util.float_list_feature(xmins),
            'image/object/bbox/xmax': dataset_util.float_list_feature(xmaxs),
            'image/object/bbox/ymin': dataset_util.float_list_feature(ymins),
            'image/object/bbox/ymax': dataset_util.float_list_feature(ymaxs),
            'image/object/class/text': dataset_util.bytes_list_feature(classes_text),
            'image/object/class/label': dataset_util.int64_list_feature(classes),
        }))
    

    There's a full tutorial on how to train with the Tensorflow 2.0 Object Detection API here.