读取图片列表——CNN输入
image_list = [] new_file_list = [] for root, _, file_list in os.walk(predict_dir): new_file_list += [file for file in file_list if ".nfs" not in file] new_file_list.sort(key= lambda x:int(x[:-4])) for file in new_file_list: # print (new_file_list) image = os.path.join(root, file) temp_image = Image.open(image).convert('L') temp_image = temp_image.resize((64, 64), Image.ANTIALIAS) temp_image = np.asarray(temp_image) / 255.0 image_list.append(temp_image) image_list = np.asarray(image_list) temp_image = image_list.reshape([len(new_file_list), 64, 64, 1])