vision_make_grid: A simplified version of torchvision.utils.make_grid

View source: R/vision-utils.R

vision_make_gridR Documentation

A simplified version of torchvision.utils.make_grid

Description

Arranges images in a grid, with optional padding between images.

Usage

vision_make_grid(
  tensor,
  ...,
  scale = TRUE,
  per_row = 8,
  padding = 2,
  pad_value = 0,
  num_rows = NULL
)

## Default S3 method:
vision_make_grid(
  tensor,
  ...,
  scale = TRUE,
  per_row = 8,
  padding = 2,
  pad_value = 0,
  num_rows = NULL
)

## S3 method for class 'torch_tensor'
vision_make_grid(
  tensor,
  ...,
  scale = TRUE,
  per_row = 8,
  padding = 2,
  pad_value = 0,
  num_rows = NULL
)

## S3 method for class ''magick-image''
vision_make_grid(
  tensor,
  ...,
  scale = TRUE,
  per_row = 8,
  padding = 2,
  pad_value = 0,
  num_rows = NULL
)

Arguments

tensor

A 4D torch_tensor of shape (B x C x H x W), a 3D torch_tensor of shape (C x H x W), or a magick-image object.

...

Additional 3D torch_tensor objects (when first argument is a 3D tensor), or additional magick-image objects (when first argument is a magick-image).

scale

whether to normalize (min-max-scale) the input tensor. Only applied for torch_tensor input.

per_row

maximum number of images per row (i.e., number of columns); remaining images wrap to the next row. Default 8.

padding

amount of padding between images in pixels (default 2).

pad_value

pixel value (0–1) to use for padding background.

num_rows

Deprecated. Use per_row instead.

Details

For torch_tensor input, accepts either:

  • one or more 3D tensors of shape (C x H x W) passed as separate arguments, or

  • one or more 4D batch tensor of shape (B x C x H x W).

For magick-image input, arranges frames using magick::image_montage().

Positional grid options retain their original order: scale, num_rows, padding, pad_value. When passing additional images, name the grid options.

Value

a 3D torch_tensor of shape \approx(C , n\_rows \times H , per\_row \times W) and of dtype torch_float().

See Also

Other image display: draw_bounding_boxes(), draw_keypoints(), draw_segmentation_masks(), tensor_image_browse(), tensor_image_display()


torchvision documentation built on Oct. 14, 2026, 1:09 a.m.