luanfujun / deep-painterly-harmonization

Code and data for paper "Deep Painterly Harmonization": https://arxiv.org/abs/1804.03189
6.08k stars 628 forks source link

"attempt to index a nil value" while trying to reproduce the results #5

Closed 2m closed 6 years ago

2m commented 6 years ago

I get

luajit: neural_paint.lua:140: attempt to index a nil value
stack traceback:
        neural_paint.lua:140: in function 'main'
        neural_paint.lua:739: in main chunk
        [C]: in function 'dofile'
        /usr/bin/th:150: in main chunk
        [C]: at 0x00404680

while trying to reproduce the results while folllowing the directions in the README.

Full logs:

Successfully loaded models/VGG_ILSVRC_19_layers.caffemodel
conv1_1: 64 3 3 3
conv1_2: 64 64 3 3
conv2_1: 128 64 3 3
conv2_2: 128 128 3 3
conv3_1: 256 128 3 3
conv3_2: 256 256 3 3
conv3_3: 256 256 3 3
conv3_4: 256 256 3 3
conv4_1: 512 256 3 3
conv4_2: 512 512 3 3
conv4_3: 512 512 3 3
conv4_4: 512 512 3 3
conv5_1: 512 512 3 3
conv5_2: 512 512 3 3
conv5_3: 512 512 3 3
conv5_4: 512 512 3 3
fc6: 1 1 25088 4096
fc7: 1 1 4096 4096
fc8: 1 1 4096 1000
Running optimization with L-BFGS
   creating recyclable direction/step/history buffers
   function value changing less than tolX
Gpu, idx      =         0       1
idx=0, classified label=Art Nouveau (Modern), weight=1.203930
Successfully loaded models/VGG_ILSVRC_19_layers.caffemodel
conv1_1: 64 3 3 3
conv1_2: 64 64 3 3
conv2_1: 128 64 3 3
conv2_2: 128 128 3 3
conv3_1: 256 128 3 3
conv3_2: 256 256 3 3
conv3_3: 256 256 3 3
conv3_4: 256 256 3 3
conv4_1: 512 256 3 3
conv4_2: 512 512 3 3
conv4_3: 512 512 3 3
conv4_4: 512 512 3 3
conv5_1: 512 512 3 3
conv5_2: 512 512 3 3
conv5_3: 512 512 3 3
conv5_4: 512 512 3 3
fc6: 1 1 25088 4096
fc7: 1 1 4096 4096
fc8: 1 1 4096 1000
Working on patchmatch layer     4       :       relu4_1
luajit: neural_paint.lua:140: attempt to index a nil value
stack traceback:
        neural_paint.lua:140: in function 'main'
        neural_paint.lua:739: in main chunk
        [C]: in function 'dofile'
        /usr/bin/th:150: in main chunk
        [C]: at 0x00404680
luanfujun commented 6 years ago

This is interesting. From your full log I don't see the feature extraction code part running (line 113-127 in neural_paint.lua. Could you add some printing information in that part to ensure it has been executed?

2m commented 6 years ago

I printed out #cnn just before this loop

https://github.com/luanfujun/deep-painterly-harmonization/blob/4db7836fa0e060322645700fb3a0cd0be89c27ab/neural_paint.lua#L113

and it was 0.

luanfujun commented 6 years ago

Could ypou try re-downloading the VGG_ILSVRC_19_layers_deploy.prototxt and VGG_ILSVRC_19_layers.caffemodel? The VGG_ILSVRC_19_layers.caffemodel should have MD5 sum: b5c644beabd7cf06bdd9065cfd674c97.

2m commented 6 years ago

The caffemodel checksum seems to be fine:

➜  deep-painterly-harmonization git:(master) ✗ md5sum models/VGG_ILSVRC_19_layers.caffemodel
b5c644beabd7cf06bdd9065cfd674c97  models/VGG_ILSVRC_19_layers.caffemodel
luanfujun commented 6 years ago

I see. What about the file VGG_ILSVRC_19_layers_deploy.prototxt: ccbbdda59210208be39f8974f5b5765e?

If they also match, I suspect it to be the problem from loadcaffe package. Can you run:

loadcaffe.load(params.proto_file, params.model_file, 'nn')

in CPU model after reinstalling it?

Thanks! Fujun

2m commented 6 years ago

Yea, the prototxt also matches:

➜  deep-painterly-harmonization git:(master) ✗ md5sum models/VGG_ILSVRC_19_layers_deploy.prototxt
ccbbdda59210208be39f8974f5b5765e  models/VGG_ILSVRC_19_layers_deploy.prototxt

Can you elaborate more on

in CPU model after reinstalling it?

I do not have much experiance with loadcaffe. :)

luanfujun commented 6 years ago

Sorry. I mean re-installing loadcaffe using: luarocks install loadcaffe and load the VGG19 in CPU mode.

I just ran this command on an ubuntu 16.04: loadcaffe_screenshot

Based on your previous full log, it seems our libprotobuf version might be different since mine prints the warning message. Are you using Mac OSX? I have only tested the code in ubuntu 16.04 LTS currently.

luanfujun commented 6 years ago

Can you call cnn:get(i) after loading it? If so, a simple yet ugly workaround for this would be hardcoding the number of layers to 46 since VGG-19 is fixed.

JangminSon commented 6 years ago

I got same Issue. image

I've checked md5checksum. I think loadcaffe does load models but it doesn't look like variable cnn has the data

Can you tell me any idea ?

JangminSon commented 6 years ago

image It looks like #cnn is 0 so it doesn't goes into for statement at the line num166 and error occurs at line 144~

Please help me with this issue

luanfujun commented 6 years ago

What about replacing #cnn with cnn:size() or table.getn(cnn)?

2m commented 6 years ago

That was it! Now it works! Thank you very much for the hint.