if (FALSE) {
# Load the Oxford-IIIT Pet dataset with basic tensor transform
oxfordiiitpet <- oxfordiiitpet_segmentation_dataset(
transform = transform_to_tensor,
download = TRUE
)
# Retrieve the image tensor, segmentation mask and label
first_item <- oxfordiiitpet[1]
first_item$x # RGB image tensor of shape (3, H, W)
first_item$y$masks # (3, H, W) bool tensor: pet, background, outline
first_item$y$label # Integer label (1–37 or 1–2 depending on target_type)
oxfordiiitpet$classes[first_item$y$label] # Class name of the label
# Visualize
overlay <- draw_segmentation_masks(first_item)
tensor_image_browse(overlay)
}
Run the code above in your browser using DataLab