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
评论列表
文章目录