jcjohnson / fast-neural-style

Feedforward style transfer
4.28k stars 814 forks source link

problem with output_dir #34

Open toniaguirre opened 8 years ago

toniaguirre commented 8 years ago

Hi guys! So I have used the normal neural-style code for some weeks, and now I am trying this one. For some strange reason, when I use as inputs individual files, it runs without problems. However, when I try to use folders as inputs I get an error: bad argument #1 to 'lower'. I searched on the internet and the only thing I can find is this: https://github.com/jcjohnson/neural-style/issues/62, but I really don't understand the solution posted by this guys. I post what I run and what I get:

[antonioa1@wh-520-9-5 fnsm]$ th fast_neural_style.lua -model models/instance_norm/1.t7 -input_image inputs/1.jpg -image_size 100 -backend cuda -use_cudnn 1
Writing output image to out.png 

[antonioa1@wh-520-9-5 fnsm]$ th fast_neural_style.lua -model models/instance_norm/1.t7 -input_dir inputs/ -output_dir out/ -image_size 100 -backend cuda -use_cudnn 1
/home/a/antonioa1/torch/install/bin/luajit: ./fast_neural_style/utils.lua:119: bad argument #1 to 'lower' (string expected, got no value)
stack traceback:
    [C]: in function 'lower'
    ./fast_neural_style/utils.lua:119: in function 'is_image_file'
    fast_neural_style.lua:109: in function 'main'
    fast_neural_style.lua:124: in main chunk
    [C]: in function 'dofile'
    ...ioa1/torch/install/lib/luarocks/rocks/trepl/scm-1/bin/th:145: in main chunk
    [C]: at 0x004066d0
htoyryla commented 8 years ago

What do you have inside inputs/ ? The error occurs when testing that the input files are supported image file types. Make sure there are no files without an extension (such as "filename" instead of "filename.txt"). It looks like the code breaks when the filename has no extension.

htoyryla commented 8 years ago

Just to document this: Line 119 in utils.lua fails if the filename checked has no extension. Tested in th:

th> filename = "inputs/kukkuu"
                                                                      [0.0001s]
th> ext = string.lower(paths.extname(filename))
[string "ext = string.lower(paths.extname(filename))"]:1: bad argument #1 to 'lower' (string expected, got no value)
stack traceback:
    [C]: in function 'lower'
    [string "ext = string.lower(paths.extname(filename))"]:1: in main chunk
    [C]: in function 'xpcall'
    /home/hannu/torch/install/share/lua/5.1/trepl/init.lua:670: in function 'repl'
    ...annu/torch/install/lib/luarocks/rocks/trepl/scm-1/bin/th:199: in main chunk
    [C]: at 0x00406670

Looks like this would work:

ext = string.lower(paths.extname(filename) or "")
toniaguirre commented 8 years ago

thank you very much @htoyryla . You were completely right. I had some folders inside the input folder, as well as a .mov file. I really appreciate your fast respond, wish you the best!

htoyryla commented 8 years ago

I think we should perhaps leave this open because the problem is still in the code and could be corrected.