read_tfrecord.py 文件源码

python
阅读 40 收藏 0 点赞 0 评论 0

项目:tf-sr-zoo 作者: MLJejuCamp2017 项目源码 文件源码
def read_and_decode(filename_queue, batch_size):
    reader = tf.TFRecordReader()
    _, serialized_example = reader.read(filename_queue)
    feature = features()
    feature = tf.parse_single_example(
        serialized_example,
        features = feature,
        )
    hr_image = tf.decode_raw(feature['hr_image'], tf.uint8)
    height = tf.cast(feature['height'], tf.int32)
    width = tf.cast(feature['width'], tf.int32)
    print(height)
    image_shape = tf.stack([128, 128,3 ])
    hr_image = tf.reshape(hr_image, image_shape)
    hr_image = tf.image.random_flip_left_right(hr_image)
    hr_image = tf.image.random_contrast(hr_image, 0.5, 1.3)
    hr_images = tf.train.shuffle_batch([hr_image], batch_size = batch_size, capacity = 30,
                                      num_threads = 2,
                                        min_after_dequeue = 10)
    return hr_images
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号