我正在将ImageDataGenerator
与flow_from_directory一起用于分段任务。
文件夹的结构为:
> MyData/TrainImages/Train/image001.npy > MyData/TrainMasks/Train/image001.npy > MyData/ValImages/Val/image002.npy > MyData/ValMasks/Val/image002.npy
我跑步:
train_datagen = ImageDataGenerator(
#augmentation stuffs...)
val_datagen = ImageDataGenerator(
#ditto...)
train_image_generator = train_datagen.flow_from_directory(
'MyData/TrainImages/',
batch_size = BS)
train_mask_generator = train_datagen.flow_from_directory(
'MyData/TrainMasks/',
batch_size = BS)
val_image_generator = val_datagen.flow_from_directory(
'MyData/ValImages/',
batch_size = BS)
val_mask_generator = val_datagen.flow_from_directory(
'MyData/ValMasks/',
batch_size = BS)
train_generator = zip(train_image_generator, train_mask_generator)
val_generator = zip(val_image_generator, val_mask_generator)
但作为输出接收:
Found 0 images belonging to 1 classes. Found 0 images belonging to 1 classes. Found 0 images belonging to 1 classes. Found 0 images belonging to 1 classes.
我在Google周围搜索,但是大多数答案都指向文件夹结构,我认为我的说法是正确的。这是因为我的图像存储为numpy数组,而不是预期的格式(jpg,png等)吗?
答案 0 :(得分:1)
每个子目录目录树中的任何PNG,JPG,BMP,PPM或TIF图像都将包含在生成器中。
因此它将不会尝试加载.npy
文件。幸运的是,实现自己的数据生成器应该相对容易。只需获取目录中所有文件的列表,以随机顺序选择文件,将它们装入numpy,然后yield
即可。