def main():

    # open session
    with tf.Session(config=tf.ConfigProto(allow_soft_placement=True)) as sess:
        # declare instance for GAN
        classes = ['angry']
        gan = WGAN(classes=classes,
                   sess=sess,
                   epoch=EPOCH,
                   batch_size=BATCH_SIZE,
                   z_dim=Z_DIM,
                   dataset_name=DATASET,
                   augmentation=False,
                   aug_ratio=12,
                   checkpoint_dir=CHECKPOINT_DIR,
                   result_dir=RESULT_DIR,
                   log_dir=LOG_DIR)

        # build graph
        gan.build_model()

        # show network architecture
        # show_all_variables()

        # launch the graph in a session
        gan.train()
        print(" [*] Training finished!")

        # visualize learned generator
        # gan.visualize_results(EPOCH - 1)
        print(" [*] Testing finished!")
Beispiel #2
0
def main(_):
    check_dir()
    print_config()
    gpu_options = tf.GPUOptions(per_process_gpu_memory_fraction=0.5)
    run_option = tf.ConfigProto(gpu_options=gpu_options)
    with tf.Session(config=run_option) as sess:
        wgan = WGAN(config=FLAGS, sess=sess)
        wgan.build_model()
        if FLAGS.is_training:
            wgan.train_model()
        if FLAGS.is_testing:
            wgan.test_model()
Beispiel #3
0
def main():
    with tf.Session() as sess:
        gan = WGAN(sess,
                   epoch=10000,
                   batch_size=16,
                   dataset_name='fire2.tfrecords',
                   checkpoint_dir='checkpoint',
                   result_dir='results',
                   log_dir='logs')
        # build graph

        gan.build_model()
        show_all_variables()
        gan.train()
        print(" [*] Training finished!")
        gan.visualize_results(20 - 1)
        print(" [*] Testing finished!")
Beispiel #4
0
import argparse

desc = "dimension"
parser = argparse.ArgumentParser(description=desc)
parser.add_argument('--dim', type=int, help='input dimension')
args = parser.parse_args()
dim = args.dim

with tf.Session(config=tf.ConfigProto(allow_soft_placement=True)) as sess:

    gan = WGAN(sess,
               epoch=20,
               batch_size=128,
               z_dim=dim,
               dataset_name='fashion-mnist',
               checkpoint_dir='checkpoints',
               result_dir='results',
               log_dir='logs')
    if gan is None:
        raise Exception("[!] There is no option for " + args.gan_type)

    # build graph
    gan.build_model()

    # show network architecture
    show_all_variables()

    # launch the graph in a session
    gan.train()
    print(" [*] Training finished!")