Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/tensorflow/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/image-processing/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 3.x 如何为计算机视觉从csv文件生成tfrecord_Python 3.x_Tensorflow_Generative Adversarial Network_Tfrecord_Tf.data.dataset - Fatal编程技术网

Python 3.x 如何为计算机视觉从csv文件生成tfrecord

Python 3.x 如何为计算机视觉从csv文件生成tfrecord,python-3.x,tensorflow,generative-adversarial-network,tfrecord,tf.data.dataset,Python 3.x,Tensorflow,Generative Adversarial Network,Tfrecord,Tf.data.dataset,我想生成tfrecord,用于训练辅助分类器生成对抗网络。我的数据集CSV文件具有如下列标题: 输入图像、目标图像、标签 我尝试按照在中给出的说明生成tfrecord 我创建了解析图像和标签的函数: def image_example(inp, tar, label): inpS = tf.image.decode_jpeg(inp).shape tarS = tf.image.decode_jpeg(tar).shape feature1 = { 'height':

我想生成tfrecord,用于训练辅助分类器生成对抗网络。我的数据集CSV文件具有如下列标题:

输入图像、目标图像、标签

我尝试按照在中给出的说明生成tfrecord

我创建了解析图像和标签的函数:

def image_example(inp, tar, label):
  inpS = tf.image.decode_jpeg(inp).shape
  tarS = tf.image.decode_jpeg(tar).shape

  feature1 = {
      'height': _int64_feature(inpS[0]),
      'width': _int64_feature(inpS[1]),
      'depth': _int64_feature(inpS[2]),
      'label': _int64_feature(label),
      'image_raw': _bytes_feature(inp),
  }

  feature2 = {
      'height': _int64_feature(tarS[0]),
      'width': _int64_feature(tarS[1]),
      'depth': _int64_feature(tarS[2]),
      'image_raw': _bytes_feature(tar),
  }
  data = tf.train.Example(features=tf.train.Features(feature=(feature1, feature2)))

  return data
为了序列化我正在使用的数据:

record_file = './images.tfrecords'
with tf.io.TFRecordWriter(record_file) as writer:
  for img1, img2, label in zip(Afiles, Bfiles, labels):
    inp = open(pathA+img1, 'rb').read()
    tar = open(pathB+img2, 'rb').read()
    tf_example = image_example(inp, tar, label)
    writer.write(tf_example.SerializeToString())
但这是行不通的

如何为我的问题创建tfrecord

我应该为输入图像和目标图像使用不同的TFR记录吗