Hi,
I am following this tutorial: https://www.digitalocean.com/community/tutorials/how-to-perform-neural-style-transfer-with-python-3-and-pytorch#step-2-—-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:
content_image = Image(‘{}/images/content/venice-boat.jpg’.format(workingdir)) style_image = Image(‘{}/images/21styles/starry_night.jpg’.format(workingdir)) display(content_image) display(style_image)
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 () 3 4 # run the command ----> 5 x = subprocess.check_output(cmd, universal_newlines=True)
/usr/lib/python3.5/subprocess.py in check_output(timeout, *popenargs, **kwargs) 624 625 return run(*popenargs, stdout=PIPE, timeout=timeout, check=True, –> 626 **kwargs).stdout 627 628
/usr/lib/python3.5/subprocess.py 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) 710
CalledProcessError: Command ‘[‘python3’, ‘/home/science/style_transfer/PyTorch-Style-Transfer/experiments/main.py’, ‘eval’, ‘–content-image’, ‘/home/science/style_transfer/PyTorch-Style-Transfer/experiments/images/content/venice-boat.jpg’, ‘–style-image’, ‘/home/science/style_transfer/PyTorch-Style-Transfer/experiments/images/21styles/starry_night.jpg’, ‘–model’, ‘/home/science/style_transfer/PyTorch-Style-Transfer/experiments/models/21styles.model’, ‘–output-image’, ‘/home/science/style_transfer/PyTorch-Style-Transfer/experiments/test.jpg’, ‘–cuda=0’]’ returned non-zero exit status 1
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
OK, so I changed the cvall to use python3 not python, and I get the following error instead:
Traceback (most recent call last): File “main.py”, line 287, in <module> main() File “main.py”, line 44, in main evaluate(args) File “main.py”, line 242, in evaluate style_model = Net(ngf=args.ngf) File “/root/style_transfer/PyTorch-Style-Transfer/experiments/net.py”, line 284, in init model += [upblock(ngf*expansion, 32, 2, norm_layer), File “/root/style_transfer/PyTorch-Style-Transfer/experiments/net.py”, line 127, in init kernel_size=1, stride=1, upsample=stride) File “/root/style_transfer/PyTorch-Style-Transfer/experiments/net.py”, line 167, in init self.upsample_layer = torch.nn.Upsample(scale_factor=upsample) AttributeError: module ‘torch.nn’ has no attribute ‘Upsample’
Hi,
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 http://download.pytorch.org/whl/cpu/torch-0.3.0.post4-cp35-cp35m-linux_x86_64.whl 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 print(torch.version)
I hope that helps!
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.