| fgvc_aircraft_dataset | R Documentation |
The FGVC-Aircraft dataset supports the following official splits:
"train": training subset with labels.
"val": validation subset with labels.
"trainval": combined training and validation set with labels.
"test": test set with labels (used for evaluation).
fgvc_aircraft_dataset(
root = tempdir(),
split = "train",
annotation_level = "variant",
transform = NULL,
target_transform = NULL,
download = FALSE
)
root |
Character. Root directory for dataset storage. The dataset will be stored under |
split |
Character. One of |
annotation_level |
Character. Level of annotation to use for classification. Default is |
transform |
Optional function to transform input images after loading. Default is |
target_transform |
Optional function to transform labels. Default is |
download |
Logical. Whether to download the dataset if not found locally. Default is |
The annotation_level determines the granularity of labels used for classification and supports four values:
"variant": the most fine-grained level, e.g., "Boeing 737-700". There are 100 visually distinguishable variants.
"family": a mid-level grouping, e.g., "Boeing 737", which includes multiple variants. There are 70 distinct families.
"manufacturer": the coarsest level, e.g., "Boeing", grouping multiple families under a single manufacturer. There are 30 manufacturers.
"all": multi-label format that returns all three levels as a vector of class indices c(manufacturer_idx, family_idx, variant_idx).
These levels form a strict hierarchy: each "manufacturer" consists of multiple "families", and each "family" contains several "variants".
Not all combinations of levels are valid — for example, a "variant" always belongs to exactly one "family", and a "family" to exactly one "manufacturer".
When annotation_level = "all" is used, the $classes field is a named list with three components:
classes$manufacturer: a character vector of manufacturer names
classes$family: a character vector of family names
classes$variant: a character vector of variant names
An object of class fgvc_aircraft_dataset, which behaves like a torch-style dataset.
Each element is a named list with:
x: an array of shape (H, W, C) with pixel values in the range (0, 255). Please note that images have varying sizes.
y: for single-level annotation ("variant", "family", "manufacturer"): an integer class label.
for multi-level annotation ("all"): a vector of three integers c(manufacturer_idx, family_idx, variant_idx).
Other classification_dataset:
caltech_dataset,
cifar10_dataset(),
eurosat_dataset(),
fer_dataset(),
flowers102_dataset(),
image_folder_dataset(),
lfw_dataset,
mnist_dataset(),
oxfordiiitpet_dataset(),
places365_dataset(),
tiny_imagenet_dataset(),
whoi_plankton_dataset(),
whoi_small_coralnet_dataset()
## Not run:
# Single-label classification
fgvc <- fgvc_aircraft_dataset(transform = transform_to_tensor, download = TRUE)
# Create a custom collate function to resize images and prepare batches
resize_collate_fn <- function(batch) {
xs <- lapply(batch, function(item) {
torchvision::transform_resize(item$x, c(768, 1024))
})
xs <- torch::torch_stack(xs)
ys <- torch::torch_tensor(sapply(batch, function(item) item$y), dtype = torch::torch_long())
list(x = xs, y = ys)
}
dl <- torch::dataloader(dataset = fgvc, batch_size = 2, collate_fn = resize_collate_fn)
batch <- dataloader_next(dataloader_make_iter(dl))
batch$x # batched image tensors with shape (2, 3, 768, 1024)
batch$y # class labels as integer tensor of shape 2
# Multi-label classification
fgvc <- fgvc_aircraft_dataset(split = "test", annotation_level = "all")
item <- fgvc[1]
item$x # a double vector representing the image
item$y # an integer vector of length 3: manufacturer, family, and variant indices
fgvc$classes$manufacturer[item$y[1]] # e.g., "Boeing"
fgvc$classes$family[item$y[2]] # e.g., "Boeing 707"
fgvc$classes$variant[item$y[3]] # e.g., "707-320"
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.