|
import torch |
|
import nltk |
|
nltk.download('wordnet') |
|
|
|
from pytorch_pretrained_biggan import (BigGAN, one_hot_from_names, truncated_noise_sample, |
|
save_as_images, display_in_terminal) |
|
initial_archi = 'biggan-deep-128' |
|
|
|
gan_model = BigGAN.from_pretrained(initial_archi).cuda().eval() |
|
|
|
|
|
truncation = 0.4 |
|
class_vector = one_hot_from_names(initial_class, batch_size=1) |
|
noise_vector = truncated_noise_sample(truncation=truncation, batch_size=1) |
|
|
|
|
|
noise_vector = torch.from_numpy(noise_vector) |
|
class_vector = torch.from_numpy(class_vector) |
|
|
|
|
|
noise_vector = noise_vector.to('cuda') |
|
class_vector = class_vector.to('cuda') |
|
gan_model.to('cuda') |
|
|
|
|
|
with torch.no_grad(): |
|
output = gan_model(noise_vector, class_vector, truncation) |
|
|
|
|
|
output = output.to('cpu') |
|
|
|
|
|
|
|
|
|
|
|
|
|
save_as_images(output) |