Caltech-101 Detection Dataset

caltech101_detection_dataset(
  root = tempdir(),
  transform = NULL,
  target_transform = NULL,
  download = FALSE
)

Arguments

root

Root directory where the dataset is stored or will be downloaded to.

transform

Optional transform function applied to the image.

target_transform

Optional transform function applied to the target (labels, boxes, etc.).

download

Logical. If TRUE, downloads and extracts the dataset if not already present in root.

Value

A torch dataset. Each item is a list with two elements:

x

A 3D torch_tensor of shape (3, H, W) representing the image in RGB format.

y

A list with:

boxes

A 2D torch_tensor of shape (1, 4) containing the bounding box in xywh format.

labels

A character scalar giving the class label for the image.

contour

A 2D torch_tensor of shape (N, 2) with the object contour coordinates.

Details

Loads the Caltech-101 dataset with image-level labels, bounding boxes, and object contours.

Examples

if (FALSE) { # \dontrun{
caltech101 <- caltech101_detection_dataset(download = TRUE)
first_item <- caltech101[1]

first_item$x <- torch_tensor(first_item$x, dtype = torch::torch_uint8())

# Draw bounding box
bboxes <- draw_bounding_boxes(
  image = first_item$x,
  boxes = first_item$y$boxes,
  labels = caltech101$classes[first_item$y$labels],
  colors = "red"
)
tensor_image_browse(bboxes)

# Draw contour points as keypoints
contour_points <- draw_keypoints(
  image = first_item$x,
  keypoints = first_item$y$contour,
  colors = "green",
  radius = 2
)
tensor_image_browse(contour_points)
} # }