I am trying to make a list containing all the images in my dataset. There will be 50000 elements in this list.
images = []
for cls in classes:
      samples_per_class = len(os.listdir(PATH_FOR_EACH_CLASS)
      for i in range(samples_per_class):
          image_path = os.path.join(
              directory,
              cls,
              str(i+1).zfill(4) + ".png"
          )
          images.append(image_path)
But I found it's very slow to set up this big list. Is there any more efficient way to deal with big list initialization?
 
     
     
    