titu1994 / Image-Super-Resolution

Implementation of Super Resolution CNN in Keras.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Problem with PSNRLoss

JordanPeltier opened this issue · comments

Hi,
When I tried to run an example, I got the following error in PSNRLoss :
AttributeError: 'Tensor' object has no attribute 'log10'

I am using :

  • Python 3.6.0
  • Tensorflow 0.12.1
  • Theano 0.9.0dev5.dev-e345e095f94b0186b401977607eb009612ac821f
  • Keras 1.2.0 with tensorflow backend

Any ideas ?

i think if you run it with theano backend, you will not find that error.

Nice thank you

Now I can get one intermediate image but not the final one.
With the exception_verbosity="high" flag, I get the following logs (seems to be a shape mismatch at one of the intermediate conv).

Debugprint of the apply node: 
Assert{msg='AbstractConv shape mismatch: shape of filters does not match given kshp.'} [id A] <TensorType(float32, 4D)> ''   
 |InplaceDimShuffle{3,2,0,1} [id B] <TensorType(float32, 4D)> ''   
 | |convolution2d_1_W [id C] <TensorType(float32, 4D)>
 |Elemwise{eq,no_inplace} [id D] <TensorType(bool, scalar)> ''   
 | |Shape_i{3} [id E] <TensorType(int64, scalar)> ''   
 | | |convolution2d_1_W [id C] <TensorType(float32, 4D)>
 | |TensorConstant{64} [id F] <TensorType(int8, scalar)>
 |Elemwise{eq,no_inplace} [id G] <TensorType(bool, scalar)> ''   
 | |Shape_i{2} [id H] <TensorType(int64, scalar)> ''   
 | | |convolution2d_1_W [id C] <TensorType(float32, 4D)>
 | |TensorConstant{3} [id I] <TensorType(int8, scalar)>
 |Elemwise{eq,no_inplace} [id J] <TensorType(bool, scalar)> ''   
 | |Shape_i{0} [id K] <TensorType(int64, scalar)> ''   
 | | |convolution2d_1_W [id C] <TensorType(float32, 4D)>
 | |TensorConstant{3} [id I] <TensorType(int8, scalar)>
 |Elemwise{eq,no_inplace} [id L] <TensorType(bool, scalar)> ''   
   |Shape_i{1} [id M] <TensorType(int64, scalar)> ''   
   | |convolution2d_1_W [id C] <TensorType(float32, 4D)>
   |TensorConstant{3} [id I] <TensorType(int8, scalar)>

Storage map footprint:
 - deconvolution2d_2_W, Shared Input, Shape: (64, 64, 3, 3), ElemSize: 4 Byte(s), TotalSize: 147456 Byte(s)
 - convolution2d_2_W, Shared Input, Shape: (64, 64, 3, 3), ElemSize: 4 Byte(s), TotalSize: 147456 Byte(s)
 - deconvolution2d_1_W, Shared Input, Shape: (64, 64, 3, 3), ElemSize: 4 Byte(s), TotalSize: 147456 Byte(s)
 - input_1, Input, Shape: (128, 8, 8, 3), ElemSize: 4 Byte(s), TotalSize: 98304 Byte(s)
 - InplaceDimShuffle{0,3,1,2}.0, Shape: (128, 3, 8, 8), ElemSize: 4 Byte(s), TotalSize: 98304 Byte(s)
 - convolution2d_3_W, Shared Input, Shape: (3, 64, 5, 5), ElemSize: 4 Byte(s), TotalSize: 19200 Byte(s)
 - convolution2d_1_W, Shared Input, Shape: (64, 3, 3, 3), ElemSize: 4 Byte(s), TotalSize: 6912 Byte(s)
 - InplaceDimShuffle{3,2,0,1}.0, Shape: (3, 3, 64, 3), ElemSize: 4 Byte(s), TotalSize: 6912 Byte(s)
 - convolution2d_1_b, Shared Input, Shape: (64,), ElemSize: 4 Byte(s), TotalSize: 256 Byte(s)
 - convolution2d_2_b, Shared Input, Shape: (64,), ElemSize: 4 Byte(s), TotalSize: 256 Byte(s)
 - deconvolution2d_1_b, Shared Input, Shape: (64,), ElemSize: 4 Byte(s), TotalSize: 256 Byte(s)
 - deconvolution2d_2_b, Shared Input, Shape: (64,), ElemSize: 4 Byte(s), TotalSize: 256 Byte(s)
 - TensorConstant{(2,) of 8}, Shape: (2,), ElemSize: 8 Byte(s), TotalSize: 16 Byte(s)
 - convolution2d_3_b, Shared Input, Shape: (3,), ElemSize: 4 Byte(s), TotalSize: 12 Byte(s)
 - Constant{1}, Shape: (), ElemSize: 8 Byte(s), TotalSize: 8.0 Byte(s)
 - Constant{0}, Shape: (), ElemSize: 8 Byte(s), TotalSize: 8.0 Byte(s)
 - Constant{-1}, Shape: (), ElemSize: 8 Byte(s), TotalSize: 8.0 Byte(s)
 - TensorConstant{(1, 1, 1, 1) of 0.5}, Shape: (1, 1, 1, 1), ElemSize: 4 Byte(s), TotalSize: 4 Byte(s)
 - TensorConstant{5}, Shape: (), ElemSize: 1 Byte(s), TotalSize: 1.0 Byte(s)
 - TensorConstant{64}, Shape: (), ElemSize: 1 Byte(s), TotalSize: 1.0 Byte(s)
 - TensorConstant{3}, Shape: (), ElemSize: 1 Byte(s), TotalSize: 1.0 Byte(s)
 - Elemwise{eq,no_inplace}.0, Shape: (), ElemSize: 1 Byte(s), TotalSize: 1.0 Byte(s)
 - Elemwise{eq,no_inplace}.0, Shape: (), ElemSize: 1 Byte(s), TotalSize: 1.0 Byte(s)
 - Elemwise{eq,no_inplace}.0, Shape: (), ElemSize: 1 Byte(s), TotalSize: 1.0 Byte(s)
 - Elemwise{eq,no_inplace}.0, Shape: (), ElemSize: 1 Byte(s), TotalSize: 1.0 Byte(s)
 TotalSize: 567871.0 Byte(s) 0.001 GB
 TotalSize inputs: 567867.0 Byte(s) 0.001 GB

PS : I launched the following command : python main.py /Volumes/HDD/Pandascore/minimap-enhance/Image-Super-Resolution/input_images/t1.bmp --save_intermediate="True"

My set up is the same as above.

@JordanPeltier The first error was weird because I am not applying log10 to a tensor, but instead using Numpy log10 to calculate the PSNRLoss.

Could I ask which model it is you are trying to use to upscale? The repo has undergone many changes in the last 2 months or so, so many things have broken as a consequence.

@titu1994 Well I just launched the default model :
python main.py /Volumes/HDD/Pandascore/minimap-enhance/Image-Super-Resolution/input_images/t1.bmp
The first error disappeared using theano as backend for keras

@JordanPeltier
Hallo JordanPeltier,
I think you can try this code:
return 10.0 * K.log(1.0 / (K.mean(K.square(y_pred - y_true)))) / K.log(10.0)
to avoid the error:
AttributeError: 'Tensor' object has no attribute 'log10'
when using TensorFlow as backend.

@ansleliu I'll try that thanks