Loads the Roboflow 100 "peixos" dataset for semantic segmentation. "peixos" contains 3 splits of respectively 821 / 118 / 251 color images of size 640 x 640. Segmentation masks are generated on-the-fly from polygon annotations of the unique "fish" category.

rf100_peixos_segmentation_dataset(
  split = c("train", "test", "valid"),
  root = tempdir(),
  download = FALSE,
  transform = NULL,
  target_transform = NULL,
  item_transform = NULL
)

Arguments

split

the subset of the dataset to choose between c("train", "test", "valid").

root

directory path to download the dataset.

download

Logical. If TRUE, downloads the dataset if not present at root.

transform

Optional transform function applied to the image.

target_transform

Optional transform function applied to the target.

item_transform

Optional transform function applied to the whole item, such as item_transform_rotate(), once transform and target_transform have been applied. It is only used by .getitem(), not by the batched .getbatch().

Value

A torch dataset. Each element is a named list with:

  • x: H × W × 3 array (use transform_to_tensor() in transform to get C × H × W tensor).

  • y: a list with:

    • masks: boolean tensor of shape (1, H, W).

    • labels: integer vector with the class index (always 1 for "fish").

The returned item is given class image_with_segmentation_mask so it can be visualised with helpers like draw_segmentation_masks(), and its y is given class segmentation_target, which target transforms dispatch on. The dataset itself inherits segmentation_dataset.

Examples

if (FALSE) { # \dontrun{
ds <- rf100_peixos_segmentation_dataset(
  split = "train",
  transform = transform_to_tensor,
  download = TRUE
)
item <- ds[1]
overlay <- draw_segmentation_masks(item)
tensor_image_browse(overlay)
} # }