keras imagedatagenerator flow_from_dataframe:找到0个已验证的图像文件名属于0类
我正在处理存储为.npy文件的3D图像数据(128,128,128)。当我尝试使用keras imagedatagenerator
时,它会引发以下错误:
找到0个已验证的属于0 class的图像文件名
。
我的代码如下:
processed_data = r'C:/Users/dush/Desktop/Project/preprocessed'
from tensorflow.keras.preprocessing.image import ImageDataGenerator
img_size = 64
batch_size = 32
data_gen = ImageDataGenerator(horizontal_flip = True,
validation_split=0.2,
fill_mode = "nearest",
zoom_range = 0.3,
width_shift_range = 0.1,
height_shift_range = 0.1,
rotation_range = 30)
train_gen = data_gen.flow_from_dataframe(
dataframe = train,
directory = processed_data,
x_col = 'id',
y_col = 'category',
target_size=(img_size, img_size, img_size),
batch_size = batch_size,
class_mode="binary",
#validate_filenames=False,
subset='training', seed = 23) #image_generator.flow_from_dataframe
valid_gen = data_gen.flow_from_dataframe(
dataframe = train,
directory = processed_data,
x_col = 'id',
y_col = 'category',
target_size=(img_size, img_size, img_size),
#validate_filenames=False,
batch_size=batch_size,
class_mode="binary",
subset='validation', shuffle=False, seed=23)
如果我设置validate_filenames = false
,则标识文件名但在拟合模型时会出现错误。我在做什么错?
I am working on 3D image data stored as .npy files with shape (128,128,128). When I try to use Keras ImageDataGenerator
it throws the following error:
Found 0 validated image filenames belonging to 0 classes
.
My code is as follows:
processed_data = r'C:/Users/dush/Desktop/Project/preprocessed'
from tensorflow.keras.preprocessing.image import ImageDataGenerator
img_size = 64
batch_size = 32
data_gen = ImageDataGenerator(horizontal_flip = True,
validation_split=0.2,
fill_mode = "nearest",
zoom_range = 0.3,
width_shift_range = 0.1,
height_shift_range = 0.1,
rotation_range = 30)
train_gen = data_gen.flow_from_dataframe(
dataframe = train,
directory = processed_data,
x_col = 'id',
y_col = 'category',
target_size=(img_size, img_size, img_size),
batch_size = batch_size,
class_mode="binary",
#validate_filenames=False,
subset='training', seed = 23) #image_generator.flow_from_dataframe
valid_gen = data_gen.flow_from_dataframe(
dataframe = train,
directory = processed_data,
x_col = 'id',
y_col = 'category',
target_size=(img_size, img_size, img_size),
#validate_filenames=False,
batch_size=batch_size,
class_mode="binary",
subset='validation', shuffle=False, seed=23)
If I set validate_filenames=False
, then it identifies the filenames but get an error when fitting the model. What am I doing wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论