orobix / retina-unet

Retina blood vessel segmentation with a convolutional neural network
1.26k stars 468 forks source link

Dimension 1 in both shapes must be equal, but are 12 and 24 for 'merge_1/concat' #39

Open pontikos opened 6 years ago

pontikos commented 6 years ago

I've downloaded the DRIVE datasets but when I run this:

python run_testing.py

I get this error:

Traceback (most recent call last):
  File "./src/retinaNN_predict.py", line 111, in <module>
    model = model_from_json(open(path_experiment+name_experiment +'_architecture.json').read())
  File "/Users/pontikos/Library/Python/2.7/lib/python/site-packages/keras/models.py", line 345, in model_from_json
    return layer_module.deserialize(config, custom_objects=custom_objects)
  File "/Users/pontikos/Library/Python/2.7/lib/python/site-packages/keras/layers/__init__.py", line 54, in deserialize
    printable_module_name='layer')
  File "/Users/pontikos/Library/Python/2.7/lib/python/site-packages/keras/utils/generic_utils.py", line 139, in deserialize_keras_object
    list(custom_objects.items())))
  File "/Users/pontikos/Library/Python/2.7/lib/python/site-packages/keras/engine/topology.py", line 2497, in from_config
    process_node(layer, node_data)
  File "/Users/pontikos/Library/Python/2.7/lib/python/site-packages/keras/engine/topology.py", line 2456, in process_node
    layer(input_tensors, **kwargs)
  File "/Users/pontikos/Library/Python/2.7/lib/python/site-packages/keras/engine/topology.py", line 602, in __call__
    output = self.call(inputs, **kwargs)
  File "/Users/pontikos/Library/Python/2.7/lib/python/site-packages/keras/legacy/layers.py", line 212, in call
    return K.concatenate(inputs, axis=self.concat_axis)
  File "/Users/pontikos/Library/Python/2.7/lib/python/site-packages/keras/backend/tensorflow_backend.py", line 1709, in concatenate
    return tf.concat([to_dense(x) for x in tensors], axis)
  File "/Users/pontikos/anaconda2/lib/python2.7/site-packages/tensorflow/python/ops/array_ops.py", line 1034, in concat
    name=name)
  File "/Users/pontikos/anaconda2/lib/python2.7/site-packages/tensorflow/python/ops/gen_array_ops.py", line 519, in _concat_v2
    name=name)
  File "/Users/pontikos/anaconda2/lib/python2.7/site-packages/tensorflow/python/framework/op_def_library.py", line 768, in apply_op
    op_def=op_def)
  File "/Users/pontikos/anaconda2/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 2338, in create_op
    set_shapes_for_outputs(ret)
  File "/Users/pontikos/anaconda2/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 1719, in set_shapes_for_outputs
    shapes = shape_func(op)
  File "/Users/pontikos/anaconda2/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 1669, in call_with_requiring
    return call_cpp_shape_fn(op, require_shape_fn=True)
  File "/Users/pontikos/anaconda2/lib/python2.7/site-packages/tensorflow/python/framework/common_shapes.py", line 610, in call_cpp_shape_fn
    debug_python_shape_fn, require_shape_fn)
  File "/Users/pontikos/anaconda2/lib/python2.7/site-packages/tensorflow/python/framework/common_shapes.py", line 676, in _call_cpp_shape_fn_impl
    raise ValueError(err.message)
ValueError: Dimension 1 in both shapes must be equal, but are 12 and 24 for 'merge_1/concat' (op: 'ConcatV2') with input shapes: [?,256,24,12], [?,64,24,24], [] and with computed input tensors: input[2] = <1>.
longw010 commented 6 years ago

Hi, I met the same error. Then, I changed my keras.json to

"image_data_format" : "channels_first",
"epsilon": 1e-07,
"floatx": "float32",
"backend": "tensorflow"

It worked!

May it help!

pontikos commented 6 years ago

Thank you, that fixed it!

On 8 Nov 2017 2:41 am, "Long Wang" notifications@github.com wrote:

