args = train_utils.parse_params(config_file_path) L = args.num_classes args.image_dim = [128, 128, 3] #%% load saved network parameters and open new session tf.reset_default_graph() in_placeholder = tf.placeholder( tf.float32, shape=[None, None, None, L + args.image_dim[2]], name="in_placeholder") out_placeholder = tf.placeholder(tf.float32, shape=[None, None, None, L], name='out_placeholder') phase = tf.placeholder(tf.bool, name='phase') net_class = Models(args) net_class.build_model(in_placeholder, phase) sess = tf.Session() saver = tf.train.Saver() sess.run(tf.global_variables_initializer()) ckpt = tf.train.get_checkpoint_state(checkpoints_path) if ckpt and ckpt.model_checkpoint_path: ckpt_path = checkpoints_path + 'my_model-' + str(checkpoint[0]) saver.restore(sess, ckpt_path) #%% if not os.path.exists(output_path): os.makedirs(output_path) image_list = sorted(os.listdir(pascal_path + '/images'))
elif args.app == 'dehaze': (x_test, gt_test) = (f_HDF5["test"], f_HDF5["test_gt"]) app_loss = Dehazing_Loss(args) elif args.app == 'matte': (x_test, x_test_1, x_test_2, gt_test) = (f_HDF5["val"], f_HDF5["test_t2"], f_HDF5["test_t1"], f_HDF5["test_gt"]) app_loss = Matting_Loss(args) print("Constructing network...") net_class = Models(args) tf.reset_default_graph() input_placeholder = tf.placeholder(tf.float32, (None, ) + x_train.shape[1:], 'images_with_seeds') phase = tf.placeholder(tf.bool, name='phase') output_from_network = net_class.build_model(input_placeholder, phase) loss = app_loss._loss(input_placeholder, output_from_network) samples_in_epoch = int( np.ceil(np.shape(x_train)[0] / np.float32(args.batch_size))) num_iter = args.num_epochs * samples_in_epoch + 1 global_step = tf.Variable(0, trainable=False) if args.train_schedule == 'exp': # decrease learning exponentially learning_rate = tf.train.exponential_decay(args.init_lr, global_step,samples_in_epoch*args.decay_every,\ args.decay_factor, staircase=True) elif args.train_schedule == 'plateau': # decrease learning rate when plateau is reached lr_placeholder = tf.placeholder(tf.float32, [], name='learning_rate') learning_rate = lr_placeholder