How to get the CK+ Dataset into a dataframe where one column is the image and the second column is the emotion (Is that even necessary?)


I want to build a model for emotion classification and tbh I am struggling with the dataset. I am using CK+ since I read it’d be on industry standard. I don’t know how to format it the right way so I can start working.
The Dataset is formatted in the following way.

Anger (Folder)

  • File 1
  • File 2

Contempt (Folder)

  • File 3
  • File 4

I need the foldernames as labels for the files inside of the folder but don’t really know how to get there.


You can load all your data in a using the tf.keras.utils.image_dataset_from_directory function. Assuming that your Anger and Contempt folders are located in a directory named Parent you can do like this:

import tensorflow as tf
dataset = tf.keras.utils.image_dataset_from_directory('Parent')

You can then access the images and labels directly from the Dataset, for example like this:

iterator = dataset.as_numpy_iterator()

Answered By – ClaudiaR

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published