split = 1 test_fname = 'test' + str(split) + '.txt' part_dat = False df_test = create_df(os.path.join(datapath, test_fname), img_path, partial_dataset=part_dat, seed=123) #%% Create TF dataloader IMSIZE = (224, 224, 3) BATCH_SIZE = 32 test_ds = create_tf_dataset(df_test, imsize=IMSIZE, onehot=True) test_ds = test_ds.batch(BATCH_SIZE) ## #%% Evaluation modelpth = 'D:\\Users\\Mikko Impiö\\kandi\\models' from tensorflow.keras.models import load_model model = load_model(os.path.join(modelpth, '09-02-2020_cont_colab.h5')) preds = model.predict(test_ds, verbose=True) yhat = np.argmax(preds, axis=1) + 1 y_test = df_test['label']
df_val = create_df(os.path.join(datapath, val_fname), img_path, partial_dataset=part_dat, seed=123) from sklearn.utils import shuffle df_train = shuffle(df_train) df_val = shuffle(df_val) #%% Create TF dataloader AUTOTUNE = tf.data.experimental.AUTOTUNE IMSIZE = (224, 224, 3) BATCH_SIZE = 8 train_ds = create_tf_dataset(df_train, imsize=IMSIZE, onehot=True) val_ds = create_tf_dataset(df_val, imsize=IMSIZE, onehot=True) train_ds = prepare_for_training(train_ds, shuffle_buffer_size=1000, batch_size=BATCH_SIZE) val_ds = prepare_for_training(val_ds, shuffle_buffer_size=1000, batch_size=BATCH_SIZE) for image, label in train_ds.take(5): print(image.shape) print(label.shape)
df_test = create_df(os.path.join(datapath, test_fname), img_path, partial_dataset=part_dat, seed=123) df_val = create_df(os.path.join(datapath, val_fname), img_path, partial_dataset=part_dat, seed=123) #%% Create TF dataloader AUTOTUNE = tf.data.experimental.AUTOTUNE IMSIZE = (224, 224, 3) BATCH_SIZE = 8 train_ds = create_tf_dataset(df_train, imsize=IMSIZE, onehot=False) test_ds = create_tf_dataset(df_test, imsize=IMSIZE, onehot=False) val_ds = create_tf_dataset(df_val, imsize=IMSIZE, onehot=False) ## train_ds = prepare_for_training(train_ds, shuffle_buffer_size=len(df_train), batch_size=BATCH_SIZE) val_ds = prepare_for_training(val_ds, shuffle_buffer_size=len(df_val), batch_size=BATCH_SIZE) for image, label in train_ds.take(5): print(image.shape)