Can I flow_from_dataframe if my labels are also filepaths?

Viewed 38

I am trying to train an image reconstruction network, that I would train like this:

vae.fit(X_train, X_train, epochs=10, batch_size=1)

where X_train is a NumPy array of the training images.

However, I want to use a generator because otherwise, I run out of memory. I have tried to use flow_from_dataframe, where I have all the file paths of the images stored (they are across multiple folders).

train_generator=datagen.flow_from_dataframe(
                                   dataframe=df,
                                   x_col="filepath",
                                   y_col="filepath")

The issue is this function inputs x_col (file path) and y_col(label). Since my loss function is based on reconstruction error, my label should be the same image itself. Is there a way to do this with this function or with another kind of generator?

1 Answers

For autoencoders, you can set class_mode=input, and then you don't have to set y_col.

So try this:

train_generator=datagen.flow_from_dataframe(
                                   dataframe=df,
                                   x_col="filepath",
                                   class_mode="input")
Related