| coco_detection_dataset | R Documentation |
Loads the MS COCO dataset for object detection tasks only.
coco_detection_dataset(
root = tempdir(),
train = TRUE,
year = c("2017", "2014"),
download = FALSE,
transform = NULL,
target_transform = NULL,
item_transform = NULL
)
root |
Root directory where the dataset is stored or will be downloaded to. |
train |
Logical. If TRUE, loads the training split; otherwise, loads the validation split. |
year |
Character. Dataset version year. One of |
download |
Logical. If TRUE, downloads the dataset if it's not already present in the |
transform |
Optional transform function applied to the image. |
target_transform |
Optional transform function applied to the target (labels, boxes, etc.). |
item_transform |
Optional transform function applied to the whole item, such as
|
The returned image x is in CHW format (channels, height, width), matching the torch convention.
The dataset y offers object detection annotations such as bounding boxes, labels,
areas, and crowd indicators from the official COCO annotations.
Files are downloaded to a coco subdirectory in the torch cache directory for better organization.
An object of class coco_detection_dataset. Each item is a list:
x: a (C, H, W) array representing the image.
y$boxes: a (N, 4) torch_tensor of bounding boxes in the format (x_{min}, y_{min}, x_{max}, y_{max}).
y$labels: an integer torch_tensor with the class label for each object.
y$area: a float torch_tensor indicating the area of each object.
y$iscrowd: a boolean torch_tensor, where TRUE marks the object as part of a crowd.
The returned object has S3 class "image_with_bounding_box"
to enable automatic dispatch by visualization functions such as draw_bounding_boxes(),
and its y has S3 class "object_detection_target" so that target transforms
such as target_transform_rotate() dispatch on it. The dataset itself
inherits "object_detection_dataset".
For instance segmentation tasks, use coco_segmentation_dataset instead.
coco_segmentation_dataset for instance segmentation tasks
Other detection_dataset:
pascal_voc_datasets,
rf100_biology_collection(),
rf100_damage_collection(),
rf100_document_collection(),
rf100_infrared_collection(),
rf100_medical_collection(),
rf100_underwater_collection()
## Not run:
# Load dataset for object detection
ds <- coco_detection_dataset(
train = FALSE,
year = "2017",
download = TRUE
)
item <- ds[1]
# Visualize bounding boxes
boxed <- draw_bounding_boxes(item)
tensor_image_browse(boxed)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.