MCPcopy Create free account
hub / github.com/Tian-one/tps-inbetween / tensor2numpy

Function tensor2numpy

demo.py:34–38  ·  view source on GitHub ↗
(tensor, rgb_range=1.)

Source from the content-addressed store, hash-verified

32 return rgb
33
34def tensor2numpy(tensor, rgb_range=1.):
35 rgb_coefficient = 255 / rgb_range
36 img = tensor.mul(rgb_coefficient).clamp(0, 255).round()
37 img = np.transpose(img.cpu().detach().numpy(), (1, 2, 0)).astype(np.uint8)
38 return img
39
40def np2Tensor(img, rgb_range=1, n_colors=1):
41 img = img.astype('float64')

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected