def load_piropo(): # img_rows, img_cols = 128, 128 ilist = set_para.lookfor(keyword = 'omni_1A', imagelist = None) ilist = set_para.lookfor(keyword = 'omni_1B', imagelist = ilist) ilist = set_para.lookfor(keyword = 'omni_2A', imagelist = ilist) ilist = set_para.lookfor(keyword = 'omni_3A', imagelist = ilist) frame = pandas.DataFrame.from_dict(ilist) train, test = train_test_split(frame, random_state = 1) # train = pandas.DataFrame.as_matrix(train) # test = pandas.DataFrame.as_matrix(test) Y_train = np.asarray(train.label.tolist()) Y_test = np.asarray(test.label.tolist()) X_train = np.asarray(train.picarray.tolist()) X_test = np.asarray(test.picarray.tolist()) X_train, Y_train, X_test, Y_test = set_para.preprocessing(X_train = X_train, y_train = Y_train, X_test = X_test, y_test = Y_test , nb_classes = nb_classes, to_categorical = True) # x = [] # y = [] # for item in ilist: # x.append(item['picarray']) # y.append(item['label']) # x = np.asarray(x) # y = np.asarray(y) # y = np.reshape(y, (len(y),1)) # evalu.savexy(x,y, modelname, modelpath) # x, y = evalu.loadxy(modelname, modelpath) # X_train, Y_train, X_test, Y_test = set_para.preprocessing(x = x, y = y, split = True, nb_classes = nb_classes, # to_categorical = True) evalu.savexy(X_train, Y_train, 'piropo_train', modelpath) evalu.savexy(X_test, Y_test, 'piropo_test', modelpath) evalu.savexy(train, test, 'dataframe', modelpath) return X_train, Y_train, X_test, Y_test, train, test
def load_stereo(): img_rows, img_cols = 36,18 x, y = set_para.readimage(label = 1, cutsize = False, resize = False, path = '/home/workstation/Documents/humandataset/pedestrain_benchmarks/Stereo/TrainingData/Pedestrians/18x36/') x, y = set_para.readimage(label = 0, cutsize = True, resize = False, x = x, labelist = y, reh = 36, rew = 18, path = '/home/workstation/Documents/humandataset/pedestrain_benchmarks/Stereo/TrainingData/NonPedestrians/') X_train, Y_train, X_test, Y_test = set_para.preprocessing(x = x, y = y, split = True, nb_classes = nb_classes, to_categorical = False) return X_train, Y_train, X_test, Y_test
def load_google(): img_rows, img_cols = 32, 64 x, y = set_para.readimage(label = 1, cutsize = False, resize = True, reh = img_rows, rew = img_cols, path = '/home/workstation/Documents/humandataset/beforethermal/1/pedestrain/') x, y = set_para.readimage(label = 1, cutsize = False, resize = True, x = x, labelist = y, reh = img_rows, rew = img_cols, path = '/home/workstation/Documents/humandataset/beforethermal/1/people_on_the_street/') x, y = set_para.readimage(label = 1, cutsize = False, resize = True, x = x, labelist = y, reh = img_rows, rew = img_cols, path = '/home/workstation/Documents/humandataset/beforethermal/1/traffic_warden/') x, y = set_para.readimage(label = 0, cutsize = False, resize = True, x = x, labelist = y, reh = img_rows, rew = img_cols, path = '/home/workstation/Documents/humandataset/beforethermal/0/empty_city_road/') x, y = set_para.readimage(label = 0, cutsize = False, resize = True, x = x, labelist = y, reh = img_rows, rew = img_cols, path = '/home/workstation/Documents/humandataset/beforethermal/0/empty_street/') x, y = set_para.readimage(label = 0, cutsize = False, resize = True, x = x, labelist = y, reh = img_rows, rew = img_cols, path = '/home/workstation/Documents/humandataset/beforethermal/0/trees_street_empty/') X_train, Y_train, X_test, Y_test = set_para.preprocessing(x = x, y = y, split = True, nb_classes = nb_classes, to_categorical = False) return X_train, Y_train, X_test, Y_test
# import plot import evalu sys.setrecursionlimit(10000) modelpath = "/home/workstation/Documents/Cifar10/best/" modelname = raw_input("Ask me == ") batch_size = 32 nb_classes = 10 nb_epoch = 2 data_augmentation = True img_rows, img_cols = 32, 32 img_channels = 3 (X_train, y_train), (X_test, y_test) = cifar10.load_data() # X_train, y_train, X_test, y_test = set_para.slicing(X_train, y_train, X_test, y_test) X_train, Y_train, X_test, Y_test = set_para.preprocessing(X_train, y_train, X_test, y_test) changed_list = ['dense'] print (changed_list[0] + ' is changed at ' + strftime("%Y-%m-%d %H:%M:%S", gmtime())) ds = 938 acc = [] avg_acc = [] m_hist = [] model = Sequential() model.add(Convolution2D(32, 5, 5, border_mode='same', input_shape=(img_channels, img_rows, img_cols))) model.add(Activation('relu')) model.add(Convolution2D(32, 5, 5)) model.add(Activation('relu')) model.add(MaxPooling2D(pool_size=(2, 2))) model.add(Dropout(0.12))
def load_beforethermal(): # Seems these are random google pics resized into (2446, 3, 64, 32) ones m = pickle.load(open( '/home/workstation/Documents/humandataset/beforethermal/' + 'beforethermal_x' + '.p', 'rb')) y = pickle.load(open( '/home/workstation/Documents/humandataset/beforethermal/' + 'beforethermal_y' + '.p', 'rb')) X_train, Y_train, X_test, Y_test = set_para.preprocessing(x = x, y = y, split = True, nb_classes = nb_classes) return X_train, Y_train, X_test, Y_test
modelname = raw_input("Ask me == ") batch_size = 32 nb_classes = 2 nb_epoch = 10 data_augmentation = True img_rows, img_cols = 32, 32 img_channels = 3 (X_train, y_train), (X_test, y_test) = cifar100.load_data() y_train = np.where((y_train < 74), y_train, 0) y_train = np.where((y_train > 69), 1, 0) y_test = np.where((y_test < 74), y_test, 0) y_test = np.where((y_test > 69), 1, 0) # X_train, y_train, X_test, y_test = set_para.slicing(X_train, y_train, X_test, y_test) X_train, Y_train, X_test, Y_test = set_para.preprocessing( X_train, y_train, X_test, y_test, nb_classes=nb_classes) acc = [] avg_acc = [] m_hist = [] model = Sequential() model.add( Convolution2D(32, 5, 5, border_mode='same', input_shape=(img_channels, img_rows, img_cols))) model.add(Activation('relu')) model.add(Convolution2D(32, 5, 5)) model.add(Activation('relu')) model.add(MaxPooling2D(pool_size=(2, 2)))
batch_size = 32 nb_classes = 2 nb_epoch = 100 data_augmentation = True img_rows, img_cols = 36,18 img_channels = 3 x, y = set_para.readimage(label = 1, cutsize = False, resize = False, path = '/home/workstation/Documents/humandataset/pedestrain_benchmarks/Stereo/TrainingData/Pedestrians/18x36/') x, y = set_para.readimage(label = 0, cutsize = True, resize = False, x = x, labelist = y, reh = 36, rew = 18, path = '/home/workstation/Documents/humandataset/pedestrain_benchmarks/Stereo/TrainingData/NonPedestrians/') X_train, Y_train, X_test, Y_test = set_para.preprocessing(x = x, y = y, split = True, nb_classes = nb_classes, to_categorical = False) acc = [] avg_acc = [] m_hist = [] inputs = Input(shape = (img_channels, img_rows, img_cols)) cn1 = Convolution2D(32,5,5, border_mode = 'same')(inputs) relu1 = Activation('relu')(cn1) pool1 = MaxPooling2D(pool_size = (2,2))(relu1) do1 = Dropout(0.2)(pool1) cn2 = Convolution2D(64,3,3, border_mode = 'same')(do1) relu2 = Activation('relu')(cn2) pool2 = MaxPooling2D(pool_size = (2,2))(relu2)