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

sndre opened this issue · comments

The following error happens when I try to run model on an example image:

$ python main.py "experiments/butterfly-0.5x.bmp" --model=sr --scale=2
Using Theano backend.
Old Size :  (128, 128, 3)
New Size : (256, 256, 3)
Number of patches = 62001, Patch Shape = (8, 8)
Model loaded.
Traceback (most recent call last):
  File "/Users/dante/anaconda/lib/python3.5/site-packages/theano/compile/function_module.py", line 859, in __call__
    outputs = self.fn()
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 <module>
    model.upscale(path, save_intermediate=save, mode=mode, patch_size=patch_size, suffix=suffix)
  File "/Users/dante/Developer/udacity/sdc/samples/Image-Super-Resolution/models.py", line 186, in upscale
    result = model.predict(img_conv, batch_size=128, verbose=verbose)
  File "/Users/dante/anaconda/lib/python3.5/site-packages/keras/engine/training.py", line 1219, in predict
    batch_size=batch_size, verbose=verbose)
  File "/Users/dante/anaconda/lib/python3.5/site-packages/keras/engine/training.py", line 897, in _predict_loop
    batch_outs = f(ins_batch)
  File "/Users/dante/anaconda/lib/python3.5/site-packages/keras/backend/theano_backend.py", line 919, in __call__
    return self.function(*inputs)
  File "/Users/dante/anaconda/lib/python3.5/site-packages/theano/compile/function_module.py", line 871, in __call__
    storage_map=getattr(self.fn, 'storage_map', None))
  File "/Users/dante/anaconda/lib/python3.5/site-packages/theano/gof/link.py", line 314, in raise_with_op
    reraise(exc_type, exc_value, exc_trace)
  File "/Users/dante/anaconda/lib/python3.5/site-packages/six.py", line 685, in reraise
    raise value.with_traceback(tb)
  File "/Users/dante/anaconda/lib/python3.5/site-packages/theano/compile/function_module.py", line 859, in __call__
    outputs = self.fn()
ValueError: CorrMM images and kernel must have the same stack size

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

Backtrace when the node is created(use Theano flag traceback.limit=N to make it longer):
  File "main.py", line 50, in <module>
    model.upscale(path, save_intermediate=save, mode=mode, patch_size=patch_size, suffix=suffix)
  File "/Users/dante/Developer/udacity/sdc/samples/Image-Super-Resolution/models.py", line 182, in upscale
    model = self.create_model(img_height, img_width, load_weights=True)
  File "/Users/dante/Developer/udacity/sdc/samples/Image-Super-Resolution/models.py", line 475, in create_model
    x = Convolution2D(self.n1, self.f1, self.f1, activation='relu', border_mode='same', name='level1')(init)
  File "/Users/dante/anaconda/lib/python3.5/site-packages/keras/engine/topology.py", line 569, in __call__
    self.add_inbound_node(inbound_layers, node_indices, tensor_indices)
  File "/Users/dante/anaconda/lib/python3.5/site-packages/keras/engine/topology.py", line 632, in add_inbound_node
    Node.create_node(self, inbound_layers, node_indices, tensor_indices)
  File "/Users/dante/anaconda/lib/python3.5/site-packages/keras/engine/topology.py", line 164, in create_node
    output_tensors = to_list(outbound_layer.call(input_tensors[0], mask=input_masks[0]))
  File "/Users/dante/anaconda/lib/python3.5/site-packages/keras/layers/convolutional.py", line 442, in call
    filter_shape=self.W_shape)
  File "/Users/dante/anaconda/lib/python3.5/site-packages/keras/backend/theano_backend.py", line 1454, in conv2d
    filter_shape=filter_shape)

I use Python 3.5.2, Theano 0.8.2, and Keras 1.2.0.

Updated to Theano 0.9.0 and Keras 2.0.3, but it still fails with the same error.

Thank you, @titu1994, it works now!