Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there some question in transform.py? #18

Open
mshmoon opened this issue Apr 6, 2018 · 4 comments
Open

Is there some question in transform.py? #18

mshmoon opened this issue Apr 6, 2018 · 4 comments

Comments

@mshmoon
Copy link

mshmoon commented Apr 6, 2018

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

@bodokaiser
Copy link
Owner

bodokaiser commented Apr 6, 2018 via email

@mshmoon
Copy link
Author

mshmoon commented Apr 9, 2018

Sorry,this code have a trouble
def call(self, gray_image):
size = gray_image.size()
print(gray_image)
color_image = 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

@bodokaiser
Copy link
Owner

You can also index over np.array as far as I know. What is the problem with for?

@InstantWindy
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants