python load all images from folder code example
Example 1: python get all images in directory
import glob
for filename in glob.iglob(root_dir + '**/*.jpg', recursive=True):
Example 2: get all type of image in folder python
import cv2
import glob
imdir = 'path/to/files/'
ext = ['png', 'jpg', 'gif']
files = []
[files.extend(glob.glob(imdir + '*.' + e)) for e in ext]
images = [cv2.imread(file) for file in files]
Example 3: getting image from path python
from PIL import Image
import glob
image_list = []
for filename in glob.glob('yourpath/*.gif'):
im=Image.open(filename)
image_list.append(im)