MCPcopy Create free account
hub / github.com/MotrixLab/AiOS / tensor2array

Function tensor2array

detrsmpl/core/renderer/torch3d_renderer/utils.py:43–50  ·  view source on GitHub ↗

Convert image tensor to array.

(image: torch.Tensor)

Source from the content-addressed store, hash-verified

41
42
43def tensor2array(image: torch.Tensor) -> np.ndarray:
44 """Convert image tensor to array."""
45 image = image.detach().cpu().numpy()
46 image = normalize(image,
47 origin_value_range=(0, 1),
48 out_value_range=(0, 255),
49 dtype=np.uint8)
50 return image
51
52
53def array2tensor(image: np.ndarray) -> torch.Tensor:

Callers 2

_write_imagesMethod · 0.85
forwardMethod · 0.85

Calls 2

normalizeFunction · 0.85
detachMethod · 0.45

Tested by

no test coverage detected