示例#1
0
def parse_function(data, config):
    features = tf.parse_single_example(data,
                                       features={
                                           'image':
                                           tf.FixedLenFeature([], tf.string),
                                           'shape':
                                           tf.FixedLenFeature([], tf.string),
                                           'label':
                                           tf.FixedLenFeature([], tf.int64)
                                       })
    shape = tf.decode_raw(features['shape'], tf.int32)
    label = tf.cast(features['label'], tf.int64)
    shape = tf.reshape(shape, [3])
    images = tf.image.decode_jpeg(features['image'], channels=3)
    images = tf.cast(tf.reshape(images, shape), tf.float32)
    images = image_augmentor(image=images, input_shape=shape, **config)
    return images, label,  # shape
def parse_function(data, config):
    features = tf.parse_single_example(data,
                                       features={
                                           'image':
                                           tf.FixedLenFeature([], tf.string),
                                           'shape':
                                           tf.FixedLenFeature([], tf.string),
                                           'ground_truth':
                                           tf.FixedLenFeature([], tf.string)
                                       })
    shape = tf.decode_raw(features['shape'], tf.int32)
    ground_truth = tf.decode_raw(features['ground_truth'], tf.float32)
    shape = tf.reshape(shape, [3])
    ground_truth = tf.reshape(ground_truth, [-1, 5])
    images = tf.image.decode_jpeg(features['image'], channels=3)
    images = tf.cast(tf.reshape(images, shape), tf.float32)
    images, ground_truth = image_augmentor(image=images,
                                           input_shape=shape,
                                           ground_truth=ground_truth,
                                           **config)
    return images, ground_truth
示例#3
0
def parse_function(data, config):
    features = tf.io.parse_single_example(
        data,
        features={  # 产生一个实例
            'image': tf.io.FixedLenFeature([], tf.string),
            'shape': tf.io.FixedLenFeature([], tf.string),
            'ground_truth': tf.io.FixedLenFeature([], tf.string)
        })
    shape = tf.decode_raw(features['shape'],
                          tf.int32)  # tf.decode_raw:主要用于将原来编码为字符串的类型变回来
    ground_truth = tf.decode_raw(features['ground_truth'], tf.float32)
    shape = tf.reshape(shape, [3])
    ground_truth = tf.reshape(ground_truth, [-1, 5])  # 这个框的标注对应于5个内容
    images = tf.image.decode_jpeg(features['image'],
                                  channels=3)  # channel=3为RGB图片
    images = tf.cast(tf.reshape(images, shape), tf.float32)
    images, ground_truth = image_augmentor(image=images,
                                           input_shape=shape,
                                           ground_truth=ground_truth,
                                           **config)
    return images, ground_truth