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.
flowers102_dataset(
root = tempdir(),
split = "train",
transform = NULL,
target_transform = NULL,
download = FALSE
)
Root directory for dataset storage. The dataset will be stored under root/flowers102
.
One of "train"
, "val"
, or "test"
. Default is "train"
.
Optional function to transform input images after loading. Default is NULL
.
Optional function to transform labels. Default is NULL
.
Logical. Whether to download the dataset if not found locally. Default is FALSE
.
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.
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).
Other classification_dataset:
caltech_dataset
,
cifar10_dataset()
,
eurosat_dataset()
,
fer_dataset()
,
fgvc_aircraft_dataset()
,
mnist_dataset()
,
oxfordiiitpet_dataset()
,
tiny_imagenet_dataset()
if (FALSE) { # \dontrun{
# 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
} # }