if platform.system() == 'Darwin': os.environ['KMP_DUPLICATE_LIB_OK'] = 'True' if model_path: model = models.load_model( model_path, custom_objects={'DivByRedSum': DivByRedSum, 'mean_pred' : mean_pred, 'max_pred': max_pred, 'min_pred' : min_pred, 'mean_true': mean_true, 'max_true': max_true, 'min_true':min_true}) else: print('Using normal model.') model = vgg16_enc_dec_model((img_height, img_width, img_channels), freeze_vgg = False, output_choice = 'sigmoid', **{'reg':None,'dropout':0.1}) model.load_weights(weights_path) if tr_or_val == 'tr': image_paths = get_img_paths(path_train+"/images") mask_paths = get_img_paths(path_train+"/masks") else: image_paths = get_img_paths(path_test+"/images") mask_paths = get_img_paths(path_test+"/masks") #TODO: If there is a problem with NaN values, one can try this: #for n,layer in enumerate(model.layers): # weights = layer.get_weights() # new_weights = [np.nan_to_num(w) for w in weights] # layer.set_weights(new_weights)
custom_objects={ 'DivByRedSum': DivByRedSum, 'mean_pred': mean_pred, 'max_pred': max_pred, 'min_pred': min_pred, 'mean_true': mean_true, 'max_true': max_true, 'min_true': min_true }, compile=True) print('Loaded model from {}'.format(args.load_model)) else: print('Using new model with {}'.format(args.model_output_choice)) template_model = vgg16_enc_dec_model( (img_height, img_width, img_channels), freeze_vgg=False, output_choice=args.model_output_choice, **counter_overfit[args.counter_overfit]) n_gpu = len(get_available_gpus()) print('Number of gpu to use: {}'.format(n_gpu)) if n_gpu > 1 and not do_not_use_mult_gpu: model = multi_gpu_model(template_model, gpus=n_gpu) print("Training using multiple GPUs..") else: model = template_model print("Training using single GPU or CPU..") print('Using {} as loss function'.format(loss_dict[args.loss])) model.compile(optimizer=keras.optimizers.Adam(clipnorm=1.0),