MCPcopy Create free account
hub / github.com/csxmli2016/MARCONetPlusPlus / tensor2uint

Function tensor2uint

utils/utils_image.py:80–84  ·  view source on GitHub ↗
(img)

Source from the content-addressed store, hash-verified

78
79# convert 2/3/4-dimensional torch tensor to uint
80def tensor2uint(img):
81 img = img.data.squeeze().float().clamp_(0, 1).cpu().numpy()
82 if img.ndim == 3:
83 img = np.transpose(img, (1, 2, 0))
84 return np.uint8((img*255.0).round())
85
86
87if __name__ == '__main__':

Callers 1

inferenceFunction · 0.90

Calls

no outgoing calls

Tested by 1

inferenceFunction · 0.72