How do I turn images dataset into a numpy array? I have a directory for a dataset of images, I I want to transorm it to a numpy array in order to be able to fit an image generator to it. What I have tried to do is the following:

trainingset_temp = '/content/drive/My Drive/Colab Notebooks/Train'
testset = '/content/drive/My Drive/Colab Notebooks/Test'

import cv2
import glob

trainingset = []
files = glob.glob ('/content/drive/My Drive/Colab Notebooks/Train/Haze') # your 
image path
for myFile in files:
    image = cv2.imread (myFile)
    trainingset.append (image)

files = glob.glob ('/content/drive/My Drive/Colab Notebooks/Train/Sunny')
for myFile in files:
    image = cv2.imread (myFile)
    trainingset.append (image)

files = glob.glob ('/content/drive/My Drive/Colab Notebooks/Train/Snowy')
for myFile in files:
    image = cv2.imread (myFile)
    trainingset.append (image)

files = glob.glob ('/content/drive/My Drive/Colab Notebooks/Train/Rainy')
for myFile in files:
    image = cv2.imread (myFile)
    trainingset.append (image)

trainingset = np.array(trainingset,dtype='float32')


but it gives me the following error message:

FileNotFoundError                         Traceback (most recent call last)
&lt;ipython-input-44-2a679dbff06e&gt; in &lt;module&gt;()
     54     batch_size=batch_size,
     55     class_mode="categorical",
---&gt; 56     shuffle=True
     57 )
     58 

1 frames
/usr/local/lib/python3.6/dist- 
packages/keras_preprocessing/image/directory_iterator.py in __init__(self, 
directory, image_data_generator, target_size, color_mode, classes, 
class_mode, batch_size, shuffle, seed, data_format, save_to_dir, 
save_prefix, save_format, follow_links, subset, interpolation, dtype)
    104         if not classes:
    105             classes = []
--&gt; 106             for subdir in sorted(os.listdir(directory)):
    107                 if os.path.isdir(os.path.join(directory, subdir)):
    108                     classes.append(subdir)

FileNotFoundError: [Errno 2] No such file or directory: array([], 
dtype=float32)


Can someone help me? Thanks in advance.
You encounter a FileNotFoundError, which means that a file can not be found.
I suspect that you forgot the filename extension of your image. Should '/content/drive/My Drive/Colab Notebooks/Train/Haze' not be something like '/content/drive/My Drive/Colab Notebooks/Train/Haze.png' or '/content/drive/My Drive/Colab Notebooks/Train/Haze.jpg'