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

No folder named "Labels", Tuple Index out of range, size mismatch. #17

Open
NicWickman opened this issue Feb 5, 2018 · 6 comments
Open

Comments

@NicWickman
Copy link

First I think there's a small error in the README tutorial: Should the correct directory should be data/labels instead of data/classes ?

Anyways, I get the following traceback:

/home/nic/.conda/envs/piwise/lib/python3.6/site-packages/torch/nn/functional.py:1423: UserWarning: nn.functional.upsample_bilinear is deprecated. Use nn.functional.upsample instead.
  warnings.warn("nn.functional.upsample_bilinear is deprecated. Use nn.functional.upsample instead.")
/home/nic/machineLearning/Automatter/machine-learning/piwise/piwise/criterion.py:13: UserWarning: Implicit dimension choice for log_softmax has been deprecated. Change the call to include dim=X as an argument.
  return self.loss(F.log_softmax(outputs), targets)
Traceback (most recent call last):
  File "main.py", line 163, in <module>
    main(parser.parse_args())
  File "main.py", line 138, in main
    train(args, model)
  File "main.py", line 85, in train
    board.image(color_transform(outputs[0].cpu().max(0)[1].data),
  File "/home/nic/machineLearning/Automatter/machine-learning/piwise/piwise/transform.py", line 48, in __call__
    color_image = torch.ByteTensor(3, size[1], size[2]).fill_(0)
IndexError: tuple index out of range

My first attempt at an obvious solution was to change it to

color_image = torch.ByteTensor(3, size[0], size[1]).fill_(0)

But I still have a size mismatch error. Tensor is 256 x 256 and Mask is 256.

@bodokaiser
Copy link
Owner

First I think there's a small error in the README tutorial: Should the correct directory should be data/labels instead of data/classes ?

Yes, I think it should be 'data/labels'. The README was not updated a while.

My first attempt at an obvious solution was to change it to
color_image = torch.ByteTensor(3, size[0], size[1]).fill_(0)
But I still have a size mismatch error. Tensor is 256 x 256 and Mask is 256.

The last time I used piwise which was more then a year ago. It worked straight out of the box, however memories are prone to failures. Some things I would suggest:

  1. Did any pytorch api change?
  2. Try different indices (debug the program)?
  3. You used the Pascal VOC 2012 data?

I am not sure if this has any relevance but the color_transform takes an image labeled 0 to 17, 255 and converts it into a color images where each label has distinct colors. The implementation was more or less copy and paste from the Matlab script Pascal VOC 2012 provides.

@SleyAI
Copy link

SleyAI commented May 5, 2018

I'm having the same issue. Did you find a solution?

@NicWickman
Copy link
Author

NicWickman commented May 5, 2018 via email

@fantasyzl
Copy link

The problem should be in transform.py. You can try deleting the lines 101 to 111 in main.py and try again.

@guizilaile23
Copy link

board.image(color_transform(targets[0].cpu()[0].data) will fix

@swg209
Copy link

swg209 commented Jul 31, 2019

This is caused by the gray_image 's axis, after add this line code
gray_image = gray_image.view(1,256,256)
in transform.py line 47,
the issue is solved.
def __call__(self, gray_image):
gray_image = gray_image.view(1,256,256)
size = gray_image.size()
color_image = torch.ByteTensor(3, size[1], size[2]).fill_(0)

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

6 participants