[SOLVED]Convert color of tensors

Add one note, that might not be the case when you use a cmap in matplotlib.
If you have a manual colormap that is torch.Tensor with shape [256, 3], you could try this cool method:

color_map = #Tensor of shape(256,3)
gray_image = (gray_image * 255).long() # Tensor values between 0 and 255 and LongTensor and shape of (512,512)
output = color_map[gray_image] #Tensor of shape (512,512,3)

from