0
$\begingroup$

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

Example :

dataset  
----good_data  
      ----good_image_01.npy  
      ----good_image_02.npy  
----bad_data  
    ----bad_image_01.npy  
    ----bad_image_02.npy

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(
  data_dir,
  validation_split=0.2,
  subset="training",
  seed=123,
  image_size=(img_height, img_width),
  batch_size=batch_size)

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

$\endgroup$
4
  • $\begingroup$ Does this answer your question?: stackoverflow.com/questions/48889482/… $\endgroup$
    – Ben
    Commented 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$ Commented 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
    Commented 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$ Commented Oct 2, 2020 at 8:09

0

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.