def _read_pngs_from(path):
"""Reads directory of images.
Args:
path: path to the directory
Returns:
A list of all images in the directory in the TF format (You need to call sess.run() or .eval() to get the value).
"""
images = []
png_files_path = glob.glob(os.path.join(path, '*.[pP][nN][gG]'))
for filename in png_files_path:
im = Image.open(filename)
im = np.asarray(im, np.uint8)
# get only images name, not path
image_name = filename.split('/')[-1].split('.')[0]
images.append([int(image_name), im])
images = sorted(images, key=lambda image: image[0])
images_only = [np.asarray(image[1], np.uint8) for image in images] # Use unint8 or you will be !!!
images_only = np.array(images_only)
#print(images_only.shape)
return images_only
评论列表
文章目录