MCPcopy Create free account
hub / github.com/VisionXLab/OF-Diff / uint2tensor3

Function uint2tensor3

ldm/modules/image_degradation/utils_image.py:282–285  ·  view source on GitHub ↗
(img)

Source from the content-addressed store, hash-verified

280
281# convert uint to 3-dimensional torch tensor
282def uint2tensor3(img):
283 if img.ndim == 2:
284 img = np.expand_dims(img, axis=2)
285 return torch.from_numpy(np.ascontiguousarray(img)).permute(2, 0, 1).float().div(255.)
286
287
288# convert 2/3/4-dimensional torch tensor to uint

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected