【发布时间】:2020-05-20 15:58:55
【问题描述】:
我正在尝试通过this 链接读取分割问题(1 类)的图像数据集。我的主文件夹包含两个文件夹,即 (a) img (b) mask。 img 包含图像样本,mask 包含相应的掩码。我的方法是,生成图像的路径,然后更改字符串路径(即 img->mask)。我修改了here 提供的代码,现在看起来如下:
def process_path(file_path):
file_path_str = str(file_path)
file_path_mask = file_path_str.replace('img', 'mask')
# load the raw data from the file as a string
img = tf.io.read_file(file_path)
img = decode_img(img)
mask = tf.io.read_file(str(file_path_mask))
mask = decode_mask(mask)
return img, mask
但是,当我尝试使用以下方法查看样本大小时:
for image, mask in labeled_ds.take(1):
print("Image shape: ", image.numpy().shape)
print("Mask shape: ", mask.numpy().shape)
我收到以下错误:
InvalidArgumentError: NewRandomAccessFile failed to Create/Open: Tensor("arg0:0", shape=(), dtype=string) : The filename, directory name, or volume label syntax is incorrect.
; Unknown error
[[{{node ReadFile_1}}]] [Op:IteratorGetNextSync]
问题:关于如何从给定文件夹中读取图像和掩码而不会出现上述错误的任何建议?
【问题讨论】:
标签: tensorflow tensorflow-datasets