diff --git a/R/dataset-pascal.R b/R/dataset-pascal.R index f7c0b4dc..310f4872 100644 --- a/R/dataset-pascal.R +++ b/R/dataset-pascal.R @@ -11,6 +11,16 @@ #' The dataset defines 21 semantic classes: `"background"`, `"aeroplane"`, `"bicycle"`, `"bird"`, `"boat"`, `"bottle"`, `"bus"`, `"car"`, `"cat"`, `"chair"`, #' `"cow"`, `"dining table"`, `"dog"`, `"horse"`, `"motorbike"`, `"person"`, `"potted plant"`, `"sheep"`, `"sofa"`, `"train"`, and `"tv/monitor"`. #' They are available through the `classes` variable of the dataset object. +#' @export +pascal_voc_classes <- function() { + c( + "background", "aeroplane", "bicycle", "bird", "boat", "bottle", + "bus", "car", "cat", "chair", "cow", "dining table", "dog", "horse", + "motorbike", "person", "potted plant", "sheep", "sofa", "train", "tv/monitor" + ) +} +#' @export +voc_classes <- pascal_voc_classes #' #' This dataset is frequently used for training and evaluating semantic segmentation models, and supports tasks requiring dense, per-pixel annotations. #' @@ -96,12 +106,7 @@ pascal_segmentation_dataset <- torch::dataset( "6cd6e144f989b92b3379bac3b3de84fd"), size = c("440 MB", "440 MB", "550 MB", "890 MB", "1.3 GB", "1.7 GB", "1.9 GB") ), - classes = c( - "background", "aeroplane", "bicycle", "bird", "boat", - "bottle", "bus", "car", "cat", "chair", - "cow", "dining table", "dog", "horse", "motorbike", - "person", "potted plant", "sheep", "sofa", "train", - "tv/monitor" + classes = pascal_voc_classes() ), voc_colormap = c( c(0, 0, 0), c(128, 0, 0), c(0, 128, 0), c(128, 128, 0), diff --git a/R/models-deeplabv3.R b/R/models-deeplabv3.R index 6a394843..bfc3a022 100644 --- a/R/models-deeplabv3.R +++ b/R/models-deeplabv3.R @@ -98,24 +98,24 @@ deeplabv3_model_urls <- list( #' @return A character vector with the PASCAL VOC class names #' @family class_resolution #' @export -voc_classes <- c( +pascal_voc_classes <- c( "background", "aeroplane", "bicycle", "bird", "boat", "bottle", "bus", "car", "cat", "chair", "cow", "dining table", "dog", "horse", "motorbike", "person", "potted plant", "sheep", "sofa", "train", "tv/monitor" ) -#' @rdname voc_classes +#' @rdname pascal_voc_classes #' @param id Integer vector of 1-based class identifiers. #' @return A character vector with the labels associated with `id`. #' @family class_resolution #' @export voc_label <- function(id) { - voc_classes[id] + pascal_voc_classes[id] } deeplabv3_meta <- list( - classes = voc_classes, - class_to_idx = setNames(seq_along(voc_classes) - 1, voc_classes) + classes = pascal_voc_classes(), + class_to_idx = setNames(seq_along(pascal_voc_classes()) - 1, pascal_voc_classes()) )