Skip to content

Instantly share code, notes, and snippets.

@cvalenzuela
Last active July 22, 2019 19:10
Show Gist options
  • Save cvalenzuela/69fab737f85065041b113e0ee3c34297 to your computer and use it in GitHub Desktop.
Save cvalenzuela/69fab737f85065041b113e0ee3c34297 to your computer and use it in GitHub Desktop.
## Sample code to generate an image using the
## pre-trained PGAN celebAHQ-512 checkpoint from the Pytorch Hub
import torch
use_gpu = True if torch.cuda.is_available() else False
# Load the model from the Pytorch Hub
model = torch.hub.load('facebookresearch/pytorch_GAN_zoo:hub',
'PGAN', model_name='celebAHQ-512',
pretrained=True, useGPU=use_gpu)
# Generate one image
noise, _ = model.buildNoiseData(1)
with torch.no_grad():
generated_image = model.test(noise)
# Now generated_image contains our generated image! 🌞
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment