import torch from torchvision import utils from model import StyledGenerator generator = StyledGenerator(512).cuda() generator.load_state_dict(torch.load('checkpoint/130000.model')) mean_style = None step = 6 shape = 4 * 2**step for i in range(10): style = generator.mean_style(torch.randn(1024, 512).cuda()) if mean_style is None: mean_style = style else: mean_style += style mean_style /= 10 image = generator( torch.randn(50, 512).cuda(), step=step, alpha=1, mean_style=mean_style, style_weight=0.7,
device = 'cuda' generator = StyledGenerator(512).to(device) generator.load_state_dict(torch.load('checkpoint/180000.model')) generator.eval() mean_style = None step = 7 alpha = 1 shape = 4 * 2**step with torch.no_grad(): for i in range(10): style = generator.mean_style(torch.randn(1024, 512).to(device)) if mean_style is None: mean_style = style else: mean_style += style mean_style /= 10 image = generator( torch.randn(15, 512).to(device), step=step, alpha=alpha, mean_style=mean_style, style_weight=0.7,