vis = VIS(save_path=opt.checkpoint_path) # configuration session config = tf.ConfigProto() config.gpu_options.allow_growth = True sess = tf.Session(config=config) K.set_session(sess) K.set_learning_phase(1) # define data loader (with train and test) train_generator, _, train_samples, _ = dataLoader(opt.data_path, opt.batch_size, opt.imSizeX, opt.imSizeY) # define test loader (optional to replace above test_generator) test_generator, test_samples = folderLoader(opt.data_path, opt.imSizeX, opt.imSizeY) opt.iter_epoch = int(train_samples) # define input holders img_shape = (opt.imSizeY, opt.imSizeX, 3) #img = tf.placeholder(tf.float32, shape=img_shape) img = tf.placeholder(tf.int32, shape=img_shape) label = tf.placeholder(tf.int32, shape=(None, opt.imSizeY, opt.imSizeX)) # define model with tf.name_scope('unet'): model = UNet().create_model(img_shape=img_shape, num_class=opt.num_class) img = model.input pred = model.output # define loss
# configure args from opts import * # assert(opt.load_from_checkpoint != '') # assert(opt.batch_size == 1) vis = VIS(save_path=opt.load_from_checkpoint) # configuration session config = tf.ConfigProto() config.gpu_options.allow_growth = True sess = tf.Session(config=config) K.set_session(sess) K.set_learning_phase(0) # define data loader test_generator, test_samples = folderLoader(opt.data_path) # define model, the last dimension is the channel img_shape = (opt.imSize, opt.imSize, 3) # img = tf.placeholder(tf.float32, shape=img_shape) label = tf.placeholder(tf.int32, shape=(None, opt.imSize, opt.imSize)) with tf.name_scope('unet'): model = UNet().create_model(img_shape=img_shape, num_class=opt.num_class) img = model.input pred = model.output # define loss with tf.name_scope('cross_entropy'): cross_entropy_loss = tf.reduce_mean( tf.nn.sparse_softmax_cross_entropy_with_logits(labels=label, logits=pred))
from utils import VIS, mean_IU # configure args from opts import * # assert(opt.load_from_checkpoint != '') # assert(opt.batch_size == 1) vis = VIS(save_path=opt.load_from_checkpoint) # configuration session config = tf.ConfigProto() config.gpu_options.allow_growth = True sess = tf.Session(config=config) # define data loader img_shape = [opt.imSize, opt.imSize] test_generator, test_samples = folderLoader(opt.data_path, imSize=img_shape) # define model, the last dimension is the channel label = tf.placeholder(tf.int32, shape=[None]+img_shape) with tf.name_scope('unet'): model = UNet().create_model(img_shape=img_shape, num_class=opt.num_class) img = model.input pred = model.output # define loss with tf.name_scope('cross_entropy'): cross_entropy_loss = tf.reduce_mean(tf.nn.sparse_softmax_cross_entropy_with_logits(labels=label, logits=pred)) saver = tf.train.Saver() # must be added in the end ''' Main ''' init_op = tf.global_variables_initializer()