(output, n_label, imtype=np.uint8)
| 71 | return image_numpy.astype(imtype) |
| 72 | |
| 73 | def tensor2label(output, n_label, imtype=np.uint8): |
| 74 | if isinstance(output, torch.autograd.Variable): |
| 75 | output = output.data |
| 76 | if len(output.size()) == 5: |
| 77 | output = output[0, -1] |
| 78 | if len(output.size()) == 4: |
| 79 | output = output[0] |
| 80 | output = output.cpu().float() |
| 81 | if output.size()[0] > 1: |
| 82 | output = output.max(0, keepdim=True)[1] |
| 83 | #print(output.size()) |
| 84 | output = Colorize(n_label)(output) |
| 85 | output = np.transpose(output.numpy(), (1, 2, 0)) |
| 86 | #img = Image.fromarray(output, "RGB") |
| 87 | return output.astype(imtype) |
| 88 | |
| 89 | def tensor2flow(output, imtype=np.uint8): |
| 90 | if isinstance(output, torch.autograd.Variable): |
no test coverage detected