def train_load(): path = 'data/train' Dir = listdir(path) imagelist = [] ListOfName = [] count = 0 for directory in Dir: if directory != '.DS_Store': #For some reason this directory keep bumping up subpath = listdir(path + '/' + directory) ListOfName.append(directory) print(directory) count = count + 1 for subdir in subpath: if subdir != '.DS_Store': Image = image(path + '/' + directory + '/' + subdir, count) Image = Image.get_feature(reshape = True) #Image = Image.getGaborFeatures(reshape = True) output = count - 1 # output = numpy.zeros((121,1)) # output[count -1] = numpy.float64(1) imagelist.append([Image, output]) #we need to randomly shuffle the data to retain the generality shuffle(imagelist) with open('pickle/ListOfName.pkl','w') as f: pickle.dump(ListOfName,f) print('got image list for train') return imagelist, count
def test_load(): path = 'data/test' Dir = listdir(path) imagelist = [] ListOfName = [] for directory in Dir: if directory != '.DS_Store': #For some reason this directory keep bumping up ListOfName.append(directory) Image = image(path + '/' + directory, 1000) #assign a random class to test data Image = Image.get_feature(reshape = True) imagelist.append([Image, 1000]) with open('pickle/TestImageName.pkl','w') as f: pickle.dump(ListOfName,f) print('got image list for test') #shuffle(imagelist) return imagelist