(tensor, path, pad_value=254.0,)
| 13 | |
| 14 | |
| 15 | def save_tensor(tensor, path, pad_value=254.0,): |
| 16 | print('save_tensor', path) |
| 17 | tensor = tensor.to(torch.float).detach().cpu() |
| 18 | if tensor.type() == 'torch.BoolTensor': |
| 19 | tensor = tensor*255 |
| 20 | if len(tensor.shape) == 3: |
| 21 | tensor = tensor.unsqueeze(1) |
| 22 | tensor = make_grid(tensor, pad_value=pad_value, normalize=False).permute(1, 2, 0).numpy().copy() |
| 23 | torchvision.utils.save_image(torch.tensor(tensor).permute(2, 0, 1), path) |
| 24 | convert_color(path) |
nothing calls this directly
no test coverage detected