Loads one of the underwater related RoboFlow 100 Environmental datasets: "pipes", "aquarium", "objects", or "coral". Images are provided with bounding box annotations for object-detection task.

rf100_underwater_collection(
  dataset,
  split = c("train", "test", "valid"),
  transform = NULL,
  target_transform = NULL,
  item_transform = NULL,
  download = FALSE
)

Arguments

dataset

Dataset to select within c("pipes", "aquarium", "objects", "coral").

split

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

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().

download

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

Value

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

  • x: H x W x 3 array representing the image, auto-oriented and stretched to 640 x 640.

  • y: a list containing the target with:

    • image_id: numeric identifier of the x image.

    • labels: numeric identifier of the N bounding-box object class.

    • boxes: a torch_tensor of shape (N, 4) with bounding boxes, each in \((x_{min}, y_{min}, x_{max}, y_{max})\) format.

The returned item inherits the class image_with_bounding_box so it can be visualised with helper functions such as draw_bounding_boxes(), and its y inherits object_detection_target, which target transforms such as target_transform_rotate() dispatch on. The collection itself inherits object_detection_dataset.

Examples

if (FALSE) { # \dontrun{
ds <- rf100_underwater_collection(
  dataset = "aquarium",
  split = "train",
  transform = transform_to_tensor,
  download = TRUE
)

item <- ds[24]
# map label ids into their class names
item$y$labels <- ds$classes[item$y$labels]
boxed <- draw_bounding_boxes(item)
tensor_image_browse(boxed)
} # }