MCPcopy Create free account
hub / github.com/OpenGVLab/DragGAN / tensor2tensorlab

Function tensor2tensorlab

draggan/deprecated/stylegan2/lpips/util.py:70–82  ·  view source on GitHub ↗
(image_tensor,to_norm=True,mc_only=False)

Source from the content-addressed store, hash-verified

68 return torch.Tensor(np_obj[:, :, :, np.newaxis].transpose((3, 2, 0, 1)))
69
70def tensor2tensorlab(image_tensor,to_norm=True,mc_only=False):
71 # image tensor to lab tensor
72 from skimage import color
73
74 img = tensor2im(image_tensor)
75 img_lab = color.rgb2lab(img)
76 if(mc_only):
77 img_lab[:,:,0] = img_lab[:,:,0]-50
78 if(to_norm and not mc_only):
79 img_lab[:,:,0] = img_lab[:,:,0]-50
80 img_lab = img_lab/100.
81
82 return np2tensor(img_lab)
83
84def tensorlab2tensor(lab_tensor,return_inbnd=False):
85 from skimage import color

Callers

nothing calls this directly

Calls 2

tensor2imFunction · 0.85
np2tensorFunction · 0.85

Tested by

no test coverage detected