how to load images from folder in python

import glob

for filename in glob.iglob(root_dir + '**/*.jpg', recursive=True):
    # Do something

Here is what the above code is Doing:
1. It’s creating a list of all the files in the root directory that end with .jpg
2. It’s iterating through the list of files
3. It’s printing the filename of each file

You can use this same code to iterate through any list of files.