MCPcopy Create free account
hub / github.com/NVIDIA/vid2vid / tensor2label

Function tensor2label

util/util.py:73–87  ·  view source on GitHub ↗
(output, n_label, imtype=np.uint8)

Source from the content-addressed store, hash-verified

71 return image_numpy.astype(imtype)
72
73def 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
89def tensor2flow(output, imtype=np.uint8):
90 if isinstance(output, torch.autograd.Variable):

Callers 1

save_all_tensorsFunction · 0.85

Calls 1

ColorizeClass · 0.85

Tested by

no test coverage detected