print('%d/100' % i)
            # get batch of test samples
            images, _, segs, txt_data, txt_len, captions, *_ = next(iter(dataloader))

            images = images.cuda()
            segs = segs.cuda()    
            txt_data = txt_data.cuda()
            bimages = images

            netG.eval()
            netEs.eval()
            netEb.eval()

            # alignment
            if align == 'shape':
                bimages = roll(images, 2, dim=0) # for text and seg mismatched backgrounds
                bsegs   = roll(segs, 2, dim=0) # for text and seg mismatched backgrounds
            elif align == 'background':
                segs = roll(segs, 1, dim=0) # for text mismatched segmentations
            elif align == 'all':
                bimages = images.clone()
                bsegs   = segs.clone()
            elif align == 'none':
                bimages = roll(images, 2, dim=0) # for text and seg mismatched backgrounds
                segs    = roll(segs, 1, dim=0) # for text mismatched segmentations
                bsegs   = roll(segs, 2, dim=0) # for text and seg mismatched backgrounds

            np_segs    = to_numpy(segs)
            np_bsegs   = to_numpy(bsegs)
            np_images  = to_numpy(images)
            np_bimages = to_numpy(bimages)
    images = images.cuda()
    segs = segs.cuda()
    txt_data = txt_data.cuda()
    bimages = images

    netG.eval()
    netEs.eval()
    netEb.eval()

    vis_samples = [None for i in range(8)]
    for i in range(6):
        # alignment
        # bimages = roll(images, i+2, dim=0) # for text and seg mismatched backgrounds
        # segs = roll(segs, i+1, dim=0) # for text mismatched segmentations
        txt_data = roll(txt_data, i + 1)
        txt_len = roll(txt_len, i + 1)

        # np to save
        np_segs = np.repeat(to_numpy(segs), 3, 1) * 2 - 1
        np_images = to_numpy(images)
        np_bimages = to_numpy(bimages)

        # generate testing results
        vis_samples[0] = np_images
        vis_samples[1] = np_bimages

        segs_code = netEs(segs)
        bkgs_code = netEb(bimages)

        *_, f_images, z_list = netG(txt_data, txt_len, segs_code, bkgs_code)
Exemple #3
0
    images, _, segs, txt_data, txt_len, captions, *_ = next(iter(dataloader))

    images = images.cuda()
    segs = segs.cuda()
    txt_data = txt_data.cuda()
    bimages = images

    netG.eval()
    netEs.eval()
    netEb.eval()

    vis_samples = [None for i in range(4 + 5 * 2)]
    for i in range(6):
        # alignment
        # bimages = roll(images, i+2, dim=0) # for text and seg mismatched backgrounds
        segs = roll(segs, i + 1, dim=0)  # for text mismatched segmentations
        if i == 5:
            segs = torch.zeros(segs.shape).cuda()

        # np to save
        np_segs = np.repeat(to_numpy(segs), 3, 1) * 2 - 1
        np_images = to_numpy(images)
        np_bimages = to_numpy(bimages)

        # generate testing results
        vis_samples[0] = np_images
        vis_samples[1] = np_bimages
        vis_samples[2 + i * 2] = np_segs

        segs_code = netEs(segs)
        bkgs_code = netEb(bimages)