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(LOGDIR): os.makedirs(LOGDIR) if not os.path.exists(OUTPUT_DIR): os.makedirs(OUTPUT_DIR) run_config = tf.ConfigProto() run_config.gpu_options.allow_growth=True print("FLAGs " + str(FLAGS.dataset)) with tf.Session(config=run_config) as sess: model = BlockGAN( sess, input_width=FLAGS.input_width, input_height=FLAGS.input_height, output_width=FLAGS.output_width, output_height=FLAGS.output_height, dataset_name=FLAGS.dataset, input_fname_pattern=FLAGS.input_fname_pattern) model.build(cfg['build_func']) show_all_variables() if FLAGS.train: train_func = eval("model." + (cfg['train_func'])) train_func(FLAGS) else: if not model.load(LOGDIR)[0]: raise Exception("[!] Train a model first, then run test mode") model.sample_HoloGAN(FLAGS)
def main(_): if not os.path.exists(LOGDIR): os.makedirs(LOGDIR) if not os.path.exists(OUTPUT_DIR): os.makedirs(OUTPUT_DIR) run_config = tf.ConfigProto() run_config.gpu_options.allow_growth = True emb_graph = None if ADD_EMBEDDING: emb_graph = load_pb(str(cfg.emb_tf_model)) with tf.Session(config=run_config, graph=emb_graph) as sess: model = HoloGAN( sess, emb_graph, input_width=cfg.input_width, input_height=cfg.input_height, output_width=cfg.output_width, output_height=cfg.output_height, dataset_name=cfg.dataset, input_fname_pattern=cfg.input_fname_pattern, crop=cfg.crop) model.build(cfg.build_func) show_all_variables() if cfg.train: train_func = eval("model." + cfg.train_func) train_func() else: if not model.load(LOGDIR)[0]: raise Exception("[!] Train a model first, then run test mode") model.sample_HoloGAN()
def main(_): os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3' 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(LOGDIR): os.makedirs(LOGDIR) if not os.path.exists(OUTPUT_DIR): os.makedirs(OUTPUT_DIR) run_config = tf.ConfigProto() run_config.gpu_options.allow_growth=True print("FLAGs " + str(FLAGS.dataset)) with tf.Session(config=run_config) as sess: model = HoloGAN( sess, input_width=FLAGS.input_width, input_height=FLAGS.input_height, output_width=FLAGS.output_width, output_height=FLAGS.output_height, dataset_name=FLAGS.dataset, input_fname_pattern=FLAGS.input_fname_pattern, crop=FLAGS.crop) model.build(cfg['build_func']) show_all_variables() if FLAGS.train: print("FLAGS.train: ", FLAGS.train) print("FLAGS.rotate_azimuth: ", FLAGS.rotate_azimuth) train_func = eval("model." + (cfg['train_func'])) train_func(FLAGS) else: print("FLAGS.train: ", FLAGS.train) print("FLAGS.rotate_azimuth: ", FLAGS.rotate_azimuth) if not model.load(LOGDIR)[0]: raise Exception("[!] Train a model first, then run test mode") # here are eight ways to sample images for different purposes #model.sample_HoloGAN(FLAGS) #model.sample_HoloGAN_target_image_tuple(FLAGS) #model.sample_HoloGAN_target_image_divided(FLAGS) #model.sample_HoloGAN_target_image_update_tuple(FLAGS) #model.sample_HoloGAN_target_image_update_divided(FLAGS) #model.sample_HoloGAN_many(FLAGS, amount=10000) #model.sample_HoloGAN_many_target_image(FLAGS, amount=10000) model.sample_HoloGAN_many_target_image_update(FLAGS, start_idx=9000, over_idx=10000, update_num=3)
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(OUTPUT_DIR): os.makedirs(OUTPUT_DIR) run_config = tf.compat.v1.ConfigProto() run_config.gpu_options.allow_growth = True with tf.compat.v1.Session(config=run_config) as sess: model = HoloGAN(sess, input_width=FLAGS.input_width, input_height=FLAGS.input_height, output_width=FLAGS.output_width, output_height=FLAGS.output_height, dataset_name=FLAGS.dataset, input_fname_pattern=FLAGS.input_fname_pattern, crop=FLAGS.crop) model.build(cfg['build_func']) show_all_variables() if FLAGS.train: train_func = eval("model." + (cfg['train_func'])) train_func(FLAGS) else: if not model.load()[0]: raise Exception("[!] Train a model first, then run test mode") if str.lower(str(cfg["z_map"])) == "true": model.train_z_map(FLAGS) elif str.lower(str(cfg["sample"])) == "true": model.sample_HoloGAN(FLAGS) elif str.lower(str(cfg["generate"])) == "true": model.generate_images(FLAGS)