小编Llu*_*s C的帖子

Keras image_dataset_from_directory 未找到图像

我想从我有大约 5000 张图像的目录中加载数据(类型“png”)。但是它返回一个错误,说当明显有图像时没有图像。这段代码:

width=int(wb-wa)
height=int(hb-ha)
directory = '/content/drive/My Drive/Colab Notebooks/Hair/Images'
train_ds = tf.keras.preprocessing.image_dataset_from_directory(
    directory, labels=densitat, label_mode='int',
    color_mode='rgb', batch_size=32, image_size=(width, height), shuffle=True, seed=1,
    validation_split=0.2, subset='training', follow_links = False)
Run Code Online (Sandbox Code Playgroud)

返回:

ValueError: Expected the lengths of `labels` to match the number of files in the target directory. len(labels) is 5588 while we found 0 files in /content/drive/My Drive/Colab Notebooks/Hair/Images.
Run Code Online (Sandbox Code Playgroud)

我可以看到图像: 带有图像的文件夹结构的 Colab 视图

问题出在哪儿?我需要使用这个函数来批量加载数据,因为我有一个大数据集

keras tensorflow image-preprocessing tensorflow-datasets

5
推荐指数
2
解决办法
2478
查看次数