jcjohnson / neural-style

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

Caffe Example Models? #120

Open 3DTOPO opened 8 years ago

3DTOPO commented 8 years ago

I am interested in training my own model(s) so I thought I would start with the Caffe examples. (I think that is the right approach - I would be very open to suggestions!). However; I can't get any of them to run.

I am using Caffe "Release Candidater" 1.0.0 RC2 version. I installed the binary Caffe models by doing this (for each directory):

cd caffe-rc2/
scripts/download_model_binary.py    models/bvlc_reference_caffenet

I am not sure which layer(s) I would use for the content layer, but it doesn't seem to matter I get this error regardless:

th neural_style.lua -style_layers relu1,relu2,relu3,relu4,relu5 -content_layers relu6 -proto_file ./models/bvlc_reference_caffenet/deploy.prototxt -model_file ./models/bvlc_reference_caffenet/bvlc_reference_caffenet.caffemodel  -gpu 0 -backend cudnn -print_iter 10
Couldn't load /home/prime/caffe-rc2/models/bvlc_reference_caffenet/bvlc_reference_caffenet.caffemodel
/home/prime/torch/install/bin/luajit: neural_style.lua:79: attempt to index a nil value
stack traceback:
    neural_style.lua:79: in function 'main'
    neural_style.lua:490: in main chunk
    [C]: in function 'dofile'
    ...rime/torch/install/lib/luarocks/rocks/trepl/scm-1/bin/th:145: in main chunk
    [C]: at 0x00406670

models/bvlc_reference_rcnn_ilsvrc13:

th neural_style.lua  -style_layers relu1,relu2,relu3,relu4,relu5,relu6 -content_layers relu7 -proto_file ./models/bvlc_reference_rcnn_ilsvrc13/deploy.prototxt -model_file ./models/bvlc_reference_rcnn_ilsvrc13/bvlc_reference_rcnn_ilsvrc13.caffemodel  -gpu 0 -backend cudnn -print_iter 20
Successfully loaded /home/prime/caffe-rc2/models/bvlc_reference_rcnn_ilsvrc13/bvlc_reference_rcnn_ilsvrc13.caffemodel
/home/prime/torch/install/bin/luajit: .../models/bvlc_reference_rcnn_ilsvrc13/deploy.prototxt.lua:6: attempt to index global 'inn' (a nil value)
stack traceback:
    .../models/bvlc_reference_rcnn_ilsvrc13/deploy.prototxt.lua:6: in main chunk
    [C]: in function 'dofile'
    ./loadcaffe_wrapper.lua:49: in function 'load'
    neural_style.lua:79: in function 'main'
neural_style.lua:490: in main chunk
[C]: in function 'dofile'
    ...rime/torch/install/lib/luarocks/rocks/trepl/scm-1/bin/th:145: in main chunk
    [C]: at 0x00406670

models/bvlc_alexnet:

th neural_style.lua -style_layers relu1,relu2,relu3,relu4,relu5  -content_layers relu7  -model_file ./models/bvlc_alexnet/bvlc_alexnet.caffemodel  -proto_file  ./models/bvlc_alexnet/deploy.prototxt  -gpu 0 -backend cudnn -print_iter 20
Successfully loaded /home/prime/caffe-rc2/models/bvlc_alexnet/bvlc_alexnet.caffemodel
MODULE data UNDEFINED
warning: module 'data [type 5]' not found
/home/prime/torch/install/bin/luajit: .../prime/caffe-rc2/models/bvlc_alexnet/deploy.prototxt.lua:6:     attempt to index global 'inn' (a nil value)
stack traceback:
    .../prime/caffe-rc2/models/bvlc_alexnet/deploy.prototxt.lua:6: in main chunk
    [C]: in function 'dofile'
    ./loadcaffe_wrapper.lua:49: in function 'load'
    neural_style.lua:79: in function 'main'
    neural_style.lua:490: in main chunk
    [C]: in function 'dofile'
    ...rime/torch/install/lib/luarocks/rocks/trepl/scm-1/bin/th:145: in main chunk
    [C]: at 0x00406670

models/bvlc_googlenet: I have no idea layer names, but get this error regardless (looks like it needs some Inception data or something too):

