在使用R中的image_load
软件包对图像进行一些调整之后,如何使用imager
函数将图像加载到Keras中?
library(keras)
library(imager)
img.url <- "https://s3.amazonaws.com/keras.io/img/keras-logo-2018-large-1200.png"
download.file(img.url,'logo.png', mode = 'wb')
img <- load.image("logo.png")
###############################
# Perform some adjustments to the image
###############################
save.image(img, "logo_adj.png")
img_height <- 100
img_width <- 100
img.keras <- keras::image_load(
'logo_adj.png',
target_size = c(img_height, img_width),
grayscale = FALSE
)
使用此脚本时,收到错误消息:
Error in py_call_impl(callable, dots$args, dots$keywords) :
ImportError: Could not import PIL.Image. The use of `array_to_img` requires PIL.
有人知道如何解决这个问题吗?