Error following ML tutorial

December 4, 2017 1.1k views
Development Ubuntu 16.04


I am following this tutorial:—-running-your-first-style-transfer-experiment

I am having the same problem as posted in the comments.

Originally, the images from this snippet pasted into Jupyter:

contentimage = Image('{}/images/content/venice-boat.jpg'.format(workingdir))
image = Image('{}/images/21styles/starrynight.jpg'.format(workingdir))

were not showing also, but I finally realised this was becasue the Jupyter notebook was created by user science, so home was different to root home, so I setup again in science home and I get the images etc working.

However, when it comes to the point of trying the first style transfer, I get the rror posted in the comments. Here is is:

CalledProcessError Traceback (most recent call last)
in ()
4 # run the command
----> 5 x = subprocess.checkoutput(cmd, universalnewlines=True)

/usr/lib/python3.5/ in check_output(timeout, popenargs, *kwargs)
625 return run(popenargs, stdout=PIPE, timeout=timeout, check=True,
--> 626 *

/usr/lib/python3.5/ in run(input, timeout, check, popenargs, *kwargs)
706 if check and retcode:
707 raise CalledProcessError(retcode, process.args,
--> 708 output=stdout, stderr=stderr)
709 return CompletedProcess(process.args, retcode, stdout, stderr)

CalledProcessError: Command '['python3', '/home/science/styletransfer/PyTorch-Style-Transfer/experiments/', 'eval', '--content-image', '/home/science/styletransfer/PyTorch-Style-Transfer/experiments/images/content/venice-boat.jpg', '--style-image', '/home/science/styletransfer/PyTorch-Style-Transfer/experiments/images/21styles/starrynight.jpg', '--model', '/home/science/styletransfer/PyTorch-Style-Transfer/experiments/models/21styles.model', '--output-image', '/home/science/styletransfer/PyTorch-Style-Transfer/experiments/test.jpg', '--cuda=0']' returned non-zero exit status 1

2 Answers

OK, so I changed the cvall to use python3 not python, and I get the following error instead:

Traceback (most recent call last):
File "", line 287, in <module>
File "", line 44, in main
File "", line 242, in evaluate
stylemodel = Net(ngf=args.ngf)
File "/root/style
transfer/PyTorch-Style-Transfer/experiments/", line 284, in init
model += [upblock(ngf*expansion, 32, 2, normlayer),
File "/root/style
transfer/PyTorch-Style-Transfer/experiments/", line 127, in init
kernelsize=1, stride=1, upsample=stride)
File "/root/style
transfer/PyTorch-Style-Transfer/experiments/", line 167, in init
self.upsamplelayer = torch.nn.Upsample(scalefactor=upsample)
AttributeError: module 'torch.nn' has no attribute 'Upsample'

  • The above was put in wrong place - But it is talking about this. I called it via putty rather than in jupyter, and this is what I see. Any ideas?


I'm not sure if you got this solved but I had the same issue and got it working by upgrading PyTorch to the latest version.

pip3 install
pip3 install torchvision

It seemed to resolve the "AttributeError: module 'torch.nn' has no attribute 'Upsample'" error

You can see what version you're running with:

import torch

I hope that helps!

Have another answer? Share your knowledge.