Learn R Programming

torchvision (version 0.7.0)

flowers102_dataset: Oxford Flowers 102 Dataset

Description

Loads the Oxford 102 Category Flower Dataset. This dataset consists of 102 flower categories, with between 40 and 258 images per class. Images in this dataset are of variable sizes.

Usage

flowers102_dataset(
  root = tempdir(),
  split = "train",
  transform = NULL,
  target_transform = NULL,
  download = FALSE
)

Value

An object of class flowers102_dataset, which behaves like a torch dataset. Each element is a named list:

  • x: a W x H x 3 numeric array representing an RGB image.

  • y: an integer label indicating the class index.

Arguments

root

Root directory for dataset storage. The dataset will be stored under root/flowers102.

split

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

transform

Optional function to transform input images after loading. Default is NULL.

target_transform

Optional function to transform labels. Default is NULL.

download

Logical. Whether to download the dataset if not found locally. Default is FALSE.

Details

This is a classification dataset where the goal is to assign each image to one of the 102 flower categories.

The dataset is split into:

  • "train": training subset with labels.

  • "val": validation subset with labels.

  • "test": test subset with labels (used for evaluation).

See Also

Other classification_dataset: caltech_dataset, cifar10_dataset(), eurosat_dataset(), fer_dataset(), fgvc_aircraft_dataset(), mnist_dataset(), oxfordiiitpet_dataset(), tiny_imagenet_dataset()

Examples

Run this code
if (FALSE) {
# Load the dataset with inline transforms
flowers <- flowers102_dataset(
  split = "train",
  download = TRUE,
  transform = . %>% transform_to_tensor() %>% transform_resize(c(224, 224))
)

# Create a dataloader
dl <- dataloader(
  dataset = flowers,
  batch_size = 4
)

# Access a batch
batch <- dataloader_next(dataloader_make_iter(dl))
batch$x  # Tensor of shape (4, 3, 224, 224)
batch$y  # Tensor of shape (4,) with numeric class labels
}

Run the code above in your browser using DataLab