标签:imp bsp mat images pen 文件路径 image otl 标签
import tensorflow as tf import os from matplotlib import pyplot as plt import numpy as np from sklearn.utils import shuffle import skimage.io as io def load_sample(sample_dir): lfilenames = [] labelsnames = [] for (dirpath, dirnames, filenames) in os.walk(sample_dir):#递归遍历文件夹 for filename in filenames: #遍历所有文件名 #print(dirnames) filename_path = os.sep.join([dirpath, filename]) img=io.imread(filename_path); lfilenames.append(img) #添加文件名 labelsnames.append( dirpath.split(‘\\‘)[-1] )#添加文件名对应的标签 return shuffle(lfilenames,labelsnames) data_dir = ‘F:\\python\\mnist_digits_images‘ #定义文件路径 image,label= load_sample(data_dir) #载入文件名称与标签
标签:imp bsp mat images pen 文件路径 image otl 标签
原文地址:https://www.cnblogs.com/hsy1941/p/12698747.html