Esempio n. 1
0
def main():

    ## Instantiating generator class and loading model
    generator = networks.GeneratorNet()
    generator.load_state_dict(torch.load(MODEL_FOLDER))

    ## Running the sample(s) generation loop
    for sample in range(num_test_samples):

        ## Generating noise to generate images out of them
        random_noise = support.noise(num_test_samples)
        generated_images = support.vectors_to_images(generator(random_noise))
        generated_images = generated_images.detach().numpy()

        # Save image
        scipy.misc.imsave('generated_images/gen_image_{}.jpg'.format(sample),
                          generated_images[0][0])
Esempio n. 2
0
        preprocess_image_train,
        num_parallel_calls=AUTOTUNE).cache().shuffle(BUFFER_SIZE).batch(
            args.batch_size))
    train_y = (train_y.map(
        preprocess_image_train,
        num_parallel_calls=AUTOTUNE).cache().shuffle(BUFFER_SIZE).batch(
            args.batch_size))
    test_x = test_x.map(preprocess_image_test).batch(NUM_SAMPLES)
    test_y = test_y.map(preprocess_image_test).batch(NUM_SAMPLES)

    ds = tf.data.Dataset.zip((train_x, train_y))

    sample_x = next(iter(test_x))
    sample_y = next(iter(test_y))

    generator_g = networks.GeneratorNet()
    generator_f = networks.GeneratorNet()

    discriminator_x = networks.DiscriminatorNet()
    discriminator_y = networks.DiscriminatorNet()

    generator_g_optimizer = tf.keras.optimizers.Adam(args.lr_generator,
                                                     beta_1=0.5)
    generator_f_optimizer = tf.keras.optimizers.Adam(args.lr_generator,
                                                     beta_1=0.5)

    discriminator_x_optimizer = tf.keras.optimizers.Adam(args.lr_discriminator,
                                                         beta_1=0.5)
    discriminator_y_optimizer = tf.keras.optimizers.Adam(args.lr_discriminator,
                                                         beta_1=0.5)
Esempio n. 3
0
				[2] Improved GAN (one-sided label smoothing, minibatch discrimination layer)
				[3] Unrolled GAN (not yet implemented)
				[4] DCGAN
			""")
	
	arch = architectures[int(input())-1]
			
	print("""Choose data:
				[1] Cats
				[2] Cars (not yet implemented)
			""")
	
	dataname = data[int(input())-1]
	
	if (arch == "VGAN"):
		G = networks.GeneratorNet()
	elif (arch == "GAN_improve"):
		G = networks_improve.GeneratorNet()
	elif(arch == "DCGAN"):
		pass; # TODO: implement me later
	
	
	
	for _,_,fnames in os.walk("./data/models/{}".format(arch)):
		model_list = fnames #sorted(fnames, reverse = True)
	model_list = filter(lambda x: "G" in x, model_list)
	max_G = (sorted(model_list, key = lambda x: int(x[x.rindex("_")+1:]))[-1])
	max_epoch = max_G[max_G.rindex("_")+1:]
	
	print("Choose epoch: [0 - " + str(max_epoch) + "]")