def main(_): pp.pprint(flags.FLAGS.__flags) if FLAGS.output_width is None: FLAGS.output_width = FLAGS.output_height assert (os.path.exists(FLAGS.checkpoint_dir)) run_config = tf.ConfigProto() run_config.gpu_options.allow_growth = True with tf.Session(config=run_config) as sess: dcgan = DCGAN(sess, output_width=FLAGS.output_width, output_height=FLAGS.output_height, batch_size=FLAGS.batch_size, dataset_name=FLAGS.dataset, checkpoint_dir=FLAGS.checkpoint_dir, lam=FLAGS.lam) #dcgan.load(FLAGS.checkpoint_dir): dcgan.complete(FLAGS) show_all_variables() # to_json("./web/js/layers.js", [dcgan.h0_w, dcgan.h0_b, dcgan.g_bn0], # [dcgan.h1_w, dcgan.h1_b, dcgan.g_bn1], # [dcgan.h2_w, dcgan.h2_b, dcgan.g_bn2], # [dcgan.h3_w, dcgan.h3_b, dcgan.g_bn3], # [dcgan.h4_w, dcgan.h4_b, None]) # Below is codes for visualization OPTION = 1 visualize(sess, dcgan, FLAGS, OPTION)
def main(_): pp.pprint(flags.FLAGS.__flags) if FLAGS.input_width is None: FLAGS.input_width = FLAGS.input_height if FLAGS.output_width is None: FLAGS.output_width = FLAGS.output_height if not os.path.exists(FLAGS.checkpoint_dir): os.makedirs(FLAGS.checkpoint_dir) if not os.path.exists(FLAGS.sample_dir): os.makedirs(FLAGS.sample_dir) #gpu_options = tf.GPUOptions(per_process_gpu_memory_fraction=0.333) run_config = tf.ConfigProto() run_config.gpu_options.allow_growth=True with tf.Session(config=run_config) as sess: dcgan = DCGAN( sess, input_width=FLAGS.input_width, input_height=FLAGS.input_height, output_width=FLAGS.output_width, output_height=FLAGS.output_height, batch_size=FLAGS.batch_size, sample_num=FLAGS.batch_size, dataset_name=FLAGS.dataset, input_fname_pattern=FLAGS.input_fname_pattern, crop=FLAGS.crop, checkpoint_dir=FLAGS.checkpoint_dir, sample_dir=FLAGS.sample_dir) print('Will try to complete images...') dcgan.complete() print('Done!')
parser.add_argument('--lr', type=float, default=0.01) parser.add_argument('--beta1', type=float, default=0.9) parser.add_argument('--beta2', type=float, default=0.999) parser.add_argument('--eps', type=float, default=1e-8) parser.add_argument('--hmcBeta', type=float, default=0.2) parser.add_argument('--hmcEps', type=float, default=0.001) parser.add_argument('--hmcL', type=int, default=100) parser.add_argument('--nIter', type=int, default=1000) parser.add_argument('--imgSize', type=int, default=64) parser.add_argument('--lam', type=float, default=0.1) parser.add_argument('--checkpointDir', type=str, default='checkpoint') parser.add_argument('--outDir', type=str, default='completions') parser.add_argument('--outInterval', type=int, default=50) parser.add_argument('--maskType', type=str, choices=['random', 'center', 'left', 'full', 'grid', 'lowres'], default='center') parser.add_argument('--centerScale', type=float, default=0.25) parser.add_argument('imgs', type=str, nargs='+') args = parser.parse_args() assert(os.path.exists(args.checkpointDir)) config = tf.ConfigProto() config.gpu_options.allow_growth = True with tf.Session(config=config) as sess: dcgan = DCGAN(sess, image_size=args.imgSize, batch_size=(1 if args.approach == 'hmc' else 64), checkpoint_dir=args.checkpointDir, lam=args.lam) dcgan.complete(args)
parser.add_argument('--beta1', type=float, default=0.9) parser.add_argument('--beta2', type=float, default=0.999) parser.add_argument('--eps', type=float, default=1e-8) parser.add_argument('--hmcBeta', type=float, default=0.2) parser.add_argument('--hmcEps', type=float, default=0.001) parser.add_argument('--hmcL', type=int, default=100) parser.add_argument('--hmcAnneal', type=float, default=1) parser.add_argument('--nIter', type=int, default=1000) parser.add_argument('--imgSize', type=int, default=64) parser.add_argument('--lam', type=float, default=0.1) parser.add_argument('--checkpointDir', type=str, default='checkpoint') parser.add_argument('--outDir', type=str, default='completions') parser.add_argument('--outInterval', type=int, default=50) parser.add_argument('--maskType', type=str, choices=['random', 'center', 'left', 'full', 'grid', 'lowres'], default='center') parser.add_argument('--centerScale', type=float, default=0.25) parser.add_argument('imgs', type=str, nargs='+') args = parser.parse_args() assert(os.path.exists(args.checkpointDir)) config = tf.ConfigProto() config.gpu_options.allow_growth = True with tf.Session(config=config) as sess: dcgan = DCGAN(sess, image_size=args.imgSize, batch_size=min(64, len(args.imgs)), checkpoint_dir=args.checkpointDir, lam=args.lam) dcgan.complete(args)
def main(_): pp.pprint(flags.FLAGS.__flags) if not os.path.exists(FLAGS.checkpoint_dir): os.makedirs(FLAGS.checkpoint_dir) if not os.path.exists(FLAGS.sample_dir): os.makedirs(FLAGS.sample_dir) # Do not take all memory gpu_options = tf.GPUOptions(per_process_gpu_memory_fraction=0.80) # sess = tf.Session(config=tf.ConfigProto(gpu_options=gpu_options)) with tf.Session(config=tf.ConfigProto(gpu_options=gpu_options)) as sess: # w/ y label if FLAGS.dataset == 'mnist': dcgan = DCGAN(sess, image_size=FLAGS.image_size, batch_size=FLAGS.batch_size, y_dim=10, output_size=28, c_dim=1, dataset_name=FLAGS.dataset, is_crop=FLAGS.is_crop, checkpoint_dir=FLAGS.checkpoint_dir) # w/o y label else: if FLAGS.dataset == 'cityscapes': print 'Select CITYSCAPES' mask_dir = CITYSCAPES_mask_dir FLAGS.output_size_h, FLAGS.output_size_w, FLAGS.is_crop = 192, 512, False FLAGS.dataset_dir = CITYSCAPES_dir elif FLAGS.dataset == 'inria': print 'Select INRIAPerson' FLAGS.output_size_h, FLAGS.output_size_w, FLAGS.is_crop = 160, 96, False FLAGS.dataset_dir = INRIA_dir elif FLAGS.dataset == 'indoor': print 'Select indoor' FLAGS.output_size_h, FLAGS.output_size_w, FLAGS.is_crop = 256, 256, False FLAGS.dataset_dir = indoor_dir elif FLAGS.dataset == 'indoor_bedroom': print 'Select indoor bedroom' FLAGS.output_size_h, FLAGS.output_size_w, FLAGS.is_crop = 256, 256, False FLAGS.dataset_dir = indoor_bedroom_dir elif FLAGS.dataset == 'indoor_dining': print 'Select indoor dining' FLAGS.output_size_h, FLAGS.output_size_w, FLAGS.is_crop = 256, 256, False FLAGS.dataset_dir = indoor_bedroom_dir dcgan = DCGAN(sess, batch_size=FLAGS.batch_size, output_size_h=FLAGS.output_size_h, output_size_w=FLAGS.output_size_w, c_dim=FLAGS.c_dim, dataset_name=FLAGS.dataset, is_crop=FLAGS.is_crop, checkpoint_dir=FLAGS.checkpoint_dir, dataset_dir=FLAGS.dataset_dir) if FLAGS.mode == 'test': print('Testing!') dcgan.test(FLAGS) elif FLAGS.mode == 'train': print('Train!') dcgan.train(FLAGS) elif FLAGS.mode == 'complete': print('Complete!') dcgan.complete(FLAGS, mask_dir)
'random', 'center', 'left', 'full', 'grid', 'lowres', 'parameters', 'wfc3' ], default='parameters') parser.add_argument('--input_spectrum', type=str, default='./input_spectrum.dat') parser.add_argument('--centerScale', type=float, default=0.25) parser.add_argument('--make_corner', type=bool, default=False) parser.add_argument('--spectra_int_norm', type=bool, default=False) parser.add_argument('--spectra_norm', type=bool, default=False) parser.add_argument('--spectra_real_norm', type=bool, default=True) args = parser.parse_args() assert (os.path.exists(args.checkpointDir)) tf.reset_default_graph() config = tf.ConfigProto(log_device_placement=True) config.gpu_options.allow_growth = True sess = tf.Session(config=config) spectrum = args.input_spectrum dcgan = DCGAN(sess, image_size=args.imgSize, z_dim=100, batch_size=64, checkpoint_dir=args.checkpointDir, c_dim=1, lam=args.lam) dcgan.complete(args, spectrum)
parser.add_argument('--nIter', type=int, default=1001) parser.add_argument('--imgSize', type=int, default=33) parser.add_argument('--lam', type=float, default=0.1) parser.add_argument('--checkpointDir', type=str, default='checkpoint_test') parser.add_argument('--outDir', type=str, default='exogan_output') parser.add_argument('--outInterval', type=int, default=50) parser.add_argument('--maskType', type=str, choices=['random', 'center', 'left', 'full', 'grid', 'lowres', 'parameters', 'wfc3'], default='parameters') parser.add_argument('--centerScale', type=float, default=0.25) parser.add_argument('--make_corner', type=bool, default=False) parser.add_argument('--spectra_int_norm', type=bool, default=False) parser.add_argument('--spectra_norm', type=bool, default=False) parser.add_argument('--spectra_real_norm', type=bool, default=True) args = parser.parse_args() assert(os.path.exists(args.checkpointDir)) tf.reset_default_graph() config = tf.ConfigProto(log_device_placement=True) config.gpu_options.allow_growth = True sess = tf.Session(config=config) dcgan = DCGAN(sess, image_size=args.imgSize, z_dim=100, batch_size=64, checkpoint_dir=args.checkpointDir, c_dim=1, lam=args.lam) dcgan.complete(args, spectrum[0], sigma=0.0)
config = tf.ConfigProto() config.gpu_options.allow_growth = True with tf.Session(config=config) as sess: dcgan = DCGAN(sess, image_size=args.imgSize, batch_size=min(64, len(args.imgs)), checkpoint_dir=args.checkpointDir, lam=args.lam) img1 = cv2.imread("C:/Users/engab/Desktop/PROJECT/CRW_4901_JFRtamp37.jpg", cv2.IMREAD_COLOR) points, positions = sift.all_experiments(img1) while True: dcgan.complete(args, points, positions, 110, 175) #put the starting coordinates of the object output = cv2.imread( "C:/Users/engab/Desktop/PROJECT/tensorflow dcgan inpainting/DSC_1535tamp1.jpg", cv2.IMREAD_COLOR) #inpainted image path img1[175:239, 110:174] = output points, positions = sift.all_experiments(img1) #your code here,put image number 950 in the loop folder parser.set_defaults( imgs= "C:/Users\\engab\\Desktop\\PROJECT\\tensorflow dcgan inpainting\\data\\loop" ) #inpainted image path args = parser.parse_args() if points < 4: break