tf_input.py 文件源码

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

项目:sparks 作者: ImpactHorizon 项目源码 文件源码
def read(filename_queue):
    class CAM17Record(object):
        pass

    result = CAM17Record()

    result.height = IMAGE_SIZE
    result.width = IMAGE_SIZE
    result.depth = CHANNELS

    reader = tf.TFRecordReader()
    result.key, value = reader.read(filename_queue)

    feature_map = {
        'image/encoded': tf.FixedLenFeature([], dtype=tf.string,
                                            default_value=''),
        'image/class/label': tf.FixedLenFeature([1], dtype=tf.int64,
                                                default_value=-1)
        }
    features = tf.parse_single_example(value, feature_map)
    result.label = tf.cast(features['image/class/label'], dtype=tf.int8)

    image_buffer = features['image/encoded']
    image = tf.image.decode_jpeg(image_buffer, channels=CHANNELS)

    depth_major = tf.reshape(image,
                                [result.width, result.height, result.depth])
    result.uint8image = tf.transpose(depth_major, [1, 0, 2])

    return result
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号