jcjohnson / neural-style

Torch implementation of neural style algorithm
MIT License
18.31k stars 2.7k forks source link

[SOLVED]: ERROR: neural_style.lua:57: attempt to index a nil value #434

Closed zenny closed 6 years ago

zenny commented 6 years ago

Hi, I am trying to run this script in an Ubuntu 14.04 machine (following https://github.com/jcjohnson/neural-style/blob/master/INSTALL.md) using only CPU with the following command, but encountering an error as stated below:

$ th neural_style.lua -style_image examples/inputs/picasso_selfport1907.jpg -content_image <INPUT IMAGE>  -output_image <OUTPUT IMAGE> -model_file models/nin_imagenet_conv.caffemodel -proto_file models/train_val.prototxt -gpu -1 -num_iterations 1000 -seed 123 -content_layers relu0,relu3,relu7,relu12 -style_layers relu0,relu3,relu7,relu12 -content_weight 10 -style_weight 1000 -image_size 512 -optimizer adam
Couldn't load models/nin_imagenet_conv.caffemodel
/mnt/homepool/HOME/zenny/Downloads/mono2colour/torch/install/bin/luajit: neural_style.lua:57: attempt to index a nil value
stack traceback:
    neural_style.lua:57: in function 'main'
    neural_style.lua:601: in main chunk
    [C]: in function 'dofile'
    ...lour/torch/install/lib/luarocks/rocks/trepl/scm-1/bin/th:150: in main chunk
    [C]: at 0x00406670

I do see two issues here, but could not figure out how that could be solved:

  1. Couldn't load models/nin_imagenet_conv.caffemodel.

Though loadcaffe is installed.

$ luarocks list 
...
loadcaffe
   1.0-0 (installed) - /mnt/homepool/HOME/zenny/Downloads/mono2colour/torch/install/lib/luarocks/rocks
...
  1. neural_style.lua:57: in function 'main' neural_style.lua:601: in main chunk

New to lua and dl, so any input appreciated. Thanks.

Cheers, /z

htoyryla commented 6 years ago

From the error message it appears that the files nin_imagenet_conv.caffemodel and train_val.prototxt are not in the models/ directory. You need to dowload them from the link in the readme file.

zenny commented 6 years ago

@htoyryla so nice of you for the prompt pointer to the solution. Just skipped the link in the readme.md file. It worked as it should.