微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

如何将 TFRecordDataset 项目转换为图像?

如何解决如何将 TFRecordDataset 项目转换为图像?

我在将 tfrecords 转换回图像时遇到问题:

def _parse_test_image_function(img):
    image_feature_description = {
        'image/file_name': tf.io.FixedLenFeature([],tf.string),'image/encoded_image': tf.io.FixedLenFeature([],}
    return tf.io.parse_single_example(img,image_feature_description)

test_dataset = tf.data.TFRecordDataset(temp_path)
test_dataset = test_dataset.map(_parse_test_image_function)

print(tf.__version__)
images = test_dataset.take(1)
print(images)

2.5.0
<TakeDataset shapes: {image/encoded_image: (),image/file_name: ()},types: {image/encoded_image: tf.string,image/file_name: tf.string}>

image_feature_description 中的字段正确

我也看到了 Converting TFRecords back into JPEG Images 但这对我来说不是很有帮助,因为答案中使用的一些功能已经过时。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。