titu1994 / Image-Super-Resolution

Implementation of Super Resolution CNN in Keras.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ValueError: CorrMM images and kernel must have the same stack size

shreyaskamathkm opened this issue · comments

Hi, I am fairly new to Keras. I was trying to the run the network on an image. But I end up getting this error.

`Using Theano backend.
Old Size : (480, 500, 3)
New Size : (1000, 960, 3)
Number of patches = 946329, Patch Shape = (8, 8)
Model loaded.
Traceback (most recent call last):
File "/usr/local/lib/python3.5/dist-packages/theano/compile/function_module.py", line 884, in call
self.fn() if output_subset is None else
ValueError: CorrMM images and kernel must have the same stack size

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "main.py", line 50, in
model.upscale(path, save_intermediate=save, mode=mode, patch_size=patch_size, suffix=suffix)
File "/media/shreyas/6E726CFB726CC983/Box Sync/Work/machine learning/Super resolution/Super Resolution/models.py", line 186, in upscale
result = model.predict(img_conv, batch_size=128, verbose=verbose)
File "/usr/local/lib/python3.5/dist-packages/keras/engine/training.py", line 1506, in predict
batch_size=batch_size, verbose=verbose)
File "/usr/local/lib/python3.5/dist-packages/keras/engine/training.py", line 1130, in _predict_loop
batch_outs = f(ins_batch)
File "/usr/local/lib/python3.5/dist-packages/keras/backend/theano_backend.py", line 1197, in call
return self.function(*inputs)
File "/usr/local/lib/python3.5/dist-packages/theano/compile/function_module.py", line 898, in call
storage_map=getattr(self.fn, 'storage_map', None))
File "/usr/local/lib/python3.5/dist-packages/theano/gof/link.py", line 325, in raise_with_op
reraise(exc_type, exc_value, exc_trace)
File "/usr/lib/python3/dist-packages/six.py", line 685, in reraise
raise value.with_traceback(tb)
File "/usr/local/lib/python3.5/dist-packages/theano/compile/function_module.py", line 884, in call
self.fn() if output_subset is None else
ValueError: CorrMM images and kernel must have the same stack size

Apply node that caused the error: CorrMM{half, (1, 1), (1, 1)}(InplaceDimShuffle{0,3,1,2}.0, Subtensor{::, ::, ::int64, ::int64}.0)
Toposort index: 18
Inputs types: [TensorType(float32, 4D), TensorType(float32, 4D)]
Inputs shapes: [(128, 3, 8, 8), (3, 64, 3, 3)]
Inputs strides: [(768, 4, 96, 12), (36, 108, -4, -12)]
Inputs values: ['not shown', 'not shown']
Outputs clients: [[Elemwise{Composite{(i0 * ((i1 + i2) + Abs((i1 + i2))))}}[(0, 1)](TensorConstant{(1, 1, 1, 1) of 0.5}, CorrMM{half, (1, 1), (1, 1)}.0, InplaceDimShuffle{x,0,x,x}.0)]]

Backtrace when the node is created(use Theano flag traceback.limit=N to make it longer):
File "main.py", line 50, in
model.upscale(path, save_intermediate=save, mode=mode, patch_size=patch_size, suffix=suffix)
File "/media/shreyas/6E726CFB726CC983/Box Sync/Work/machine learning/Super resolution/Super Resolution/models.py", line 182, in upscale
model = self.create_model(img_height, img_width, load_weights=True)
File "/media/shreyas/6E726CFB726CC983/Box Sync/Work/machine learning/Super resolution/Super Resolution/models.py", line 561, in create_model
level1_1 = Convolution2D(self.n1, (3, 3), activation='relu', padding='same')(init)
File "/usr/local/lib/python3.5/dist-packages/keras/engine/topology.py", line 596, in call
output = self.call(inputs, **kwargs)
File "/usr/local/lib/python3.5/dist-packages/keras/layers/convolutional.py", line 164, in call
dilation_rate=self.dilation_rate)
File "/usr/local/lib/python3.5/dist-packages/keras/backend/theano_backend.py", line 1855, in conv2d
filter_dilation=dilation_rate)

HINT: Use the Theano flag 'exception_verbosity=high' for a debugprint and storage map footprint of this apply node.
`
Can you please help me to figure out this error? Do I need to try different version of Keras or Theano?
Thanks in advance

Go to your Keras.json file and change image_data_format to channels_first

Thank you very much. Works like charm!