Hi, I met the same error. Then, I changed my keras.json to

"image_data_format" : "channels_first", "epsilon": 1e-07, "floatx": "float32", "backend": "tensorflow"

It worked!

May it help!

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/orobix/retina-unet/issues/39#issuecomment-342562800, or mute the thread https://github.com/notifications/unsubscribe-auth/ADrG9ACxrNglN3q2VeWhnEnuhYJ9eSUEks5s0JZKgaJpZM4QCpOt .

imwilliam1230 commented 6 years ago

Have you fixed it ? I have the same problem and seem the solution above not work. ........................................................ /home/thviet/anaconda2/envs/retina/lib/python2.7/site-packages/keras/engine/topology.py:1252: UserWarning: Update your InputLayer call to the Keras 2 API: InputLayer(dtype="float32", batch_input_shape=[None, 1, ..., name="input_1") return cls(config) /home/thviet/anaconda2/envs/retina/lib/python2.7/site-packages/keras/engine/topology.py:1252: UserWarning: Update your Conv2D call to the Keras 2 API: Conv2D(kernel_initializer="glorot_uniform", kernel_constraint=None, activity_regularizer=None, trainable=True, padding="same", strides=[1, 1], filters=32, use_bias=True, name="convolution2d_1", bias_regularizer=None, bias_constraint=None, data_format="channels_first", kernel_regularizer=None, activation="relu", kernel_size=(3, 3)) return cls(config) /home/thviet/anaconda2/envs/retina/lib/python2.7/site-packages/keras/engine/topology.py:1252: UserWarning: Update your Dropout call to the Keras 2 API: Dropout(rate=0.2, trainable=True, name="dropout_1") return cls(config) /home/thviet/anaconda2/envs/retina/lib/python2.7/site-packages/keras/engine/topology.py:1252: UserWarning: Update your Conv2D call to the Keras 2 API: Conv2D(kernel_initializer="glorot_uniform", kernel_constraint=None, activity_regularizer=None, trainable=True, padding="same", strides=[1, 1], filters=32, use_bias=True, name="convolution2d_2", bias_regularizer=None, bias_constraint=None, data_format="channels_first", kernel_regularizer=None, activation="relu", kernel_size=(3, 3)) return cls(config) /home/thviet/anaconda2/envs/retina/lib/python2.7/site-packages/keras/engine/topology.py:1252: UserWarning: Update your MaxPooling2D call to the Keras 2 API: MaxPooling2D(name="maxpooling2d_1", trainable=True, data_format="channels_first", pool_size=[2, 2], padding="valid", strides=[2, 2]) return cls(config) /home/thviet/anaconda2/envs/retina/lib/python2.7/site-packages/keras/engine/topology.py:1252: UserWarning: Update your Conv2D call to the Keras 2 API: Conv2D(kernel_initializer="glorot_uniform", kernel_constraint=None, activity_regularizer=None, trainable=True, padding="same", strides=[1, 1], filters=64, use_bias=True, name="convolution2d_3", bias_regularizer=None, bias_constraint=None, data_format="channels_first", kernel_regularizer=None, activation="relu", kernel_size=(3, 3)) return cls(config) /home/thviet/anaconda2/envs/retina/lib/python2.7/site-packages/keras/engine/topology.py:1252: UserWarning: Update your Dropout call to the Keras 2 API: Dropout(rate=0.2, trainable=True, name="dropout_2") return cls(config) /home/thviet/anaconda2/envs/retina/lib/python2.7/site-packages/keras/engine/topology.py:1252: UserWarning: Update your Conv2D call to the Keras 2 API: Conv2D(kernel_initializer="glorot_uniform", kernel_constraint=None, activity_regularizer=None, trainable=True, padding="same", strides=[1, 1], filters=64, use_bias=True, name="convolution2d_4", bias_regularizer=None, bias_constraint=None, data_format="channels_first", kernel_regularizer=None, activation="relu", kernel_size=(3, 3)) return cls(config) /home/thviet/anaconda2/envs/retina/lib/python2.7/site-packages/keras/engine/topology.py:1252: UserWarning: Update your MaxPooling2D call to the Keras 2 API: MaxPooling2D(name="maxpooling2d_2", trainable=True, data_format="channels_first", pool_size=[2, 2], padding="valid", strides=[2, 2]) return cls(config) /home/thviet/anaconda2/envs/retina/lib/python2.7/site-packages/keras/engine/topology.py:1252: UserWarning: Update your Conv2D call to the Keras 2 API: Conv2D(kernel_initializer="glorot_uniform", kernel_constraint=None, activity_regularizer=None, trainable=True, padding="same", strides=[1, 1], filters=128, use_bias=True, name="convolution2d_5", bias_regularizer=None, bias_constraint=None, data_format="channels_first", kernel_regularizer=None, activation="relu", kernel_size=(3, 3)) return cls(config) /home/thviet/anaconda2/envs/retina/lib/python2.7/site-packages/keras/engine/topology.py:1252: UserWarning: Update your Dropout call to the Keras 2 API: Dropout(rate=0.2, trainable=True, name="dropout_3") return cls(config) /home/thviet/anaconda2/envs/retina/lib/python2.7/site-packages/keras/engine/topology.py:1252: UserWarning: Update your Conv2D call to the Keras 2 API: Conv2D(kernel_initializer="glorot_uniform", kernel_constraint=None, activity_regularizer=None, trainable=True, padding="same", strides=[1, 1], filters=128, use_bias=True, name="convolution2d_6", bias_regularizer=None, bias_constraint=None, data_format="channels_first", kernel_regularizer=None, activation="relu", kernel_size=(3, 3)) return cls(config) /home/thviet/anaconda2/envs/retina/lib/python2.7/site-packages/keras/engine/topology.py:1252: UserWarning: The Merge layer is deprecated and will be removed after 08/2017. Use instead layers from keras.layers.merge, e.g. add, concatenate, etc. return cls(config) /home/thviet/anaconda2/envs/retina/lib/python2.7/site-packages/keras/engine/topology.py:1252: UserWarning: Update your Conv2D call to the Keras 2 API: Conv2D(kernel_initializer="glorot_uniform", kernel_constraint=None, activity_regularizer=None, trainable=True, padding="same", strides=[1, 1], filters=64, use_bias=True, name="convolution2d_7", bias_regularizer=None, bias_constraint=None, data_format="channels_first", kernel_regularizer=None, activation="relu", kernel_size=(3, 3)) return cls(config) /home/thviet/anaconda2/envs/retina/lib/python2.7/site-packages/keras/engine/topology.py:1252: UserWarning: Update your Dropout call to the Keras 2 API: Dropout(rate=0.2, trainable=True, name="dropout_4") return cls(config) /home/thviet/anaconda2/envs/retina/lib/python2.7/site-packages/keras/engine/topology.py:1252: UserWarning: Update your Conv2D call to the Keras 2 API: Conv2D(kernel_initializer="glorot_uniform", kernel_constraint=None, activity_regularizer=None, trainable=True, padding="same", strides=[1, 1], filters=64, use_bias=True, name="convolution2d_8", bias_regularizer=None, bias_constraint=None, data_format="channels_first", kernel_regularizer=None, activation="relu", kernel_size=(3, 3)) return cls(config) /home/thviet/anaconda2/envs/retina/lib/python2.7/site-packages/keras/engine/topology.py:1252: UserWarning: Update your Conv2D call to the Keras 2 API: Conv2D(kernel_initializer="glorot_uniform", kernel_constraint=None, activity_regularizer=None, trainable=True, padding="same", strides=[1, 1], filters=32, use_bias=True, name="convolution2d_9", bias_regularizer=None, bias_constraint=None, data_format="channels_first", kernel_regularizer=None, activation="relu", kernel_size=(3, 3)) return cls(config) /home/thviet/anaconda2/envs/retina/lib/python2.7/site-packages/keras/engine/topology.py:1252: UserWarning: Update your Dropout call to the Keras 2 API: Dropout(rate=0.2, trainable=True, name="dropout_5") return cls(config) /home/thviet/anaconda2/envs/retina/lib/python2.7/site-packages/keras/engine/topology.py:1252: UserWarning: Update your Conv2D call to the Keras 2 API: Conv2D(kernel_initializer="glorot_uniform", kernel_constraint=None, activity_regularizer=None, trainable=True, padding="same", strides=[1, 1], filters=32, use_bias=True, name="convolution2d_10", bias_regularizer=None, bias_constraint=None, data_format="channels_first", kernel_regularizer=None, activation="relu", kernel_size=(3, 3)) return cls(config) /home/thviet/anaconda2/envs/retina/lib/python2.7/site-packages/keras/engine/topology.py:1252: UserWarning: Update your Conv2D call to the Keras 2 API: Conv2D(kernel_initializer="glorot_uniform", kernel_constraint=None, activity_regularizer=None, trainable=True, padding="same", strides=[1, 1], filters=2, use_bias=True, name="convolution2d_11", bias_regularizer=None, bias_constraint=None, data_format="channels_first", kernel_regularizer=None, activation="relu", kernel_size=(1, 1)) return cls(config) 2017-12-11 15:24:11.000932: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.1 instructions, but these are available on your machine and could speed up CPU computations. 2017-12-11 15:24:11.000979: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.2 instructions, but these are available on your machine and could speed up CPU computations. 2017-12-11 15:24:11.000987: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX instructions, but these are available on your machine and could speed up CPU computations. 2017-12-11 15:24:11.000992: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX2 instructions, but these are available on your machine and could speed up CPU computations. 2017-12-11 15:24:11.000998: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use FMA instructions, but these are available on your machine and could speed up CPU computations. .......................................................

Here is my keras.json { "image_data_format" : "channels_first", "epsilon": 1e-07, "floatx": "float32", "backend": "tensorflow" }

msaadsadiq commented 6 years ago

I have the same problem


test PATCHES images shape: (228900, 1, 48, 48) test PATCHES images range (min-max): 0.0 - 1.0 /home/saad/anaconda3/lib/python3.6/site-packages/keras/engine/topology.py:1269: UserWarning: Update your InputLayer call to the Keras 2 API: InputLayer(batch_input_shape=[None, 1, ..., name="input_1", dtype="float32") return cls(config) /home/saad/anaconda3/lib/python3.6/site-packages/keras/engine/topology.py:1269: UserWarning: Update your Conv2D call to the Keras 2 API: Conv2D(name="convolution2d_1", activity_regularizer=None, trainable=True, activation="relu", kernel_size=(3, 3), filters=32, strides=[1, 1], padding="same", data_format="channels_first", kernel_initializer="glorot_uniform", kernel_regularizer=None, bias_regularizer=None, kernel_constraint=None, bias_constraint=None, use_bias=True) return cls(config) /home/saad/anaconda3/lib/python3.6/site-packages/keras/engine/topology.py:1269: UserWarning: Update your Dropout call to the Keras 2 API: Dropout(trainable=True, name="dropout_1", rate=0.2) return cls(config) /home/saad/anaconda3/lib/python3.6/site-packages/keras/engine/topology.py:1269: UserWarning: Update your Conv2D call to the Keras 2 API: Conv2D(name="convolution2d_2", activity_regularizer=None, trainable=True, activation="relu", kernel_size=(3, 3), filters=32, strides=[1, 1], padding="same", data_format="channels_first", kernel_initializer="glorot_uniform", kernel_regularizer=None, bias_regularizer=None, kernel_constraint=None, bias_constraint=None, use_bias=True) return cls(config) /home/saad/anaconda3/lib/python3.6/site-packages/keras/engine/topology.py:1269: UserWarning: Update your MaxPooling2D call to the Keras 2 API: MaxPooling2D(name="maxpooling2d_1", trainable=True, pool_size=[2, 2], strides=[2, 2], padding="valid", data_format="channels_first") return cls(config) /home/saad/anaconda3/lib/python3.6/site-packages/keras/engine/topology.py:1269: UserWarning: Update your Conv2D call to the Keras 2 API: Conv2D(name="convolution2d_3", activity_regularizer=None, trainable=True, activation="relu", kernel_size=(3, 3), filters=64, strides=[1, 1], padding="same", data_format="channels_first", kernel_initializer="glorot_uniform", kernel_regularizer=None, bias_regularizer=None, kernel_constraint=None, bias_constraint=None, use_bias=True) return cls(config) /home/saad/anaconda3/lib/python3.6/site-packages/keras/engine/topology.py:1269: UserWarning: Update your Dropout call to the Keras 2 API: Dropout(trainable=True, name="dropout_2", rate=0.2) return cls(config) /home/saad/anaconda3/lib/python3.6/site-packages/keras/engine/topology.py:1269: UserWarning: Update your Conv2D call to the Keras 2 API: Conv2D(name="convolution2d_4", activity_regularizer=None, trainable=True, activation="relu", kernel_size=(3, 3), filters=64, strides=[1, 1], padding="same", data_format="channels_first", kernel_initializer="glorot_uniform", kernel_regularizer=None, bias_regularizer=None, kernel_constraint=None, bias_constraint=None, use_bias=True) return cls(config) /home/saad/anaconda3/lib/python3.6/site-packages/keras/engine/topology.py:1269: UserWarning: Update your MaxPooling2D call to the Keras 2 API: MaxPooling2D(name="maxpooling2d_2", trainable=True, pool_size=[2, 2], strides=[2, 2], padding="valid", data_format="channels_first") return cls(config) /home/saad/anaconda3/lib/python3.6/site-packages/keras/engine/topology.py:1269: UserWarning: Update your Conv2D call to the Keras 2 API: Conv2D(name="convolution2d_5", activity_regularizer=None, trainable=True, activation="relu", kernel_size=(3, 3), filters=128, strides=[1, 1], padding="same", data_format="channels_first", kernel_initializer="glorot_uniform", kernel_regularizer=None, bias_regularizer=None, kernel_constraint=None, bias_constraint=None, use_bias=True) return cls(config) /home/saad/anaconda3/lib/python3.6/site-packages/keras/engine/topology.py:1269: UserWarning: Update your Dropout call to the Keras 2 API: Dropout(trainable=True, name="dropout_3", rate=0.2) return cls(config) /home/saad/anaconda3/lib/python3.6/site-packages/keras/engine/topology.py:1269: UserWarning: Update your Conv2D call to the Keras 2 API: Conv2D(name="convolution2d_6", activity_regularizer=None, trainable=True, activation="relu", kernel_size=(3, 3), filters=128, strides=[1, 1], padding="same", data_format="channels_first", kernel_initializer="glorot_uniform", kernel_regularizer=None, bias_regularizer=None, kernel_constraint=None, bias_constraint=None, use_bias=True) return cls(config) /home/saad/anaconda3/lib/python3.6/site-packages/keras/engine/topology.py:1269: UserWarning: The Merge layer is deprecated and will be removed after 08/2017. Use instead layers from keras.layers.merge, e.g. add, concatenate, etc. return cls(config) /home/saad/anaconda3/lib/python3.6/site-packages/keras/engine/topology.py:1269: UserWarning: Update your Conv2D call to the Keras 2 API: Conv2D(name="convolution2d_7", activity_regularizer=None, trainable=True, activation="relu", kernel_size=(3, 3), filters=64, strides=[1, 1], padding="same", data_format="channels_first", kernel_initializer="glorot_uniform", kernel_regularizer=None, bias_regularizer=None, kernel_constraint=None, bias_constraint=None, use_bias=True) return cls(config) /home/saad/anaconda3/lib/python3.6/site-packages/keras/engine/topology.py:1269: UserWarning: Update your Dropout call to the Keras 2 API: Dropout(trainable=True, name="dropout_4", rate=0.2) return cls(config) /home/saad/anaconda3/lib/python3.6/site-packages/keras/engine/topology.py:1269: UserWarning: Update your Conv2D call to the Keras 2 API: Conv2D(name="convolution2d_8", activity_regularizer=None, trainable=True, activation="relu", kernel_size=(3, 3), filters=64, strides=[1, 1], padding="same", data_format="channels_first", kernel_initializer="glorot_uniform", kernel_regularizer=None, bias_regularizer=None, kernel_constraint=None, bias_constraint=None, use_bias=True) return cls(config) /home/saad/anaconda3/lib/python3.6/site-packages/keras/engine/topology.py:1269: UserWarning: Update your Conv2D call to the Keras 2 API: Conv2D(name="convolution2d_9", activity_regularizer=None, trainable=True, activation="relu", kernel_size=(3, 3), filters=32, strides=[1, 1], padding="same", data_format="channels_first", kernel_initializer="glorot_uniform", kernel_regularizer=None, bias_regularizer=None, kernel_constraint=None, bias_constraint=None, use_bias=True) return cls(config) /home/saad/anaconda3/lib/python3.6/site-packages/keras/engine/topology.py:1269: UserWarning: Update your Dropout call to the Keras 2 API: Dropout(trainable=True, name="dropout_5", rate=0.2) return cls(config) /home/saad/anaconda3/lib/python3.6/site-packages/keras/engine/topology.py:1269: UserWarning: Update your Conv2D call to the Keras 2 API: Conv2D(name="convolution2d_10", activity_regularizer=None, trainable=True, activation="relu", kernel_size=(3, 3), filters=32, strides=[1, 1], padding="same", data_format="channels_first", kernel_initializer="glorot_uniform", kernel_regularizer=None, bias_regularizer=None, kernel_constraint=None, bias_constraint=None, use_bias=True) return cls(config) /home/saad/anaconda3/lib/python3.6/site-packages/keras/engine/topology.py:1269: UserWarning: Update your Conv2D call to the Keras 2 API: Conv2D(name="convolution2d_11", activity_regularizer=None, trainable=True, activation="relu", kernel_size=(1, 1), filters=2, strides=[1, 1], padding="same", data_format="channels_first", kernel_initializer="glorot_uniform", kernel_regularizer=None, bias_regularizer=None, kernel_constraint=None, bias_constraint=None, use_bias=True) return cls(config) 2018-02-08 13:25:04.736991: I tensorflow/core/platform/cpu_feature_guard.cc:137] Your CPU supports instructions that this TensorFlow binary was not compiled to use: SSE4.1 SSE4.2 AVX AVX2 FMA 2018-02-08 13:25:05.110080: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1030] Found device 0 with properties: name: TITAN Xp COLLECTORS EDITION major: 6 minor: 1 memoryClockRate(GHz): 1.582 pciBusID: 0000:03:00.0 totalMemory: 11.90GiB freeMemory: 11.25GiB 2018-02-08 13:25:05.110120: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1120] Creating TensorFlow device (/device:GPU:0) -> (device: 0, name: TITAN Xp COLLECTORS EDITION, pci bus id: 0000:03:00.0, compute capability: 6.1) 2018-02-08 13:25:10.244735: E tensorflow/stream_executor/cuda/cuda_dnn.cc:378] Loaded runtime CuDNN library: 7005 (compatibility version 7000) but source was compiled with 6021 (compatibility version 6000). If using a binary install, upgrade your CuDNN library to match. If building from sources, make sure the library loaded at runtime matches a compatible version specified during compile configuration. 2018-02-08 13:25:10.245843: F tensorflow/core/kernels/conv_ops.cc:667] Check failed: stream->parent()->GetConvolveAlgorithms( conv_parameters.ShouldIncludeWinogradNonfusedAlgo(), &algorithms) Aborted (core dumped)