import numpy as np
import os
from scipy.misc import imread, imresize
import matplotlib.pyplot as plt
import pprint
cwd = os.getcwd()
def load_img_from_folder(path):
valid_exts = ['.jpg', '.png', '.jpeg', 'gif']
imgs = []
names = []
for f in os.listdir(path):
ext = os.path.splitext(f)[1]
if ext.lower() in valid_exts:
fullpath = os.path.join(path, f)
imgs.append(fullpath)
names.append(f)
return imgs, names
images,names = load_img_from_folder(cwd)
pprint.pprint(images)
pprint.pprint(names)
for img,name, i in zip(images, names, range(len(images))):
plt.figure(i)
plt.imshow(imread(images[i]))
plt.show()