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

train doesn't run: ValueError: not enough values to unpack (expected 3, got 2) #25

Closed
xaionaro opened this issue Mar 4, 2018 · 5 comments

Comments

@xaionaro
Copy link

xaionaro commented Mar 4, 2018

Hello. train doesn't run:

danusya@werewolf:~/fast-neural-style$ python3 neural_style/neural_style.py train --dataset ~/dataset/ --style-image ~/Caleido/Color_Kaleidoscope_2017-6-24_15141.png  --vgg-model-dir caleido_vgg --save-model-dir caleido_model --epochs 2 --cuda 0
/usr/local/lib/python3.5/dist-packages/torchvision/transforms/transforms.py:156: UserWarning: The use of the transforms.Scale transform is deprecated, please use transforms.Resize instead.
  "please use transforms.Resize instead.")
Traceback (most recent call last):
  File "neural_style/neural_style.py", line 210, in <module>
    main()
  File "neural_style/neural_style.py", line 204, in main
    train(args)
  File "neural_style/neural_style.py", line 50, in train
    style = utils.preprocess_batch(style)
  File "/home/danusya/fast-neural-style/neural_style/utils.py", line 59, in preprocess_batch
    (r, g, b) = torch.chunk(batch, 3)
ValueError: not enough values to unpack (expected 3, got 2)
@achaiah
Copy link

achaiah commented Mar 5, 2018

Are you using png images? I ran into this too and found out that this project can only handle jpg.

@xaionaro
Copy link
Author

xaionaro commented Mar 5, 2018

Yep. Ok, thanks, I'll try without png.

@abhiskk
Copy link
Owner

abhiskk commented Mar 5, 2018

As @xaionaro pointed out this might be an issue with the format of image, you can convert the image to relevant format using the following code:

from PIL import Image
content_image = Image.open('/path/to/image')
content_rgb_image = content_image.convert('RGB')
content_rgb_image.save('/path/to/output/image')

@achaiah
Copy link

achaiah commented Mar 5, 2018

@abhiskk - Actually, it would be helpful if this code was incorporated into the project so people can use any type of image. The current error: ValueError: not enough values to unpack (expected 3, got 2) is completely misleading.

@xaionaro - if you want a quick way to convert all png into jpg just install imagemagick and do: mogrify -format jpg *.png

@abhiskk
Copy link
Owner

abhiskk commented Mar 5, 2018

@achaiah - Point noted, I will try to incorporate this soon. Any PRs are also welcome. This code is also part of the pytorch/examples repo, so if you want you can open a PR in that repo also.

@abhiskk abhiskk closed this as completed Mar 16, 2018
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