shionhonda / viton-gan

Original implementation of the paper "VITON-GAN: Virtual Try-on Image Generator Trained with Adversarial Loss" by Shion Honda.
https://diglib.eg.org/handle/10.2312/egp20191043
MIT License
101 stars 31 forks source link

Mismatch Shape Between Tensors #3

Closed pratiklodha95 closed 5 years ago

pratiklodha95 commented 5 years ago

Does the code assume that the images are pre-resized to the same dimensions as the segment ? Also the tensor from the self.transform has color as first element [3,320,320] whereas torch.from_numpy keeps the arrangement same [320,320,3] and hence multiplication fails

 head_mask_tensor = torch.from_numpy(head_mask) # [0,1]
        feature_head_tensor = person_tensor * head_mask_tensor - (1 - head_mask_tensor) # [-1,1], fill -1 for other parts
        cloth_mask_tensor = torch.from_numpy(cloth_mask) # [0,1]
        cloth_parse_tensor = person_tensor * cloth_mask_tensor + (1 - cloth_mask_tensor) # [-1,1], fill 1 for other parts
        body_mask_tensor = torch.from_numpy(body_mask).unsqueeze(0) # Tensor [0,1]
pratiklodha95 commented 5 years ago

The error is nothing to do with shape, but the transform method needs to be updated to

transform = transforms.Compose([transforms.ToTensor(), transforms.Normalize((0.5,), (0.5,)) ])