places365_dataset: Places365 Dataset

places365_datasetR Documentation

Places365 Dataset

Description

Loads the MIT Places365 dataset for scene classification.

Usage

places365_dataset(
  root = tempdir(),
  split = c("train", "val", "test"),
  transform = NULL,
  target_transform = NULL,
  download = FALSE,
  loader = magick_loader
)

places365_dataset_large(
  root = tempdir(),
  split = c("train", "val", "test"),
  transform = NULL,
  target_transform = NULL,
  download = FALSE,
  loader = magick_loader
)

Arguments

root

Root directory for dataset storage. The dataset will be stored under ⁠root/<dataset-name>⁠. Defaults to tempdir().

split

One of "train", "val", or "test".

transform

Optional. A function that takes an image and returns a transformed version (e.g., normalization, cropping).

target_transform

Optional. A function that transforms the label.

download

Logical. If TRUE, downloads the dataset to ⁠root/⁠. If the dataset is already present, download is skipped.

loader

A function to load an image given its path. Defaults to magick_loader(), which uses the {magick} package.

Details

The dataset provides three splits: "train", "val", and "test". Folder structure and image layout on disk are handled internally by the loader.

This function downloads and prepares the smaller 256x256 image version (~30 GB). For the high-resolution variant (~160 GB), use places365_dataset_large(). Note that images in the large version come in varying sizes, so resizing may be needed before batching.

The test split corresponds to the private evaluation set used in the Places365 challenge. Annotation files are not publicly released, so only the images are provided.

Value

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

  • x: the image as loaded (or transformed if transform is set).

  • y: the integer class label. For the test split, no labels are available and y will always be NA.

Functions

  • places365_dataset_large(): High resolution variant (~160 GB).

See Also

Other classification_dataset: caltech_dataset, cifar10_dataset(), eurosat_dataset(), fer_dataset(), fgvc_aircraft_dataset(), flowers102_dataset(), image_folder_dataset(), lfw_dataset, mnist_dataset(), oxfordiiitpet_dataset(), tiny_imagenet_dataset(), whoi_plankton_dataset(), whoi_small_coralnet_dataset()

Examples

## Not run: 
ds <- places365_dataset(
  split = "val",
  download = TRUE,
  transform = transform_to_tensor
)
item <- ds[1]
tensor_image_browse(item$x)

# Show class index and label
label_idx <- item$y
label_name <- ds$classes[label_idx]
cat("Label index:", label_idx, "Class name:", label_name, "\n")

dl <- dataloader(ds, batch_size = 2)
batch <- dataloader_next(dataloader_make_iter(dl))
batch$x

ds_large <- places365_dataset_large(
  split = "val",
  download = TRUE,
  transform = . %>% transform_to_tensor() %>% transform_resize(c(256, 256))
)
dl <- torch::dataloader(dataset = ds_large, batch_size = 2)
batch <- dataloader_next(dataloader_make_iter(dl))
batch$x

## End(Not run)


torchvision documentation built on Nov. 6, 2025, 9:07 a.m.