Python 使用tensorflow io'在tensorflow中加载tiff图像;s解码

Python 使用tensorflow io'在tensorflow中加载tiff图像;s解码,python,tensorflow,image-processing,Python,Tensorflow,Image Processing,我有一个tiff图像的数据集,我正在尝试使用tfio.experimental.image.decode_tiff从一个包含一列图像路径的数据帧加载图像,因为tensorflow目前不支持它 tensorflow版本:2.3.0 tensorflow io版本:0.15.0.dev20201015045556 list_ds = tf.data.Dataset.from_tensor_slices(df['image_path'].values) image_count = 86 val_si

我有一个tiff图像的数据集,我正在尝试使用tfio.experimental.image.decode_tiff从一个包含一列图像路径的数据帧加载图像,因为tensorflow目前不支持它

tensorflow版本:2.3.0

tensorflow io版本:0.15.0.dev20201015045556

list_ds = tf.data.Dataset.from_tensor_slices(df['image_path'].values)

image_count = 86
val_size = int(image_count * 0.2)
train_ds = list_ds.skip(val_size)
val_ds = list_ds.take(val_size)

def decode_img(img):

  img = tfio.experimental.image.decode_tiff(img, index=0, name=None)

  # resize the image to the desired size
  return tf.image.resize(img, [256, 256])


def process_path(file_path):

  # load the raw data from the file as a string
  img = tf.io.read_file(file_path)
  img = decode_img(img)

  return img

AUTOTUNE = tf.data.experimental.AUTOTUNE

# Set `num_parallel_calls` so multiple images are loaded/processed in parallel.
train_ds = train_ds.map(process_path, num_parallel_calls=AUTOTUNE)
val_ds = val_ds.map(process_path, num_parallel_calls=AUTOTUNE)
当我尝试运行以下代码以可视化图像时:


image_batch = next(iter(train_ds))

plt.figure(figsize=(2, 2))
for i in range(9):
  ax = plt.subplot(3, 3, i + 1)
  plt.imshow(image_batch[i].numpy().astype("uint8"))
  #label = label_batch[i]

plt.show()
第一行本身给出了以下错误:

Assertion failed: sizeof(tmsize_t)==sizeof(void*), file external/libtiff/libtiff/tif_open.c, line 99

Process finished with exit code -1073740791 (0xC0000409)
它在python控制台中无休止地运行

我研究了各种问题:

但没有找到解决办法


我想在tensorflow中加载图像只是为了利用tensorflow数据集API来提高性能,因为我的数据集相当大。因此,请告诉我是否有人对如何在tensorflow中加载tiff支持的图像有更好的了解。

您找到答案了吗?尝试将此
img=img[:,:,:-1]
添加到这行下方
img=tfio.experional.image.decode\tiff(img,index=0,name=None)
的decode\img函数中。您找到答案了吗?尝试添加此
img=img=img[:,:,:-1]
此行下方
img=tfio.experimental.image.decode\tiff(img,index=0,name=None)
在decode\img函数中。