Open mshmoon opened 6 years ago
Hey,
It is basically a python implementation of the Matlab class color function provided by the Pascal VOC project
https://gist.github.com/wllhf/a4533e0adebe57e3ed06d4b50c8419ae https://gist.github.com/wllhf/a4533e0adebe57e3ed06d4b50c8419ae
What it does is convert the labels (0, 1, …, 21 I think) to a more distinct RGB color code so that you can visualize how the network labeled objects.
Am 06.04.2018 um 13:32 schrieb mshmoon notifications@github.com:
def colormap(n): cmap=np.zeros([n, 3]).astype(np.uint8)
for i in np.arange(n): r, g, b = np.zeros(3)
for j in np.arange(8): r = r + (1<<(7-j))*((i&(1<<(3*j))) >> (3*j)) g = g + (1<<(7-j))*((i&(1<<(3*j+1))) >> (3*j+1)) b = b + (1<<(7-j))*((i&(1<<(3*j+2))) >> (3*j+2)) cmap[i,:] = np.array([r, g, b])
return cmap I do not understand the function,please help me... I use your main code to run a new network, but I can not decode a image from output
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/bodokaiser/piwise/issues/18, or mute the thread https://github.com/notifications/unsubscribe-auth/ABsq8u-TXv10gfRKrsDjp5amIwL2VIo_ks5tl1JhgaJpZM4TJ6IQ.
Sorry,this code have a trouble def call(self, gray_image): size = gray_image.size() print(gray_image) colorimage = torch.ByteTensor(3, size[0], size[1]).fill(0)
for label in range(1, len(self.cmap)):
mask = gray_image[0] == label
**color_image[0][mask] = self.cmap[label][0]
color_image[1][mask] = self.cmap[label][1]
color_image[2][mask] = self.cmap[label][2]**
return color_image
the mask is not a scalar,so it is not a index The 'for' cycle can not be run
You can also index over np.array
as far as I know. What is the problem with for?
index over np.array is not work ,beacause it appears other error,"TypeError: Performing basic indexing on a tensor and encountered an error indexing dim 0 with an object of type numpy.ndarray. "I don't know how to do ,can you answer me?Thank you
def colormap(n): cmap=np.zeros([n, 3]).astype(np.uint8)
I do not understand the function,please help me... I use your main code to run a new network, but I can not decode a image from output