1import cv2
2import glob
3
4imdir = 'path/to/files/'
5ext = ['png', 'jpg', 'gif'] # Add image formats here
6
7files = []
8[files.extend(glob.glob(imdir + '*.' + e)) for e in ext]
9
10images = [cv2.imread(file) for file in files]
11
1import glob
2
3for filename in glob.iglob(root_dir + '**/*.jpg', recursive=True):
4 # Do something