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

Function tensor2uint

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

Source from the content-addressed store, hash-verified

287
288# convert 2/3/4-dimensional torch tensor to uint
289def tensor2uint(img):
290 img = img.data.squeeze().float().clamp_(0, 1).cpu().numpy()
291 if img.ndim == 3:
292 img = np.transpose(img, (1, 2, 0))
293 return np.uint8((img*255.0).round())
294
295
296# --------------------------------------------

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected