2 回答

TA貢獻(xiàn)2041條經(jīng)驗(yàn) 獲得超4個(gè)贊
我是Keras的新手,所以請(qǐng)服食我的鹽。我認(rèn)為您應(yīng)該使用Keras ImageDataGenerator,尤其是該flow_from_dataframe選項(xiàng),因?yàn)槟f您擁有Pandas數(shù)據(jù)框。Flow_from_dataframe讀取數(shù)據(jù)框的cols以獲取文件名和標(biāo)簽。
以下是一個(gè)示例片段。在網(wǎng)上查找教程。
train_datagen = ImageDataGenerator(horizontal_flip=True,
vertical_flip=False,
rescale=1/255.0)
train_generator = train_datagen.flow_from_dataframe(
dataframe=trainDataframe,
directory=imageDir,
x_col="file", # name of col in data frame that contains file names
y_col=y_col_list, # name of col with labels
has_ext=True,
batch_size=batch_size,
shuffle=True,
save_to_dir=saveDir,
target_size=(img_width,img_height),
color_mode='grayscale',
class_mode='categorical', # for classification task
interpolation='bilinear')
添加回答
舉報(bào)