Open obiii opened 4 years ago
I know this is a very old question on a defunct message board, but given that this still shows up in search results (and I was having a similar issue), the solution I found was to first turn my multiple columns in a new column in my dataframe that is a list or tuple itself.
dataframe['combined_classes'] = dataframe[('PFRType', 'FuelType')].apply(lambda x: x.tolist(), axis=1)
trainGen = ImageDataGenerator()
trainGenDf = trainGen.flow_from_dataframe(dataframe,
directory = '../MTLData/train/',
x_col = "Image",
y_col='combined_classes',
class_mode='sparse',
target_size=(224,224),
batch_size=32)
I'm sure you're not still working on this, but wanted to share my workaround anyways in case anyone else was looking for the answer like I was.
Hi,
i am trying to train a multi task CNN using flow_from_dataframe. The columns in dataframe are already in str format but the dtypes shows "Object" no matter what I use to convert them to string. Seems pandas uses object even for str now.
The dataframe has these columns:
And I get this error: If class_mode="sparse", y_col="['PFRType', 'FuelType']" column values must be strings.
here is the code for generator
I am using Keras Version: 2.3.1 Can someone please help?