(tensor)
| 14 | return source |
| 15 | |
| 16 | def tensor_to_image(tensor): |
| 17 | image = tensor.mul(255).clamp(0, 255).byte().cpu() |
| 18 | image = image[..., [2, 1, 0]].numpy() |
| 19 | return image |
| 20 | |
| 21 | def image_to_tensor(image): |
| 22 | tensor = torch.clamp(torch.from_numpy(image).float() / 255., 0, 1) |