(tensor)
| 378 | return output |
| 379 | |
| 380 | def tensor_to_image(tensor): |
| 381 | image = tensor.mul(255).clamp(0, 255).byte().cpu() |
| 382 | image = image[..., [2, 1, 0]].numpy() |
| 383 | return image |
| 384 | |
| 385 | def image_to_tensor(image): |
| 386 | tensor = torch.clamp(torch.from_numpy(image).float() / 255., 0, 1) |