rkerascimg

Converting image/array list for keras input R


I intend to feed neural net with image data. Originally I have them stored as a list of arrays with dims 10,10,3 (height, length, color channel).

  1. Does anyone know how to convert the list containing multiple cimg images into one cimg storing multiple images in R?

and/or

  1. Does anyone know how to convert list of arrays with dims 10,10,3 into the object acceptable by keras?

Solution

  • You can use simplify2array, which takes a list and returns an array.

    my_images_arr <- simplify2array(my_list_of_cimg)
    

    there after, make your data labels. keras doesn't appear to require that your array object have a class attribute, just be in a consistent form, in this case an array of images.