How can I read the images arranged from subfolders using flow_from_dataframe function not flow_from_directory function in Keras? Here is the dataset directory structure arrangement of the dataset with subfolders and CSV file with labels "classes" and image ids I used in the code with output.`
from tensorflow.keras.preprocessing.image import ImageDataGenerator
import pandas as pd
def append_ext(fn):
return fn+".png"
traindf=pd.read_csv("trainLabels.csv",dtype=str)
print(traindf)
traindf["id"]=traindf["id"].apply(append_ext)
print(traindf)
datagen=ImageDataGenerator(rescale=1./255.,validation_split=0.25)
train_generator=datagen.flow_from_dataframe(
dataframe=traindf,
directory="./testdf/",
x_col="id",
y_col="label",
subset="training",
batch_size=32,
seed=42,
shuffle=True,
classes = ["animal_1", "animal_2"],
class_mode="categorical",
target_size=(32,32))
valid_generator=datagen.flow_from_dataframe(
dataframe=traindf,
directory="./testdf/",
x_col="id",
y_col="label",
subset="validation",
batch_size=32,
seed=42,
shuffle=True,
classes = ["animal_1", "animal_2"],
class_mode="categorical",
target_size=(32,32))`.
Found 0 validated image filenames belonging to 2 classes.
Found 0 validated image filenames belonging to 2 classes.
Thanks!