image_folder, mask_folder, aug_dict_image, aug_dict_mask, image_color_mode="grayscale", mask_color_mode="grayscale", image_save_prefix="image", mask_save_prefix="mask", flag_multi_class=False, num_class=num_class, save_to_dir=None, target_size=(256, 256), seed=1) #Instantiate the model model = unet() #Save the model after each epoch model_checkpoint = ModelCheckpoint( '/media/hd1/unet_model_training_data/unet-master/data_' + channel + '/06082020_unet_little-delta_' + little_delta + '_total-time_' + total_time + '.hdf5', monitor='loss', verbose=1, save_best_only=True) #Fit the model with 5 epochs try: H1 = model.fit_generator(myData, steps_per_epoch=steps_per_epoch, epochs=2, callbacks=[model_checkpoint])
num_class = 3 #Augment the data with some defined alterations #These are defined by U-Net package #The mask must have the same augmentation applied to it excepting brightness aug_dict_image = dict() aug_dict_mask = dict() cnt = 0 for i1 in np.arange(1, 7): for i2 in np.arange(1, 7): if cnt == input_cnt: weights_file = '/media/hd1/unet_model_training_data_cm/unet-master/data_' + ch + '/round_' + str( i1) + '_06302020_unet_little-delta_' + str( little_delta) + '_total-time_' + str(total_time) + '.hdf5' model = unet(pretrained_weights=weights_file) test_path = '/media/hd1/unet_model_training_data_cm/unet-master/data_' + ch + '/unet_data/round_' + str( i2) + '_test_little-delta_' + str( little_delta) + '_total-time_' + str(total_time) #Test the model myDataTest = trainGenerator(batch_size, test_path, image_folder, mask_folder, aug_dict_image, aug_dict_mask, image_color_mode="grayscale", mask_color_mode="grayscale", image_save_prefix="image", mask_save_prefix="mask",