예제 #1
0
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)

    with tf.Session() as sess:
        cdgan = CrossDomainGAN(sess,
                               image_size=FLAGS.image_size,
                               batch_size=FLAGS.batch_size,
                               c_dim=FLAGS.c_dim,
                               dataset_name=FLAGS.dataset,
                               checkpoint_dir=FLAGS.checkpoint_dir,
                               sample_dir=FLAGS.sample_dir)

        if FLAGS.is_train:
            cdgan.train(FLAGS)
        else:
            cdgan.load(FLAGS.checkpoint_dir)

        if FLAGS.visualize:
            # 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 = 2
            visualize(sess, dcgan, FLAGS, OPTION)
예제 #2
0
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(_):
    pp.pprint(flags.FLAGS.__flags)

    if not os.path.exists(FLAGS.checkpoint_dir):
        os.makedirs(FLAGS.checkpoint_dir)
    with tf.Session() as sess:
        model = TinyVGG(sess, image_size=FLAGS.image_size, batch_size=FLAGS.batch_size, c_dim=FLAGS.c_dim,
                     y_dim=FLAGS.y_dim, dataset_name=FLAGS.dataset, checkpoint_dir=FLAGS.checkpoint_dir)
        if FLAGS.is_train:
            model.train(FLAGS)
        else:
            model.load(FLAGS.checkpoint_dir)
예제 #4
0
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)