十年网站开发经验 + 多家企业客户 + 靠谱的建站团队
量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决
如下所示:
成都创新互联公司提供高防主机、云服务器、香港服务器、雅安电信机房等# -*- coding: UTF-8 -*- import numpy as np import os from scipy.misc import imread, imresize import matplotlib.pyplot as plt from glob import glob # 读取目录下所有的jpg图片 def load_image(image_path, image_size): file_name=glob(image_path+"/*jpg") sample = [] for file in file_name: pic = imread(file).astype(np.float32) pic = imresize(pic, (image_size, image_size)).astype(np.float32) sample.append(pic) sample = np.array(sample) return sample if __name__=='__main__': samples=load_image("./images",150) # 显示第一张图片 pic=samples[:1,:,:,:] pic=np.reshape(pic,(150,150,3)).astype(np.uint8) plt.imshow(pic) plt.show()