【问题标题】:Obtaining paths from .tfrecords file in tensorflow从 tensorflow 中的 .tfrecords 文件获取路径
【发布时间】:2019-05-14 06:33:10
【问题描述】:

是否可以从 .tfrecord 文件中获取记录(数据项)的路径?例如,为了获取总记录数,我们可以使用tf.python_io.tf_record_iterator

例如 如果我有 100 张原始图像并将它们转换为 .tfrecords 格式。现在我可以将它们加载到我的 tensorflow 模型中以访问它们。有没有办法可以使用 .tfrecords 访问这些图像的磁盘(路径)位置?

【问题讨论】:

标签: tensorflow tfrecord


【解决方案1】:

当你从一批图像创建一个tfrecord文件时,这意味着这些图像中的数据以字节格式存储在tfrecord文件中。您可以将原始图像的路径存储到 tfrecord 文件中,例如:

def image_example(image_string, label, path):

    feature = {
        'label': _int64_feature(label),
        'image_raw': _bytes_feature(image_string),
        'path': _bytes_feature(path),
    }

    return tf.train.Example(features=tf.train.Features(feature=feature))

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-06-14
    • 2019-07-10
    • 1970-01-01
    • 1970-01-01
    • 2011-11-16
    • 2012-01-21
    • 2012-10-25
    相关资源
    最近更新 更多