Convert image tensor to array.
(image: torch.Tensor)
| 41 | |
| 42 | |
| 43 | def 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 | |
| 53 | def array2tensor(image: np.ndarray) -> torch.Tensor: |
no test coverage detected