I have two folders of hyperspectral data with five channels which are converted to numpy array. Each folder depicts the respective label.

Example :


I have used keras image generator to feed the data to input pipeline previously with png images.

train_ds = tf.keras.preprocessing.image_dataset_from_directory(
  image_size=(img_height, img_width),

But I am not sure how to achieve the same with numpy dataset. can anyone help?

  • $\begingroup$ Does this answer your question?: stackoverflow.com/questions/48889482/… $\endgroup$
    – Ben
    Sep 25, 2020 at 2:56
  • $\begingroup$ Hi, Thanks for the comment but it doesn't. I need a method in which I can feed a folder of data with a label ( which will be the folder name) like the above "from directory" method. Is there one such? $\endgroup$ Sep 29, 2020 at 9:25
  • $\begingroup$ Have you tried replacing (img_height, img_width) with (np_array_size,) ? Or Have you looked into this : towardsdatascience.com/… . This may be overkill if some out of the box option exists outhere, but implementing your own keras sequence generator allows you to customize as much as you want your data fetching process $\endgroup$
    – mprouveur
    Oct 1, 2020 at 10:24
  • $\begingroup$ with np_array_size, the problem is this generator only takes in specific image types such as jpg, png and bmp i guess.. There is no support for numpy. But i will have a look at the link you provided. Thanks $\endgroup$ Oct 2, 2020 at 8:09


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.