def get_original_image(tfrecords_dir, is_training_data=False):
record = tf.python_io.tf_record_iterator(tfrecords_dir).next()
example = tf.train.Example()
example.ParseFromString(record)
shape = np.fromstring(example.features.feature['shape'].bytes_list.value[0], dtype=np.int32)
image = np.fromstring(example.features.feature['img_raw'].bytes_list.value[0], dtype=np.float32)
image = image.reshape(shape)
if is_training_data:
ground_truth = np.fromstring(example.features.feature['gt_raw'].bytes_list.value[0], dtype=np.uint8)
ground_truth = ground_truth.reshape(shape[:-1])
else:
ground_truth = None
return image, ground_truth
评论列表
文章目录