if i % 100 == 0: a=np.array(buf) plotStats(a,opt.outputFolder+desc) vutils.save_image(text, '%s/real_textures.jpg' % opt.outputFolder, normalize=True) IG=invblend(fake,mixedI,alpha[:,:1],alpha[:,1:2]) vutils.save_image(torch.cat([content[:,:3], mixedI, IG,fake, alpha, rgb_channels(A)], 2), '%s/mosaic_epoch_%03d_%s.jpg' % (opt.outputFolder, epoch, desc), normalize=True) fixnoise=setNoise(fixnoise) for net in Gnets: net.eval() with torch.no_grad(): if False:##do whole mosaic in 1 pass -- warning, takes a lot of memory, do not use unless you have a good reason templates=templates.to(device) fakebig, alpha, A, mixedbig = famosGeneration(targetMosaic, fixnoise, templates.unsqueeze(0), True) else: fakebig, alpha, A, mixedbig = splitW(targetMosaic, fixnoise, templates.unsqueeze(0), famosGeneration) vutils.save_image(mixedbig,'%s/mixed_epoch_%03d_%s.jpg' % (opt.outputFolder, epoch,desc), normalize =True) if True:# vutils.save_image(alpha,'%s/alpha_epoch_%03d_%s.jpg' % (opt.outputFolder, epoch,desc), normalize=False) vutils.save_image(rgb_channels(A), '%s/blenda_epoch_%03d_%s.jpg' % (opt.outputFolder, epoch, desc), normalize=False)##already 01 v=nn.functional.avg_pool2d(A.view(-1, 1, A.shape[2], A.shape[3]), int(16)) vutils.save_image(v,'%s/blendaBW_epoch_%03d_%s.jpg' % (opt.outputFolder, epoch,desc), normalize=False) vutils.save_image(fakebig,'%s/mosaicBig_epoch_%03d_%s.jpg' % (opt.outputFolder, epoch,desc),normalize=True) ##RUN OUT-OF-SAMPLE with torch.no_grad(): try: im=getImage(opt.testImage, bDel=True) if im.shape[2]>targetMosaic.shape[2] or im.shape[3]>targetMosaic.shape[3]: print ("cropping to original mosaic size")
normalize=True) fixnoise = setNoise(fixnoise) vutils.save_image(fixnoise.view(-1, 1, fixnoise.shape[2], fixnoise.shape[3]), '%s/noiseBig_epoch_%03d_%s.jpg' % (opt.outputFolder, epoch, desc), normalize=True) netMix.eval() with torch.no_grad(): if False: ##if desired use this to make prediction in 1 pass, may be good for real-time video fakebig = ganGeneration(targetMosaic, fixnoise) else: fakebig, _, _, _ = splitW(targetMosaic, fixnoise, None, ganGeneration) vutils.save_image(fakebig, '%s/mosaicBig_epoch_%03d_%s.jpg' % (opt.outputFolder, epoch, desc), normalize=True) ##RUN OUT-OF-SAMPLE VIDEO_SAVE_FREQ = 10 with torch.no_grad(): import os t0 = time.time() try: try: files = os.listdir(opt.testImage) os.makedirs(opt.outputFolder + "video/")