MCPcopy Create free account
hub / github.com/cszn/BSRGAN / tensor2uint

Function tensor2uint

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

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected