Local image + y values from pkl file

HI,
I have a directory (dataset) that contains sub directory (each one contains 40 images), the name of sub directory is referring to a 5 float values that can be taken from a pkl file, the pkl file is a dictionary like this:
{“label1”: {“sub_folder_name1”: 0.2535}, {“sub_folder_name2”: 0.2535}, {“sub_folder_name3”: 0.2535},
“label2”: {“sub_folder_name1”: 0.4004}, {“sub_folder_name2”: 0.2535}, {“sub_folder_name3”: 0.2535}}

for example for the name sub_folder_1 the y value will be [0.2535, 0.4004]
and so on

features = images
labels = y values ( float )
it s a kind of regression task, not classification.

How to load all images in a dataset with their correspending y values from pkl file?
Thank you

1 Like

Hi @youb, For creating dataset with the images present in the sub directories with labels present in the pkl file, you have iterate through the dataset and convert those images to array and store all the image array of one sub directory and get the labels from the pkl file for that corresponding sub directory. after collecting all the images array from sub directories and labels from pkl file you can create a dataset method or you can rename the sub directories with the label and can use the
keras.utils.image_dataset_from_directory to create the dataset. Thank You.