Skip to contents

This function uses the torchvision package to read and transform the image in a torch tensor. The function tries to adjust the dimensions to deal with black and white or colored images.

Usage

captcha_transform_image(x, input_dim = c(32L, 192L))

Arguments

x

character vector with the paths to image files.

input_dim

resize image to dimension. Defaults to 32x192, which is a good default for many Captcha applications.

Value

torch tensor with dimensions length(x)x3xinput_dim.

Examples


if (torch::torch_is_installed()) {
  captcha_file <- fs::dir_ls(
    system.file("examples/captcha/", package = "captcha"
  ))
  result <- captcha_transform_image(captcha_file)
  class(result)
  dim(result)
}