FER-2013 Facial Expression Dataset

fer_dataset(
  root = tempdir(),
  train = TRUE,
  transform = NULL,
  target_transform = NULL,
  download = FALSE
)

Arguments

root

(string, optional): Root directory for dataset storage, the dataset will be stored under root/fer2013.

train

(bool, optional): If True, creates dataset from training.pt, otherwise from test.pt.

transform

(callable, optional): A function/transform that takes in an PIL image and returns a transformed version. E.g, transform_random_crop().

target_transform

(callable, optional): A function/transform that takes in the target and transforms it.

download

(bool, optional): If true, downloads the dataset from the internet and puts it in root directory. If dataset is already downloaded, it is not downloaded again.

Value

A torch dataset of class fer_dataset. Each element is a named list:

  • x: a 48x48 grayscale array

  • y: an integer from 1 to 7 indicating the class index

Details

Loads the FER-2013 dataset for facial expression recognition. The dataset contains grayscale images (48x48) of human faces, each labeled with one of seven emotion categories: "Angry", "Disgust", "Fear", "Happy", "Sad", "Surprise", and "Neutral".

The dataset is split into:

  • "Train": training images labeled as "Training" in the original CSV.

  • "Test": includes both "PublicTest" and "PrivateTest" entries.

Examples

if (FALSE) { # \dontrun{
fer <- fer_dataset(train = TRUE, download = TRUE)
first_item <- fer[1]
first_item$x  # 48x48 grayscale array
first_item$y  # 4
fer$classes[first_item$y]  # "Happy"
} # }