MCPcopy Create free account
hub / github.com/OpenTalker/StyleHEAT / tensor2grayimg

Function tensor2grayimg

utils/common.py:71–79  ·  view source on GitHub ↗
(var)

Source from the content-addressed store, hash-verified

69
70
71def tensor2grayimg(var):
72 assert len(var.shape) == 2
73 if torch.is_tensor(var):
74 var = var.cpu().detach().numpy()
75# var = ((var + 1) / 2)
76 var[var < 0] = 0
77 var[var > 1] = 1
78 var = var * 255
79 return Image.fromarray(var.astype('uint8'), 'L')
80
81
82def img2tensor(img):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected