I would like to load images from a folder , convert them to numpy arrays and then store them as dataframe rows. How should I proceed?
Here's what I came up with:
from keras.preprocessing.image import load_img
from keras.preprocessing.image import img_to_array
from keras.preprocessing.image import array_to_img
BASE_DIR = '/kaggle/input/coughspectrograms/content/'
os.chdir('/kaggle/input/coughspectrograms/content/')
files_in_train = sorted(os.listdir(BASE_DIR))
files_in_train.pop(0)
img_df = pd.DataFrame()
for img in files_in_train:
loaded_img = load_img(img)
img_array = img_to_array(loaded_img)
img_df = pd.DataFrame({"image": [img_array]})