使用成像器对图像进行一些调整后如何在R Keras中加载图像

时间:2019-03-19 15:39:07

标签: python r image keras computer-vision

在使用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.

有人知道如何解决这个问题吗?

0 个答案:

没有答案