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

Function uint2tensor4

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

Source from the content-addressed store, hash-verified

72
73# convert uint to 4-dimensional torch tensor
74def uint2tensor4(img):
75 if img.ndim == 2:
76 img = np.expand_dims(img, axis=2)
77 return torch.from_numpy(np.ascontiguousarray(img)).permute(2, 0, 1).float().div(255.).unsqueeze(0)
78
79# convert 2/3/4-dimensional torch tensor to uint
80def tensor2uint(img):

Callers 1

inferenceFunction · 0.90

Calls

no outgoing calls

Tested by 1

inferenceFunction · 0.72