Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Image Generator: Output array is read-only #839

Open
d-bohn opened this issue Jul 11, 2019 · 0 comments
Open

Image Generator: Output array is read-only #839

d-bohn opened this issue Jul 11, 2019 · 0 comments
Labels

Comments

@d-bohn
Copy link

@d-bohn d-bohn commented Jul 11, 2019

I'm getting an error trying to use an image generator.

library(keras)
x <- "test_image.png"
img <- image_load(x)

x <- image_to_array(img)

dim(x) <- c(1,dim(x))

gen_images <- image_data_generator(rescale = 1/255,
                                   preprocessing_function = imagenet_preprocess_input
)

images_iter <- flow_images_from_data (
  x=x, y=NULL,
  generator=gen_images,
  batch_size=1,
  save_to_dir=images_dir,
  save_prefix="aug",
  save_format="jpeg"
)

reticulate::iter_next(images_iter)

Results in the following error: Error in py_iter_next(it, completed) : ValueError: output array is read-only.

The same error occurs when I try to run imagenet_preprocess_input with a directory as input , e.g.,

train_datagen = image_data_generator(
  rescale = 1/255,
  horizontal_flip = TRUE,
  fill_mode = "nearest",
  preprocessing_function = imagenet_preprocess_input
)

train_generator <- flow_images_from_directory(
  "./train",                 
  train_datagen,            
  target_size = c(FLAGS$image_width,FLAGS$image_height),
  batch_size = batch_size,
  class_mode = "categorical",
  follow_links = TRUE
)

Session info:

sessionInfo()
R version 3.6.0 (2019-04-26)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Linux Mint 18.3

Matrix products: default
BLAS:   /usr/lib/libblas/libblas.so.3.6.0
LAPACK: /home/dan/anaconda/envs/r-tensorflow/lib/libmkl_rt.so

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C               LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8    LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C             LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] keras_2.2.4

loaded via a namespace (and not attached):
 [1] compiler_3.6.0         Matrix_1.2-17          magrittr_1.5           R6_2.3.0               generics_0.0.2        
 [6] tools_3.6.0            whisker_0.3-2          base64enc_0.1-3        Rcpp_1.0.1             reticulate_1.10.0.9003
[11] tensorflow_1.10        grid_3.6.0             zeallot_0.1.0          jsonlite_1.6           tfruns_1.4            
[16] lattice_0.20-38  
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants