vggface2_dataset: VGGFace2 Dataset

vggface2_datasetR Documentation

VGGFace2 Dataset

Description

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.

Usage

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".

See Also

Other classification_dataset: caltech_dataset, cifar10_dataset(), eurosat_dataset(), fer_dataset(), fgvc_aircraft_dataset(), flowers102_dataset(), image_folder_dataset(), lfw_dataset, mnist_dataset(), oxfordiiitpet_dataset(), places365_dataset(), tiny_imagenet_dataset(), whoi_plankton_dataset(), whoi_small_coralnet_dataset()

Examples

## Not run: 
#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=...)

## End(Not run)


torchvision documentation built on Oct. 14, 2026, 1:09 a.m.