def draw_concat(Gs, reals, NoiseAmp, in_s, mode, fixed_noise, opt): if len(Gs) > 0: if mode == 'rand': count = 0 for G, real_curr, real_next, noise_amp in zip(Gs, reals, reals[1:], NoiseAmp): if not opt.add_inject or count >= opt.inject_level: if count == 0: G_z = in_s z = fixed_noise[count] if count == opt.inject_level and opt.add_inject: z_in = noise_amp * z + real_curr.cuda() G_z = real_curr.cuda() else: G_z = G_z[:, :, 0:real_curr.shape[2], 0:real_curr.shape[3]] z_in = noise_amp * z + G_z if count > opt.switch_scale: G_z = G(z_in.detach()) else: G_z = G(z_in.detach(), G_z) G_z = imresize2(G_z.detach(), 1 / opt.scale_factor, opt) G_z = G_z[:, :, 0:real_next.shape[2], 0:real_next.shape[3]] count += 1 return G_z
def draw_concat(Gs, reals, NoiseAmp, in_s, mode, inject_level, opt): if len(Gs) > 0: if mode == 'rand': count = 0 for G,real_curr,real_next,noise_amp in zip(Gs,reals,reals[1:],NoiseAmp): print("cnt " + str(count)) if count == 0: z = generate_noise2([1, 3, real_curr.shape[2], real_curr.shape[3]], device=opt.device) G_z = in_s else: z = generate_noise2([1, opt.nc_z,real_curr.shape[2], real_curr.shape[3]], device=opt.device) G_z = G_z[:,:,0:real_curr.shape[2],0:real_curr.shape[3]] if count == inject_level: print("Inject") z_in = noise_amp*z + real_curr.cuda() else: z_in = noise_amp*z+G_z if count > opt.switch_scale: G_z = G(z_in.detach()) else: G_z = G(z_in.detach(), G_z) G_z = imresize2(G_z.detach(),1/opt.scale_factor,opt) G_z = G_z[:,:,0:real_next.shape[2],0:real_next.shape[3]] count += 1 return G_z
def draw_concat(Gs, reals, NoiseAmp, in_s, mode, opt): if len(Gs) > 0: if mode == 'rand': count = 0 for G, real_curr, real_next, noise_amp in zip( Gs, reals, reals[1:], NoiseAmp): G = G.cuda() if count == 0: z = generate_noise2( [1, 3, real_curr.shape[2], real_curr.shape[3]], device=opt.device) G_z = in_s else: z = generate_noise2( [1, opt.nc_z, real_curr.shape[2], real_curr.shape[3]], device=opt.device) G_z = G_z[:, :, 0:real_curr.shape[2], 0:real_curr.shape[3]] z_in = noise_amp * z + G_z if count > opt.switch_scale: G_z = G(z_in.detach()) else: G_z = G(z_in.detach(), G_z) G_z = imresize2(G_z.detach(), 1 / opt.scale_factor, opt) G_z = G_z[:, :, 0:real_next.shape[2], 0:real_next.shape[3]] count += 1 if mode == 'rec': count = 0 for G, real_curr, real_next, noise_amp in zip( Gs, reals, reals[1:], NoiseAmp): G = G.cuda() if count == 0: size = list(real_curr.size()) #print(size) G_z = generate_noise2(size, device=opt.device) G_z = G_z[:, :, 0:real_curr.shape[2], 0:real_curr.shape[3]] if count > opt.switch_scale: G_z = G(G_z) else: G_z = G(G_z, G_z) G_z = imresize2(G_z.detach(), 1 / opt.scale_factor, opt) G_z = G_z[:, :, 0:real_next.shape[2], 0:real_next.shape[3]] count += 1 return G_z