File size: 664 Bytes
134a749
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import torch
import torchvision.transforms.functional as F

def compose_img(gt_img, fake_img, im_parse):

    seg_head = torch.logical_or(im_parse == 1, im_parse == 2)
    seg_head = torch.logical_or(seg_head, im_parse == 4)
    seg_head = torch.logical_or(seg_head, im_parse == 13)

    true_head = gt_img * seg_head
    true_parts = true_head
    
    generated_body = (F.pil_to_tensor(fake_img).cuda() / 255) * (~(seg_head))

    return true_parts + generated_body

def compose_img_dresscode(gt_img, fake_img, im_head):

    seg_head = im_head
    true_head = gt_img * seg_head
    generated_body = fake_img * ~(seg_head)

    return true_head + generated_body