The VGGFace2 dataset is a large-scale face recognition dataset containing images of celebrities from a wide range of ethnicities, professions, and ages. Each identity has multiple images with variations in context, pose, age, and illumination.

vggface2_dataset(
  root = tempdir(),
  split = "val",
  transform = NULL,
  target_transform = NULL,
  download = FALSE
)

Arguments

root

Character. Root directory where the dataset will be stored under root/vggface2.

split

One of "train", "val", or "test". Default is "val".

transform

Optional. A function that takes an image and returns a transformed version (e.g., normalization, cropping).

target_transform

Optional. A function that transforms the label.

download

Logical. If TRUE, downloads the dataset to root/. If the dataset is already present, download is skipped.

Value

A torch dataset object vggface2_dataset:

  • x: RGB image array.

  • y: Integer label (1…N) for the identity.

ds$classes is a named list mapping integer labels to a list with:

  • name: Character name of the person.

  • gender: "Male" or "Female".

Examples

if (FALSE) { # \dontrun{
#Load the training set
ds <- vggface2_dataset(download = TRUE)
item <- ds[1]
item$x      # image array RGB
item$y      # integer label
ds$classes[item$y]  # list(name=..., gender=...)

#Load the test set
ds <- vggface2_dataset(download = TRUE, train = FALSE)
item <- ds[1]
item$x      # image array RGB
item$y      # integer label
ds$classes[item$y]  # list(name=..., gender=...)
} # }