th neural_style.lua -style_layers conv1/relu_7x7  -content_layers inception_5b/relu_1x1  -model_file ./models/bvlc_googlenet/bvlc_googlenet.caffemodel  -proto_file ./models/bvlc_googlenet/deploy.prototxt  -gpu 0 -backend cudnn -print_iter 20

Successfully loaded ./models/bvlc_googlenet/bvlc_googlenet.caffemodel MODULE data UNDEFINED warning: module 'data [type 5]' not found MODULE label_data_1_split UNDEFINED warning: module 'label_data_1_split [type 22]' not found MODULE pool2/3x3_s2_pool2/3x3_s2_0_split UNDEFINED warning: module 'pool2/3x3_s2_pool2/3x3_s2_0_split [type 22]' not found MODULE inception_3a/output UNDEFINED warning: module 'inception_3a/output [type 3]' not found MODULE inception_3a/output_inception_3a/output_0_split UNDEFINED warning: module 'inception_3a/output_inception_3a/output_0_split [type 22]' not found MODULE inception_3b/output UNDEFINED warning: module 'inception_3b/output [type 3]' not found MODULE pool3/3x3_s2_pool3/3x3_s2_0_split UNDEFINED warning: module 'pool3/3x3_s2_pool3/3x3_s2_0_split [type 22]' not found MODULE inception_4a/output UNDEFINED warning: module 'inception_4a/output [type 3]' not found MODULE inception_4a/output_inception_4a/output_0_split UNDEFINED warning: module 'inception_4a/output_inception_4a/output_0_split [type 22]' not found MODULE inception_4b/output UNDEFINED warning: module 'inception_4b/output [type 3]' not found MODULE inception_4b/output_inception_4b/output_0_split UNDEFINED warning: module 'inception_4b/output_inception_4b/output_0_split [type 22]' not found MODULE inception_4c/output UNDEFINED warning: module 'inception_4c/output [type 3]' not found MODULE inception_4c/output_inception_4c/output_0_split UNDEFINED warning: module 'inception_4c/output_inception_4c/output_0_split [type 22]' not found MODULE inception_4d/output UNDEFINED warning: module 'inception_4d/output [type 3]' not found MODULE inception_4d/output_inception_4d/output_0_split UNDEFINED warning: module 'inception_4d/output_inception_4d/output_0_split [type 22]' not found MODULE inception_4e/output UNDEFINED warning: module 'inception_4e/output [type 3]' not found MODULE pool4/3x3_s2_pool4/3x3_s2_0_split UNDEFINED warning: module 'pool4/3x3_s2_pool4/3x3_s2_0_split [type 22]' not found MODULE inception_5a/output UNDEFINED warning: module 'inception_5a/output [type 3]' not found MODULE inception_5a/output_inception_5a/output_0_split UNDEFINED warning: module 'inception_5a/output_inception_5a/output_0_split [type 22]' not found MODULE inception_5b/output UNDEFINED warning: module 'inception_5b/output [type 3]' not found /home/prime/torch/install/bin/luajit: ...rime/caffe-rc2/models/bvlc_googlenet/deploy.prototxt.lua:8: attempt to index global 'inn' (a nil value) stack traceback: ...rime/caffe-rc2/models/bvlc_googlenet/deploy.prototxt.lua:8: in main chunk [C]: in function 'dofile' ./loadcaffe_wrapper.lua:49: in function 'load' neural_style.lua:79: in function 'main' neural_style.lua:490: in main chunk [C]: in function 'dofile' ...rime/torch/install/lib/luarocks/rocks/trepl/scm-1/bin/th:145: in main chunk [C]: at 0x00406670

jcjohnson commented 8 years ago

At least some of those errors are due to [loadcaffe][(https://github.com/szagoruyko/loadcaffe); it does not work with arbitrary caffe models. For example it does not support AlexNet with the nn backend or GoogLeNet.

3DTOPO commented 8 years ago

Good to know, thank you. Any idea about the others? Eg. should it be possible to get it to work with bvlc_reference_caffenet and or bvlc_reference_rcnn_ilsvrc13?