Filipa Almeida Filipa Almeida - 7 months ago 35
Python Question

How to load all images in folder by its name using python?

I have a folder with 50000 images named as

I want to load each image and then used them to something. Here, that's the code I'm using (load just first 14 images):

for m in range(0,15):

count = m + 1

im = + 'ILSVRC2012_val_000' + str(count).zfill(5) + '.JPEG')

The error is

No such file or directory: ILSVRC2012_val_00000010.JPEG

Any idea how to solve it?


I'd use glob.glob.

from glob import glob

for path in sorted(glob(IMAGE_PATH_FOLDER + "ILSVRC2012_val_*.JPEG")):
    im =